Merge branch 'master' into BUDI-7656/add-migration

This commit is contained in:
Michael Drury 2024-06-06 16:49:48 +01:00 committed by GitHub
commit ea1d3000c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 11 deletions

View File

@ -353,18 +353,15 @@ export class DatabaseImpl implements Database {
} }
async destroy() { async destroy() {
try { if (env.SQS_SEARCH_ENABLE && (await this.exists(SQLITE_DESIGN_DOC_ID))) {
if (env.SQS_SEARCH_ENABLE) {
// delete the design document, then run the cleanup operation // delete the design document, then run the cleanup operation
try { const definition = await this.get<SQLiteDefinition>(SQLITE_DESIGN_DOC_ID)
const definition = await this.get<SQLiteDefinition>( // remove all tables - save the definition then trigger a cleanup
SQLITE_DESIGN_DOC_ID definition.sql.tables = {}
) await this.put(definition)
await this.remove(SQLITE_DESIGN_DOC_ID, definition._rev)
} finally {
await this.sqlDiskCleanup() await this.sqlDiskCleanup()
} }
} try {
return await this.nano().db.destroy(this.name) return await this.nano().db.destroy(this.name)
} catch (err: any) { } catch (err: any) {
// didn't exist, don't worry // didn't exist, don't worry

View File

@ -334,6 +334,12 @@ describe("/applications", () => {
expect(events.app.deleted).toHaveBeenCalledTimes(1) expect(events.app.deleted).toHaveBeenCalledTimes(1)
expect(events.app.unpublished).toHaveBeenCalledTimes(1) expect(events.app.unpublished).toHaveBeenCalledTimes(1)
}) })
it("should be able to delete an app after SQS_SEARCH_ENABLE has been set but app hasn't been migrated", async () => {
await config.withCoreEnv({ SQS_SEARCH_ENABLE: "true" }, async () => {
await config.api.application.delete(app.appId)
})
})
}) })
describe("POST /api/applications/:appId/duplicate", () => { describe("POST /api/applications/:appId/duplicate", () => {