Merge remote-tracking branch 'origin/master' into feature/automation-row-ux-update
This commit is contained in:
commit
e472dc826c
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
||||||
"version": "2.29.10",
|
"version": "2.29.11",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/*",
|
"packages/*",
|
||||||
|
|
|
@ -10,6 +10,6 @@ export const MIGRATIONS: AppMigration[] = [
|
||||||
{
|
{
|
||||||
id: "20240604153647_initial_sqs",
|
id: "20240604153647_initial_sqs",
|
||||||
func: m20240604153647_initial_sqs,
|
func: m20240604153647_initial_sqs,
|
||||||
disabled: !env.SQS_SEARCH_ENABLE,
|
disabled: !(env.SQS_MIGRATION_ENABLE || env.SQS_SEARCH_ENABLE),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -40,7 +40,7 @@ const migration = async () => {
|
||||||
// only do initial search if environment is using SQS already
|
// only do initial search if environment is using SQS already
|
||||||
// initial search makes sure that all the indexes have been created
|
// initial search makes sure that all the indexes have been created
|
||||||
// and are ready to use, avoiding any initial waits for large tables
|
// and are ready to use, avoiding any initial waits for large tables
|
||||||
if (env.SQS_SEARCH_ENABLE) {
|
if (env.SQS_MIGRATION_ENABLE || env.SQS_SEARCH_ENABLE) {
|
||||||
const tables = await sdk.tables.getAllInternalTables()
|
const tables = await sdk.tables.getAllInternalTables()
|
||||||
// do these one by one - running in parallel could cause problems
|
// do these one by one - running in parallel could cause problems
|
||||||
for (let table of tables) {
|
for (let table of tables) {
|
||||||
|
|
|
@ -66,16 +66,21 @@ function oldLinkDocument(): Omit<LinkDocument, "tableId"> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sqsDisabled(cb: () => Promise<void>) {
|
type SQSEnvVar = "SQS_MIGRATION_ENABLE" | "SQS_SEARCH_ENABLE"
|
||||||
await config.withEnv({ SQS_SEARCH_ENABLE: "" }, cb)
|
|
||||||
|
async function sqsDisabled(envVar: SQSEnvVar, cb: () => Promise<void>) {
|
||||||
|
await config.withEnv({ [envVar]: "" }, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sqsEnabled(cb: () => Promise<void>) {
|
async function sqsEnabled(envVar: SQSEnvVar, cb: () => Promise<void>) {
|
||||||
await config.withEnv({ SQS_SEARCH_ENABLE: "1" }, cb)
|
await config.withEnv({ [envVar]: "1" }, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
describe.each(["SQS_MIGRATION_ENABLE", "SQS_SEARCH_ENABLE"] as SQSEnvVar[])(
|
||||||
|
"SQS migration with (%s)",
|
||||||
|
envVar => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await sqsDisabled(async () => {
|
await sqsDisabled(envVar, async () => {
|
||||||
await config.init()
|
await config.init()
|
||||||
const table = await config.api.table.save(basicTable())
|
const table = await config.api.table.save(basicTable())
|
||||||
tableId = table._id!
|
tableId = table._id!
|
||||||
|
@ -85,11 +90,10 @@ beforeAll(async () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("SQS migration", () => {
|
|
||||||
it("test migration runs as expected against an older DB", async () => {
|
it("test migration runs as expected against an older DB", async () => {
|
||||||
const db = dbCore.getDB(config.appId!)
|
const db = dbCore.getDB(config.appId!)
|
||||||
// confirm nothing exists initially
|
// confirm nothing exists initially
|
||||||
await sqsDisabled(async () => {
|
await sqsDisabled(envVar, async () => {
|
||||||
let error: any | undefined
|
let error: any | undefined
|
||||||
try {
|
try {
|
||||||
await db.get(SQLITE_DESIGN_DOC_ID)
|
await db.get(SQLITE_DESIGN_DOC_ID)
|
||||||
|
@ -99,7 +103,7 @@ describe("SQS migration", () => {
|
||||||
expect(error).toBeDefined()
|
expect(error).toBeDefined()
|
||||||
expect(error.status).toBe(404)
|
expect(error.status).toBe(404)
|
||||||
})
|
})
|
||||||
await sqsEnabled(async () => {
|
await sqsEnabled(envVar, async () => {
|
||||||
await processMigrations(config.appId!, MIGRATIONS)
|
await processMigrations(config.appId!, MIGRATIONS)
|
||||||
const designDoc = await db.get<SQLiteDefinition>(SQLITE_DESIGN_DOC_ID)
|
const designDoc = await db.get<SQLiteDefinition>(SQLITE_DESIGN_DOC_ID)
|
||||||
expect(designDoc.sql.tables).toBeDefined()
|
expect(designDoc.sql.tables).toBeDefined()
|
||||||
|
@ -126,4 +130,5 @@ describe("SQS migration", () => {
|
||||||
expect(linkDoc.doc2.rowId).toEqual(rowId1)
|
expect(linkDoc.doc2.rowId).toEqual(rowId1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
|
@ -92,6 +92,7 @@ const environment = {
|
||||||
SQL_LOGGING_ENABLE: process.env.SQL_LOGGING_ENABLE,
|
SQL_LOGGING_ENABLE: process.env.SQL_LOGGING_ENABLE,
|
||||||
SQL_ALIASING_DISABLE: process.env.SQL_ALIASING_DISABLE,
|
SQL_ALIASING_DISABLE: process.env.SQL_ALIASING_DISABLE,
|
||||||
SQS_SEARCH_ENABLE: process.env.SQS_SEARCH_ENABLE,
|
SQS_SEARCH_ENABLE: process.env.SQS_SEARCH_ENABLE,
|
||||||
|
SQS_MIGRATION_ENABLE: process.env.SQS_MIGRATION_ENABLE,
|
||||||
// flags
|
// flags
|
||||||
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
|
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
|
||||||
DISABLE_THREADING: process.env.DISABLE_THREADING,
|
DISABLE_THREADING: process.env.DISABLE_THREADING,
|
||||||
|
|
Loading…
Reference in New Issue