File tree Expand file tree Collapse file tree 2 files changed +85
-0
lines changed
Expand file tree Collapse file tree 2 files changed +85
-0
lines changed Original file line number Diff line number Diff line change 1+ import { DataTypes } from "sequelize" ;
2+ import { Migration } from "../umzug" ;
3+
4+ const TABLE_NAME = "admin_comments" ;
5+
6+ export const up : Migration = async ( { context : sequelize } ) => {
7+ await sequelize . getQueryInterface ( ) . createTable ( TABLE_NAME , {
8+ id : {
9+ type : DataTypes . UUID ,
10+ defaultValue : DataTypes . UUIDV4 ,
11+ allowNull : false ,
12+ primaryKey : true ,
13+ } ,
14+ userId : {
15+ type : DataTypes . INTEGER ,
16+ allowNull : false ,
17+ references : {
18+ model : "users" ,
19+ key : "id" ,
20+ } ,
21+ } ,
22+ applicantRecordId : {
23+ type : DataTypes . STRING ,
24+ allowNull : false ,
25+ references : {
26+ model : "applicant_records" ,
27+ key : "id" ,
28+ } ,
29+ } ,
30+ comment : {
31+ type : DataTypes . STRING ,
32+ allowNull : false ,
33+ } ,
34+ createdAt : {
35+ type : DataTypes . DATE ,
36+ allowNull : false ,
37+ defaultValue : DataTypes . NOW ,
38+ } ,
39+ updatedAt : {
40+ type : DataTypes . DATE ,
41+ allowNull : false ,
42+ defaultValue : DataTypes . NOW ,
43+ } ,
44+ } ) ;
45+ } ;
46+
47+ export const down : Migration = async ( { context : sequelize } ) => {
48+ await sequelize . getQueryInterface ( ) . dropTable ( TABLE_NAME ) ;
49+ } ;
Original file line number Diff line number Diff line change 1+ import {
2+ Column ,
3+ DataType ,
4+ ForeignKey ,
5+ Model ,
6+ Table ,
7+ } from "sequelize-typescript" ;
8+ import User from "./user.model" ;
9+ import ApplicantRecord from "./applicantRecord.model" ;
10+
11+ @Table ( { tableName : "admin_comments" } )
12+ export default class AdminComment extends Model {
13+ @Column ( {
14+ type : DataType . UUID ,
15+ defaultValue : DataType . UUIDV4 ,
16+ primaryKey : true ,
17+ } )
18+ id ! : string ;
19+
20+ @ForeignKey ( ( ) => User )
21+ @Column ( { type : DataType . INTEGER } )
22+ userId ! : number ;
23+
24+ @ForeignKey ( ( ) => ApplicantRecord )
25+ @Column ( { type : DataType . UUID } )
26+ applicantRecordId ! : string ;
27+
28+ @Column ( { type : DataType . STRING , allowNull : false } )
29+ comment ! : string ;
30+
31+ @Column ( { type : DataType . DATE , allowNull : false } )
32+ createdAt ! : Date ;
33+
34+ @Column ( { type : DataType . DATE , allowNull : false } )
35+ updatedAt ! : Date ;
36+ }
You can’t perform that action at this time.
0 commit comments