@@ -25,23 +25,6 @@ const execUnit = {
25
25
} ;
26
26
} ,
27
27
28
- learn : ( context , driver , file ) => {
29
- const _file = file . get ( ) ;
30
-
31
- const i = Learn . getInterface (
32
- context . _driver ,
33
- file ,
34
- driver ,
35
- context . internals
36
- ) ;
37
-
38
- return _file . migrate ( i , {
39
- options : context . internals . safeOptions ,
40
- seedLink : context . seedLink ,
41
- dbm : context . internals . safeOptions . dbmigrate
42
- } ) ;
43
- } ,
44
-
45
28
up : async function ( context , driver , file ) {
46
29
const _file = file . get ( ) ;
47
30
const chain = new Chain ( context . _driver , file , driver , context . internals ) ;
@@ -50,6 +33,10 @@ const execUnit = {
50
33
chain . addChain ( Migrate ) ;
51
34
52
35
await State . startMigration ( context . _driver , file , context . internals ) ;
36
+ // startMigration - needs secondary instance since we can not afford to
37
+ // loose state and the transaction start will include these for roll back
38
+ // we will disable them probably at all from DDL when the driver does not
39
+ // explicitly signal DDL transaction support (like crdb)
53
40
try {
54
41
await _file . migrate ( chain , {
55
42
options : context . internals . safeOptions ,
@@ -64,57 +51,16 @@ const execUnit = {
64
51
throw err ;
65
52
}
66
53
return Promise . promisify ( context . writeMigrationRecord . bind ( context ) ) ( file ) ;
67
- return execUnit . learn ( context , driver , file ) ;
68
-
69
- return context . driver
70
- . startMigration ( )
71
- . then ( ( ) => {
72
- const _file = file . get ( ) ;
73
-
74
- return _file . migrate ( context . driver , {
75
- options : context . internals . safeOptions ,
76
- seedLink : context . seedLink ,
77
- dbm : context . internals . safeOptions . dbmigrate
78
- } ) ;
79
- } )
80
- . then ( ( ) => {
81
- return Promise . promisify ( context . writeMigrationRecord . bind ( context ) ) (
82
- file
83
- ) ;
84
- } )
85
- . then ( context . driver . endMigration . bind ( context . driver ) ) ;
54
+ // end migration, same as start migration
86
55
} ,
87
56
88
57
down : async function ( context , driver , file ) {
58
+ // start migration, see up comments
89
59
await State . startMigration ( context . _driver , file , context . internals ) ;
90
60
await TranslateState ( context . _driver , file , driver , context . internals ) ;
91
61
await State . endMigration ( context . _driver , file , context . internals ) ;
92
62
return Promise . promisify ( context . deleteMigrationRecord . bind ( context ) ) ( file ) ;
93
-
94
- await _file . migrate ( chain , {
95
- options : context . internals . safeOptions ,
96
- seedLink : context . seedLink ,
97
- dbm : context . internals . safeOptions . dbmigrate
98
- } ) ;
99
- return Promise . promisify ( context . deleteMigrationRecord . bind ( context ) ) ( file ) ;
100
-
101
- return driver
102
- . startMigration ( )
103
- . then ( ( ) => {
104
- const _file = file . get ( ) ;
105
-
106
- return _file . down ( context . driver , {
107
- options : context . internals . safeOptions ,
108
- seedLink : context . seedLink ,
109
- dbm : context . internals . safeOptions . dbmigrate
110
- } ) ;
111
- } )
112
- . then ( ( ) => {
113
- return Promise . promisify ( context . deleteMigrationRecord . bind ( context ) ) (
114
- file
115
- ) ;
116
- } )
117
- . then ( context . driver . endMigration . bind ( context . driver ) ) ;
63
+ // end migration, see up comments
118
64
}
119
65
} ;
120
66
0 commit comments