You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-10 22:11:50 +02:00
Server: Fixed incorrectly named database migration that prevents new migrations from being applied
This commit is contained in:
@@ -287,7 +287,17 @@ export const sqliteSyncSlave = async (master: DbConnection, slave: DbConnection)
|
||||
await reconnectDb(slave);
|
||||
};
|
||||
|
||||
const fixMigrationNames = async (db: DbConnection) => {
|
||||
// This can be used to fix migration names, once the migration has already been deployed.
|
||||
// Incorrectly named migrations may end up being applied in the wrong order.
|
||||
await db('knex_migrations')
|
||||
.update({ name: '20250404091200_user_auth_code.js' })
|
||||
.where('name', '=', '202504040912000_user_auth_code.js');
|
||||
};
|
||||
|
||||
export async function migrateLatest(db: DbConnection, disableTransactions = false) {
|
||||
await fixMigrationNames(db);
|
||||
|
||||
await db.migrate.latest({
|
||||
directory: migrationDir,
|
||||
disableTransactions,
|
||||
@@ -295,6 +305,8 @@ export async function migrateLatest(db: DbConnection, disableTransactions = fals
|
||||
}
|
||||
|
||||
export async function migrateUp(db: DbConnection, disableTransactions = false) {
|
||||
await fixMigrationNames(db);
|
||||
|
||||
await db.migrate.up({
|
||||
directory: migrationDir,
|
||||
disableTransactions,
|
||||
@@ -302,6 +314,8 @@ export async function migrateUp(db: DbConnection, disableTransactions = false) {
|
||||
}
|
||||
|
||||
export async function migrateDown(db: DbConnection, disableTransactions = false) {
|
||||
await fixMigrationNames(db);
|
||||
|
||||
await db.migrate.down({
|
||||
directory: migrationDir,
|
||||
disableTransactions,
|
||||
@@ -309,10 +323,14 @@ export async function migrateDown(db: DbConnection, disableTransactions = false)
|
||||
}
|
||||
|
||||
export async function migrateUnlock(db: DbConnection) {
|
||||
await fixMigrationNames(db);
|
||||
|
||||
await db.migrate.forceFreeMigrationsLock();
|
||||
}
|
||||
|
||||
export async function migrateList(db: DbConnection, asString = true) {
|
||||
await fixMigrationNames(db);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
||||
const migrations: any = await db.migrate.list({
|
||||
directory: migrationDir,
|
||||
|
Reference in New Issue
Block a user