Merge branch 'master' into cheeks-fixes
This commit is contained in:
commit
69be1c93b7
|
@ -179,6 +179,13 @@ jobs:
|
||||||
- run: yarn --frozen-lockfile
|
- run: yarn --frozen-lockfile
|
||||||
|
|
||||||
- name: Test server
|
- name: Test server
|
||||||
|
env:
|
||||||
|
DD_CIVISIBILITY_AGENTLESS_ENABLED: true
|
||||||
|
DD_API_KEY: "${{ secrets.DATADOG_API_KEY }}"
|
||||||
|
DD_SITE: "datadoghq.eu"
|
||||||
|
NODE_OPTIONS: "-r dd-trace/ci/init"
|
||||||
|
DD_ENV: "ci"
|
||||||
|
DD_SERVICE: "budibase/packages/server"
|
||||||
run: |
|
run: |
|
||||||
if ${{ env.USE_NX_AFFECTED }}; then
|
if ${{ env.USE_NX_AFFECTED }}; then
|
||||||
yarn test --scope=@budibase/server --since=${{ env.NX_BASE_BRANCH }}
|
yarn test --scope=@budibase/server --since=${{ env.NX_BASE_BRANCH }}
|
||||||
|
|
|
@ -1683,3 +1683,5 @@ describe.each([
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// todo: remove me
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
import * as setup from "../../../api/routes/tests/utilities"
|
import * as setup from "../../../api/routes/tests/utilities"
|
||||||
import { basicTable } from "../../../tests/utilities/structures"
|
import { basicTable } from "../../../tests/utilities/structures"
|
||||||
import {
|
import { db as dbCore, SQLITE_DESIGN_DOC_ID } from "@budibase/backend-core"
|
||||||
db as dbCore,
|
|
||||||
SQLITE_DESIGN_DOC_ID,
|
|
||||||
context,
|
|
||||||
} from "@budibase/backend-core"
|
|
||||||
import {
|
import {
|
||||||
LinkDocument,
|
LinkDocument,
|
||||||
DocumentType,
|
DocumentType,
|
||||||
|
@ -16,7 +12,17 @@ import {
|
||||||
generateLinkID,
|
generateLinkID,
|
||||||
generateRowID,
|
generateRowID,
|
||||||
} from "../../../db/utils"
|
} from "../../../db/utils"
|
||||||
|
import { processMigrations } from "../../migrationsProcessor"
|
||||||
import migration from "../20240604153647_initial_sqs"
|
import migration from "../20240604153647_initial_sqs"
|
||||||
|
import { AppMigration } from "src/appMigrations"
|
||||||
|
|
||||||
|
const MIGRATIONS: AppMigration[] = [
|
||||||
|
{
|
||||||
|
id: "20240604153647_initial_sqs",
|
||||||
|
func: migration,
|
||||||
|
disabled: false,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
const config = setup.getConfig()
|
const config = setup.getConfig()
|
||||||
let tableId: string
|
let tableId: string
|
||||||
|
@ -91,9 +97,7 @@ describe("SQS migration", () => {
|
||||||
expect(error.status).toBe(404)
|
expect(error.status).toBe(404)
|
||||||
})
|
})
|
||||||
await sqsEnabled(async () => {
|
await sqsEnabled(async () => {
|
||||||
await context.doInAppContext(config.appId!, async () => {
|
await processMigrations(config.appId!, MIGRATIONS)
|
||||||
await migration()
|
|
||||||
})
|
|
||||||
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()
|
||||||
const mainTableDef = designDoc.sql.tables[tableId]
|
const mainTableDef = designDoc.sql.tables[tableId]
|
||||||
|
|
|
@ -12,8 +12,10 @@ export async function processMigrations(
|
||||||
migrations: AppMigration[]
|
migrations: AppMigration[]
|
||||||
) {
|
) {
|
||||||
console.log(`Processing app migration for "${appId}"`)
|
console.log(`Processing app migration for "${appId}"`)
|
||||||
|
try {
|
||||||
// have to wrap in context, this gets the tenant from the app ID
|
// have to wrap in context, this gets the tenant from the app ID
|
||||||
await context.doInAppContext(appId, async () => {
|
await context.doInAppContext(appId, async () => {
|
||||||
|
console.log(`Acquiring app migration lock for "${appId}"`)
|
||||||
await locks.doWithLock(
|
await locks.doWithLock(
|
||||||
{
|
{
|
||||||
name: LockName.APP_MIGRATION,
|
name: LockName.APP_MIGRATION,
|
||||||
|
@ -21,8 +23,8 @@ export async function processMigrations(
|
||||||
resource: appId,
|
resource: appId,
|
||||||
},
|
},
|
||||||
async () => {
|
async () => {
|
||||||
try {
|
|
||||||
await context.doInAppMigrationContext(appId, async () => {
|
await context.doInAppMigrationContext(appId, async () => {
|
||||||
|
console.log(`Lock acquired starting app migration for "${appId}"`)
|
||||||
let currentVersion = await getAppMigrationVersion(appId)
|
let currentVersion = await getAppMigrationVersion(appId)
|
||||||
|
|
||||||
const pendingMigrations = migrations
|
const pendingMigrations = migrations
|
||||||
|
@ -30,6 +32,9 @@ export async function processMigrations(
|
||||||
.sort((a, b) => a.id.localeCompare(b.id))
|
.sort((a, b) => a.id.localeCompare(b.id))
|
||||||
|
|
||||||
const migrationIds = migrations.map(m => m.id).sort()
|
const migrationIds = migrations.map(m => m.id).sort()
|
||||||
|
console.log(
|
||||||
|
`App migrations to run for "${appId}" - ${migrationIds.join(",")}`
|
||||||
|
)
|
||||||
|
|
||||||
let index = 0
|
let index = 0
|
||||||
for (const { id, func } of pendingMigrations) {
|
for (const { id, func } of pendingMigrations) {
|
||||||
|
@ -55,13 +60,13 @@ export async function processMigrations(
|
||||||
currentVersion = id
|
currentVersion = id
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (err) {
|
|
||||||
logging.logAlert("Failed to run app migration", err)
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
console.log(`App migration for "${appId}" processed`)
|
console.log(`App migration for "${appId}" processed`)
|
||||||
})
|
})
|
||||||
|
} catch (err) {
|
||||||
|
logging.logAlert("Failed to run app migration", err)
|
||||||
|
throw err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
export * from "./environment"
|
export * from "./environment"
|
||||||
|
export * from "./status"
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
export type SystemStatusResponse = {
|
||||||
|
passing?: boolean
|
||||||
|
checks?: {
|
||||||
|
login: boolean
|
||||||
|
search: boolean
|
||||||
|
}
|
||||||
|
health?: {
|
||||||
|
passing: boolean
|
||||||
|
}
|
||||||
|
version?: string
|
||||||
|
}
|
|
@ -1,16 +1,24 @@
|
||||||
import { accounts } from "@budibase/backend-core"
|
import { accounts, env as coreEnv } from "@budibase/backend-core"
|
||||||
|
import { Ctx, SystemStatusResponse } from "@budibase/types"
|
||||||
import env from "../../../environment"
|
import env from "../../../environment"
|
||||||
import { BBContext } from "@budibase/types"
|
|
||||||
|
|
||||||
export const fetch = async (ctx: BBContext) => {
|
export const fetch = async (ctx: Ctx<void, SystemStatusResponse>) => {
|
||||||
|
let status: SystemStatusResponse | undefined
|
||||||
if (!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL) {
|
if (!env.SELF_HOSTED && !env.DISABLE_ACCOUNT_PORTAL) {
|
||||||
const status = await accounts.getStatus()
|
status = await accounts.getStatus()
|
||||||
ctx.body = status
|
}
|
||||||
} else {
|
|
||||||
ctx.body = {
|
if (!status) {
|
||||||
|
status = {
|
||||||
health: {
|
health: {
|
||||||
passing: true,
|
passing: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (coreEnv.VERSION) {
|
||||||
|
status.version = coreEnv.VERSION
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.body = status
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ describe("/api/system/status", () => {
|
||||||
health: {
|
health: {
|
||||||
passing: true,
|
passing: true,
|
||||||
},
|
},
|
||||||
|
version: expect.any(String),
|
||||||
})
|
})
|
||||||
expect(accounts.getStatus).toHaveBeenCalledTimes(0)
|
expect(accounts.getStatus).toHaveBeenCalledTimes(0)
|
||||||
config.cloudHosted()
|
config.cloudHosted()
|
||||||
|
|
Loading…
Reference in New Issue