一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
35 行
890 B
TypeScript
35 行
890 B
TypeScript
import BaseService from './BaseService';
|
|
import Migration from '../models/Migration';
|
|
|
|
export default class MigrationService extends BaseService {
|
|
|
|
private static instance_: MigrationService;
|
|
|
|
public static instance() {
|
|
if (this.instance_) return this.instance_;
|
|
this.instance_ = new MigrationService();
|
|
return this.instance_;
|
|
}
|
|
|
|
public async runScript(num: number) {
|
|
const script = Migration.script(num);
|
|
await script.exec();
|
|
}
|
|
|
|
public async run() {
|
|
const migrations = await Migration.migrationsToDo();
|
|
|
|
for (const migration of migrations) {
|
|
this.logger().info(`Running migration: ${migration.number}`);
|
|
|
|
try {
|
|
await this.runScript(migration.number);
|
|
await Migration.delete(migration.id, { sourceDescription: 'MigrationService' });
|
|
} catch (error) {
|
|
this.logger().error(`Cannot run migration: ${migration.number}`, error);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|