File tree 6 files changed +44
-2
lines changed
6 files changed +44
-2
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,14 @@ declare module '@ioc:Adonis/Lucid/Migrator' {
20
20
direction : 'up'
21
21
connectionName ?: string
22
22
dryRun ?: boolean
23
+ disableLocks ?: boolean
23
24
}
24
25
| {
25
26
direction : 'down'
26
27
batch ?: number
27
28
connectionName ?: string
28
29
dryRun ?: boolean
30
+ disableLocks ?: boolean
29
31
}
30
32
31
33
/**
@@ -53,6 +55,7 @@ declare module '@ioc:Adonis/Lucid/Migrator' {
53
55
*/
54
56
export interface MigratorContract extends EventEmitter {
55
57
dryRun : boolean
58
+ disableLocks : boolean
56
59
version : number
57
60
direction : 'up' | 'down'
58
61
status : 'completed' | 'skipped' | 'pending' | 'error'
Original file line number Diff line number Diff line change @@ -44,6 +44,12 @@ export default class Refresh extends BaseCommand {
44
44
@flags . boolean ( { description : 'Run seeders' } )
45
45
public seed : boolean
46
46
47
+ /**
48
+ * Disable advisory locks
49
+ */
50
+ @flags . boolean ( { description : 'Disable advisory locks' } )
51
+ public disableLocks : boolean
52
+
47
53
/**
48
54
* Converting command properties to arguments
49
55
*/
@@ -61,6 +67,10 @@ export default class Refresh extends BaseCommand {
61
67
args . push ( '--dry-run' )
62
68
}
63
69
70
+ if ( this . disableLocks ) {
71
+ args . push ( '--disable-locks' )
72
+ }
73
+
64
74
return args
65
75
}
66
76
Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ export default class Reset extends BaseCommand {
38
38
@flags . boolean ( { description : 'Do not run actual queries. Instead view the SQL output' } )
39
39
public dryRun : boolean
40
40
41
+ /**
42
+ * Disable advisory locks
43
+ */
44
+ @flags . boolean ( { description : 'Disable advisory locks' } )
45
+ public disableLocks : boolean
46
+
41
47
/**
42
48
* Converting command properties to arguments
43
49
*/
@@ -55,6 +61,10 @@ export default class Reset extends BaseCommand {
55
61
args . push ( '--dry-run' )
56
62
}
57
63
64
+ if ( this . disableLocks ) {
65
+ args . push ( '--disable-locks' )
66
+ }
67
+
58
68
return args
59
69
}
60
70
Original file line number Diff line number Diff line change @@ -57,6 +57,12 @@ export default class Migrate extends MigrationsBase {
57
57
@flags . boolean ( { description : 'A compact single-line output' } )
58
58
public compactOutput : boolean = false
59
59
60
+ /**
61
+ * Disable advisory locks
62
+ */
63
+ @flags . boolean ( { description : 'Disable advisory locks' } )
64
+ public disableLocks : boolean
65
+
60
66
/**
61
67
* Instantiating the migrator instance
62
68
*/
@@ -69,6 +75,7 @@ export default class Migrate extends MigrationsBase {
69
75
connectionName : this . connection ,
70
76
batch : this . batch ,
71
77
dryRun : this . dryRun ,
78
+ disableLocks : this . disableLocks
72
79
} )
73
80
}
74
81
Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ export default class Migrate extends MigrationsBase {
48
48
@flags . boolean ( { description : 'A compact single-line output' } )
49
49
public compactOutput : boolean = false
50
50
51
+ /**
52
+ * Disable advisory locks
53
+ */
54
+ @flags . boolean ( { description : 'Disable advisory locks' } )
55
+ public disableLocks : boolean
56
+
51
57
/**
52
58
* Instantiating the migrator instance
53
59
*/
@@ -59,6 +65,7 @@ export default class Migrate extends MigrationsBase {
59
65
direction : 'up' ,
60
66
connectionName : this . connection ,
61
67
dryRun : this . dryRun ,
68
+ disableLocks : this . disableLocks ,
62
69
} )
63
70
}
64
71
Original file line number Diff line number Diff line change @@ -80,6 +80,11 @@ export class Migrator extends EventEmitter implements MigratorContract {
80
80
*/
81
81
public dryRun : boolean = ! ! this . options . dryRun
82
82
83
+ /**
84
+ * Disable advisory locks
85
+ */
86
+ public disableLocks : boolean = ! ! this . options . disableLocks
87
+
83
88
/**
84
89
* An array of files we have successfully migrated. The files are
85
90
* collected regardless of `up` or `down` methods
@@ -252,7 +257,7 @@ export class Migrator extends EventEmitter implements MigratorContract {
252
257
* to the real execution cycle
253
258
*/
254
259
private async acquireLock ( ) {
255
- if ( ! this . client . dialect . supportsAdvisoryLocks ) {
260
+ if ( ! this . client . dialect . supportsAdvisoryLocks || this . disableLocks ) {
256
261
return
257
262
}
258
263
@@ -268,7 +273,7 @@ export class Migrator extends EventEmitter implements MigratorContract {
268
273
* `Mysql`, `PostgreSQL` and `MariaDb` for now.
269
274
*/
270
275
private async releaseLock ( ) {
271
- if ( ! this . client . dialect . supportsAdvisoryLocks ) {
276
+ if ( ! this . client . dialect . supportsAdvisoryLocks || this . disableLocks ) {
272
277
return
273
278
}
274
279
You can’t perform that action at this time.
0 commit comments