2021-01-22 19:41:11 +02:00
|
|
|
import BaseModel from '../BaseModel';
|
2023-02-22 15:12:53 +02:00
|
|
|
import migration42 from '../migrations/42';
|
2019-05-11 18:55:40 +02:00
|
|
|
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2021-01-22 19:41:11 +02:00
|
|
|
const migrationScripts: Record<number, any> = {
|
2020-11-05 18:58:23 +02:00
|
|
|
20: require('../migrations/20.js'),
|
|
|
|
27: require('../migrations/27.js'),
|
|
|
|
33: require('../migrations/33.js'),
|
2021-04-29 16:27:38 +02:00
|
|
|
35: require('../migrations/35.js'),
|
2023-02-22 15:12:53 +02:00
|
|
|
42: migration42,
|
2019-05-11 18:55:40 +02:00
|
|
|
};
|
|
|
|
|
2021-01-22 19:41:11 +02:00
|
|
|
export default class Migration extends BaseModel {
|
2023-03-06 16:22:01 +02:00
|
|
|
public static tableName() {
|
2019-05-11 18:55:40 +02:00
|
|
|
return 'migrations';
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public static modelType() {
|
2019-05-11 18:55:40 +02:00
|
|
|
return BaseModel.TYPE_MIGRATION;
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public static migrationsToDo() {
|
2019-05-11 18:55:40 +02:00
|
|
|
return this.modelSelectAll('SELECT * FROM migrations ORDER BY number ASC');
|
|
|
|
}
|
|
|
|
|
2023-03-06 16:22:01 +02:00
|
|
|
public static script(number: number) {
|
2019-12-29 19:58:40 +02:00
|
|
|
if (!migrationScripts[number]) throw new Error('Migration script has not been added to "migrationScripts" array');
|
2019-05-11 18:55:40 +02:00
|
|
|
return migrationScripts[number];
|
|
|
|
}
|
|
|
|
}
|