Merge branch 'master' into budi-8349-in-memory-search-parity-testing

This commit is contained in:
Sam Rose 2024-06-14 11:17:38 +01:00 committed by GitHub
commit 909cf3f4f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 9 deletions

View File

@ -33,7 +33,8 @@
</Body>
</Layout>
<Button
on:click={() => (window.location = "https://docs.budibase.com")}
on:click={() =>
(window.location = "https://docs.budibase.com/docs/migrations")}
>Migration guide</Button
>
{/if}

View File

@ -1,18 +1,22 @@
<script>
export let isMigrationDone
export let onMigrationDone
export let timeoutSeconds = 10 // 3 minutes
export let timeoutSeconds = 60 // 1 minute
export let minTimeSeconds = 3
const loadTime = Date.now()
const intervalMs = 1000
let timedOut = false
let secondsWaited = 0
async function checkMigrationsFinished() {
setTimeout(async () => {
const isMigrated = await isMigrationDone()
const timeoutMs = timeoutSeconds * 1000
if (!isMigrated) {
if (!isMigrated || secondsWaited <= minTimeSeconds) {
if (loadTime + timeoutMs > Date.now()) {
secondsWaited += 1
return checkMigrationsFinished()
}
@ -20,7 +24,7 @@
}
onMigrationDone()
}, 1000)
}, intervalMs)
}
checkMigrationsFinished()
@ -41,6 +45,11 @@
<span class="subtext">
{#if !timedOut}
Please wait and we will be back in a second!
<br />
Checkout the
<a href="https://docs.budibase.com/docs/app-migrations" target="_blank"
>documentation</a
> on app migrations.
{:else}
An error occurred, please try again later.
<br />

View File

@ -23,16 +23,15 @@ const getCacheKey = (appId: string) => `appmigrations_${env.VERSION}_${appId}`
export async function getAppMigrationVersion(appId: string): Promise<string> {
const cacheKey = getCacheKey(appId)
let metadata: AppMigrationDoc | undefined = await cache.get(cacheKey)
let version: string | undefined = await cache.get(cacheKey)
// returned cached version if we found one
if (metadata?.version) {
return metadata.version
if (version) {
return version
}
let version
try {
metadata = await getFromDB(appId)
const metadata = await getFromDB(appId)
version = metadata.version || ""
} catch (err: any) {
if (err.status !== 404) {