Merge branch 'master' into cheeks-fixes
This commit is contained in:
commit
69be1c93b7
|
@ -179,6 +179,13 @@ jobs:
|
|||
- run: yarn --frozen-lockfile
|
||||
|
||||
- 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: |
|
||||
if ${{ env.USE_NX_AFFECTED }}; then
|
||||
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 { basicTable } from "../../../tests/utilities/structures"
|
||||
import {
|
||||
db as dbCore,
|
||||
SQLITE_DESIGN_DOC_ID,
|
||||
context,
|
||||
} from "@budibase/backend-core"
|
||||
import { db as dbCore, SQLITE_DESIGN_DOC_ID } from "@budibase/backend-core"
|
||||
import {
|
||||
LinkDocument,
|
||||
DocumentType,
|
||||
|
@ -16,7 +12,17 @@ import {
|
|||
generateLinkID,
|
||||
generateRowID,
|
||||
} from "../../../db/utils"
|
||||
import { processMigrations } from "../../migrationsProcessor"
|
||||
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()
|
||||
let tableId: string
|
||||
|
@ -91,9 +97,7 @@ describe("SQS migration", () => {
|
|||
expect(error.status).toBe(404)
|
||||
})
|
||||
await sqsEnabled(async () => {
|
||||
await context.doInAppContext(config.appId!, async () => {
|
||||
await migration()
|
||||
})
|
||||
await processMigrations(config.appId!, MIGRATIONS)
|
||||
const designDoc = await db.get<SQLiteDefinition>(SQLITE_DESIGN_DOC_ID)
|
||||
expect(designDoc.sql.tables).toBeDefined()
|
||||
const mainTableDef = designDoc.sql.tables[tableId]
|
||||
|
|
|
@ -12,17 +12,19 @@ export async function processMigrations(
|
|||
migrations: AppMigration[]
|
||||
) {
|
||||
console.log(`Processing app migration for "${appId}"`)
|
||||
// have to wrap in context, this gets the tenant from the app ID
|
||||
await context.doInAppContext(appId, async () => {
|
||||
await locks.doWithLock(
|
||||
{
|
||||
name: LockName.APP_MIGRATION,
|
||||
type: LockType.AUTO_EXTEND,
|
||||
resource: appId,
|
||||
},
|
||||
async () => {
|
||||
try {
|
||||
try {
|
||||
// have to wrap in context, this gets the tenant from the app ID
|
||||
await context.doInAppContext(appId, async () => {
|
||||
console.log(`Acquiring app migration lock for "${appId}"`)
|
||||
await locks.doWithLock(
|
||||
{
|
||||
name: LockName.APP_MIGRATION,
|
||||
type: LockType.AUTO_EXTEND,
|
||||
resource: appId,
|
||||
},
|
||||
async () => {
|
||||
await context.doInAppMigrationContext(appId, async () => {
|
||||
console.log(`Lock acquired starting app migration for "${appId}"`)
|
||||
let currentVersion = await getAppMigrationVersion(appId)
|
||||
|
||||
const pendingMigrations = migrations
|
||||
|
@ -30,6 +32,9 @@ export async function processMigrations(
|
|||
.sort((a, b) => a.id.localeCompare(b.id))
|
||||
|
||||
const migrationIds = migrations.map(m => m.id).sort()
|
||||
console.log(
|
||||
`App migrations to run for "${appId}" - ${migrationIds.join(",")}`
|
||||
)
|
||||
|
||||
let index = 0
|
||||
for (const { id, func } of pendingMigrations) {
|
||||
|
@ -55,13 +60,13 @@ export async function processMigrations(
|
|||
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 "./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 { 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) {
|
||||
const status = await accounts.getStatus()
|
||||
ctx.body = status
|
||||
} else {
|
||||
ctx.body = {
|
||||
status = await accounts.getStatus()
|
||||
}
|
||||
|
||||
if (!status) {
|
||||
status = {
|
||||
health: {
|
||||
passing: true,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if (coreEnv.VERSION) {
|
||||
status.version = coreEnv.VERSION
|
||||
}
|
||||
|
||||
ctx.body = status
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ describe("/api/system/status", () => {
|
|||
health: {
|
||||
passing: true,
|
||||
},
|
||||
version: expect.any(String),
|
||||
})
|
||||
expect(accounts.getStatus).toHaveBeenCalledTimes(0)
|
||||
config.cloudHosted()
|
||||
|
|
Loading…
Reference in New Issue