Migration timeouts
#696
-
Does the tool support configuring timeouts on migrations? |
Beta Was this translation helpful? Give feedback.
Answered by
mmkal
Nov 6, 2023
Replies: 1 comment
-
Nothing out of the box, but I'm open to it if you can think of a clean API. Would need to make sure it's clear what happens when a migration times out, whether a timeout config is global or local, can it be overridden etc. I don't want to go far as to say that this is the official recommended way to do this, but you could do something like import { Umzug } from 'umzug'
const migrator = new Umzug({
migrations: {
glob: 'migrations/*.js',
resolve(params) {
const base = Umzug.defaultResolver(params);
return {
...base,
async up(upParams) {
return Promise.race([
base.up(upParams),
new Promise((_resolve, reject) =>
setTimeout(() => {
reject(new Error('timeout'));
}, 1000)
),
]);
},
async down(downParams) {
return Promise.race([
base.down(downParams),
new Promise((_resolve, reject) =>
setTimeout(() => {
reject(new Error('timeout'));
}, 1000)
),
]);
},
};
},
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mmkal
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nothing out of the box, but I'm open to it if you can think of a clean API. Would need to make sure it's clear what happens when a migration times out, whether a timeout config is global or local, can it be overridden etc.
I don't want to go far as to say that this is the official recommended way to do this, but you could do something like