@@ -9,6 +9,7 @@ class STD {
9
9
this . modS = mod . c ;
10
10
this . modI = mod . i ;
11
11
this . modF = mod . f ;
12
+ this . modC = mod . s ;
12
13
}
13
14
14
15
dropTable ( t ) {
@@ -33,6 +34,8 @@ class STD {
33
34
delete this . indizies [ t ] ;
34
35
}
35
36
37
+ this . modC . push ( { t : 1 , a : 'createTable' , c : [ t ] } ) ;
38
+
36
39
return Promise . resolve ( alter ) ;
37
40
}
38
41
@@ -62,6 +65,8 @@ class STD {
62
65
}
63
66
} ) ;
64
67
68
+ this . modC . push ( { t : 0 , a : 'dropTable' , c : [ t ] } ) ;
69
+
65
70
return Promise . resolve ( ) ;
66
71
}
67
72
@@ -71,6 +76,8 @@ class STD {
71
76
delete this . schema [ t ] ;
72
77
}
73
78
79
+ this . modC . push ( { t : 0 , a : 'renameTable' , c : [ n , t ] } ) ;
80
+
74
81
return Promise . resolve ( ) ;
75
82
}
76
83
@@ -86,17 +93,16 @@ class STD {
86
93
return this . createTable . apply ( this , args ) ;
87
94
}
88
95
89
- removeColumn ( tableName , columnName , columnSpec ) {
96
+ removeColumn ( t , c ) {
90
97
let alter = { } ;
91
- alter = { c : { } , i : { } , f : { } } ;
92
- if ( this . schema [ tableName ] ) {
93
- alter . c [ tableName ] = { } ;
94
- alter . c [ tableName ] [ columnName ] = this . schema [ tableName ] [ columnName ] ;
95
- this . modS [ tableName ] = { } ;
96
- this . modS [ tableName ] [ columnName ] = this . schema [ tableName ] [ columnName ] ;
97
- delete this . schema [ tableName ] [ columnName ] ;
98
+ if ( this . schema [ t ] ) {
99
+ this . modS [ t ] = { } ;
100
+ this . modS [ t ] [ c ] = this . schema [ t ] [ c ] ;
101
+ delete this . schema [ t ] [ c ] ;
98
102
}
99
103
104
+ this . modC . push ( { t : 1 , a : 'addColumn' , c : [ t , c ] } ) ;
105
+
100
106
return Promise . resolve ( alter ) ;
101
107
}
102
108
@@ -106,6 +112,8 @@ class STD {
106
112
delete this . schema [ t ] [ o ] ;
107
113
}
108
114
115
+ this . modC . push ( { t : 0 , a : 'renameColumn' , c : [ t , n , o ] } ) ;
116
+
109
117
return Promise . resolve ( ) ;
110
118
}
111
119
@@ -116,6 +124,8 @@ class STD {
116
124
this . schema [ t ] = this . schema [ t ] || { } ;
117
125
this . schema [ t ] [ c ] = s ;
118
126
127
+ this . modC . push ( { t : 0 , a : 'removeColumn' , c : [ t , c ] } ) ;
128
+
119
129
return Promise . resolve ( ) ;
120
130
}
121
131
@@ -132,8 +142,11 @@ class STD {
132
142
changeColumn ( t , c , s ) {
133
143
this . checkColumn ( t , c ) ;
134
144
145
+ this . modS [ t ] [ c ] = this . schema [ t ] [ c ] ;
135
146
this . schema [ t ] [ c ] = Object . assign ( this . schema [ t ] [ c ] , s ) ;
136
147
148
+ this . modC . push ( { t : 1 , a : 'changeColumn' , c : [ t , c ] } ) ;
149
+
137
150
return Promise . resolve ( ) ;
138
151
}
139
152
@@ -153,6 +166,8 @@ class STD {
153
166
if ( ! this . indizies [ t ] ) this . indizies [ t ] = { } ;
154
167
this . indizies [ t ] [ i ] = index ;
155
168
169
+ this . modC . push ( { t : 0 , a : 'removeIndex' , c : [ t , i ] } ) ;
170
+
156
171
return Promise . resolve ( ) ;
157
172
}
158
173
@@ -201,6 +216,8 @@ class STD {
201
216
this . foreign [ t ] [ k ] . r = r ;
202
217
}
203
218
219
+ this . modC . push ( { t : 0 , a : 'removeForeignKey' , c : [ t , k ] } ) ;
220
+
204
221
return Promise . resolve ( ) ;
205
222
}
206
223
0 commit comments