mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-06-15 06:54:24 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f37d4a7d5 | |||
| 2f83e86d69 |
@@ -42,6 +42,7 @@ class MigrationManager {
|
|||||||
|
|
||||||
await this.fetchVersionsFromDatabase()
|
await this.fetchVersionsFromDatabase()
|
||||||
if (!this.maxVersion || !this.databaseVersion) throw new Error('Failed to fetch versions from the database.')
|
if (!this.maxVersion || !this.databaseVersion) throw new Error('Failed to fetch versions from the database.')
|
||||||
|
Logger.debug(`[MigrationManager] Database version: ${this.databaseVersion}, Max version: ${this.maxVersion}, Server version: ${this.serverVersion}`)
|
||||||
|
|
||||||
if (semver.gt(this.serverVersion, this.maxVersion)) {
|
if (semver.gt(this.serverVersion, this.maxVersion)) {
|
||||||
try {
|
try {
|
||||||
@@ -191,10 +192,11 @@ class MigrationManager {
|
|||||||
allowNull: false
|
allowNull: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
await this.sequelize.query("INSERT INTO :migrationsMeta (key, value) VALUES ('version', :version), ('maxVersion', '0.0.0')", {
|
await this.sequelize.query("INSERT INTO :migrationsMeta (key, value) VALUES ('version', '0.0.0'), ('maxVersion', '0.0.0')", {
|
||||||
replacements: { version: this.serverVersion, migrationsMeta: MigrationManager.MIGRATIONS_META_TABLE },
|
replacements: { migrationsMeta: MigrationManager.MIGRATIONS_META_TABLE },
|
||||||
type: Sequelize.QueryTypes.INSERT
|
type: Sequelize.QueryTypes.INSERT
|
||||||
})
|
})
|
||||||
|
Logger.debug(`[MigrationManager] Created migrationsMeta table: "${MigrationManager.MIGRATIONS_META_TABLE}"`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,6 +221,7 @@ class MigrationManager {
|
|||||||
await fs.copy(sourceFile, targetFile) // Asynchronously copy the files
|
await fs.copy(sourceFile, targetFile) // Asynchronously copy the files
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
Logger.debug(`[MigrationManager] Copied migrations to the config directory: "${this.migrationsDir}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ describe('MigrationManager', () => {
|
|||||||
value: { type: 'VARCHAR(255)', allowNull: false, defaultValue: undefined, primaryKey: false, unique: false }
|
value: { type: 'VARCHAR(255)', allowNull: false, defaultValue: undefined, primaryKey: false, unique: false }
|
||||||
})
|
})
|
||||||
expect(migrationManager.maxVersion).to.equal('0.0.0')
|
expect(migrationManager.maxVersion).to.equal('0.0.0')
|
||||||
expect(migrationManager.databaseVersion).to.equal(serverVersion)
|
expect(migrationManager.databaseVersion).to.equal('0.0.0')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should throw an error if the database query fails', async () => {
|
it('should throw an error if the database query fails', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user