@@ -3,6 +3,54 @@ import runner from '../runner'
3
3
4
4
export default {
5
5
up : ( queryInterface , Sequelize ) => {
6
+ const CREATE_BASE_USER = ( ) => (
7
+ queryInterface . createTable ( 'base_user' , {
8
+ base_user_id : {
9
+ type : Sequelize . UUID ,
10
+ defaultValue : Sequelize . UUIDV4 ,
11
+ allowNull : false ,
12
+ primaryKey : true
13
+ } ,
14
+ first_name : {
15
+ type : Sequelize . STRING ( 250 ) ,
16
+ allowNull : false
17
+ } ,
18
+ last_name : {
19
+ type : Sequelize . STRING ( 250 ) ,
20
+ allowNull : false
21
+ } ,
22
+ user_email : {
23
+ type : Sequelize . STRING ( 250 ) ,
24
+ allowNull : false ,
25
+ unique : true
26
+ } ,
27
+ user_password : {
28
+ type : Sequelize . STRING ,
29
+ allowNull : true ,
30
+ defaultValue : null
31
+ } ,
32
+ is_email_verified : {
33
+ type : Sequelize . BOOLEAN ,
34
+ allowNull : false ,
35
+ defaultValue : false
36
+ } ,
37
+ username : {
38
+ type : Sequelize . STRING ( 250 ) ,
39
+ allowNull : true
40
+ } ,
41
+ created_at : {
42
+ type : Sequelize . DATE ,
43
+ allowNull : false ,
44
+ defaultValue : Sequelize . literal ( 'CURRENT_TIMESTAMP' ) ,
45
+ } ,
46
+ updated_at : {
47
+ type : Sequelize . DATE ,
48
+ allowNull : false ,
49
+ defaultValue : Sequelize . literal ( 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP' )
50
+ }
51
+ } )
52
+ )
53
+
6
54
const CREATE_ARTIST = ( ) => (
7
55
queryInterface . createTable ( 'artist' , {
8
56
artist_id : {
@@ -63,16 +111,52 @@ export default {
63
111
} )
64
112
)
65
113
114
+ const CREATE_TRADER = ( ) => (
115
+ queryInterface . createTable ( 'trader' , {
116
+ trader_id : {
117
+ type : Sequelize . UUID ,
118
+ defaultValue : Sequelize . UUIDV4 ,
119
+ allowNull : false ,
120
+ primaryKey : true
121
+ } ,
122
+ trader_base_id : {
123
+ type : Sequelize . UUID ,
124
+ allowNull : false ,
125
+ primaryKey : true ,
126
+ references : {
127
+ model : 'base_user' ,
128
+ key : 'base_user_id'
129
+ } ,
130
+ onDelete : 'cascade' ,
131
+ onUpdate : 'cascade' ,
132
+ } ,
133
+ created_at : {
134
+ type : Sequelize . DATE ,
135
+ allowNull : false ,
136
+ defaultValue : Sequelize . literal ( 'CURRENT_TIMESTAMP' ) ,
137
+ } ,
138
+ updated_at : {
139
+ type : Sequelize . DATE ,
140
+ allowNull : false ,
141
+ defaultValue : Sequelize . literal ( 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP' )
142
+ }
143
+ } )
144
+ )
145
+
66
146
return runner . run ( [
147
+ ( ) => CREATE_BASE_USER ( ) ,
67
148
( ) => CREATE_ARTIST ( ) ,
68
- ( ) => CREATE_VINYL ( )
149
+ ( ) => CREATE_VINYL ( ) ,
150
+ ( ) => CREATE_TRADER ( )
69
151
] )
70
152
} ,
71
153
72
154
down : ( queryInterface , Sequelize ) => {
73
155
return runner . run ( [
156
+ ( ) => queryInterface . dropTable ( 'artist' ) ,
74
157
( ) => queryInterface . dropTable ( 'vinyl' ) ,
75
- ( ) => queryInterface . dropTable ( 'artist' )
158
+ ( ) => queryInterface . dropTable ( 'trader' ) ,
159
+ ( ) => queryInterface . dropTable ( 'base_user' )
76
160
] )
77
161
}
78
162
} ;
0 commit comments