Merge pull request #13942 from Budibase/fix/migration-guide-link
Migration documentation + caching fix
This commit is contained in:
commit
bc949e2f54
|
@ -33,7 +33,8 @@
|
||||||
</Body>
|
</Body>
|
||||||
</Layout>
|
</Layout>
|
||||||
<Button
|
<Button
|
||||||
on:click={() => (window.location = "https://docs.budibase.com")}
|
on:click={() =>
|
||||||
|
(window.location = "https://docs.budibase.com/docs/migrations")}
|
||||||
>Migration guide</Button
|
>Migration guide</Button
|
||||||
>
|
>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -1,18 +1,22 @@
|
||||||
<script>
|
<script>
|
||||||
export let isMigrationDone
|
export let isMigrationDone
|
||||||
export let onMigrationDone
|
export let onMigrationDone
|
||||||
export let timeoutSeconds = 10 // 3 minutes
|
export let timeoutSeconds = 60 // 1 minute
|
||||||
|
export let minTimeSeconds = 3
|
||||||
|
|
||||||
const loadTime = Date.now()
|
const loadTime = Date.now()
|
||||||
|
const intervalMs = 1000
|
||||||
let timedOut = false
|
let timedOut = false
|
||||||
|
let secondsWaited = 0
|
||||||
|
|
||||||
async function checkMigrationsFinished() {
|
async function checkMigrationsFinished() {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
const isMigrated = await isMigrationDone()
|
const isMigrated = await isMigrationDone()
|
||||||
|
|
||||||
const timeoutMs = timeoutSeconds * 1000
|
const timeoutMs = timeoutSeconds * 1000
|
||||||
if (!isMigrated) {
|
if (!isMigrated || secondsWaited <= minTimeSeconds) {
|
||||||
if (loadTime + timeoutMs > Date.now()) {
|
if (loadTime + timeoutMs > Date.now()) {
|
||||||
|
secondsWaited += 1
|
||||||
return checkMigrationsFinished()
|
return checkMigrationsFinished()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +24,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
onMigrationDone()
|
onMigrationDone()
|
||||||
}, 1000)
|
}, intervalMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
checkMigrationsFinished()
|
checkMigrationsFinished()
|
||||||
|
@ -41,6 +45,11 @@
|
||||||
<span class="subtext">
|
<span class="subtext">
|
||||||
{#if !timedOut}
|
{#if !timedOut}
|
||||||
Please wait and we will be back in a second!
|
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}
|
{:else}
|
||||||
An error occurred, please try again later.
|
An error occurred, please try again later.
|
||||||
<br />
|
<br />
|
||||||
|
|
|
@ -23,16 +23,15 @@ const getCacheKey = (appId: string) => `appmigrations_${env.VERSION}_${appId}`
|
||||||
export async function getAppMigrationVersion(appId: string): Promise<string> {
|
export async function getAppMigrationVersion(appId: string): Promise<string> {
|
||||||
const cacheKey = getCacheKey(appId)
|
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
|
// returned cached version if we found one
|
||||||
if (metadata?.version) {
|
if (version) {
|
||||||
return metadata.version
|
return version
|
||||||
}
|
}
|
||||||
|
|
||||||
let version
|
|
||||||
try {
|
try {
|
||||||
metadata = await getFromDB(appId)
|
const metadata = await getFromDB(appId)
|
||||||
version = metadata.version || ""
|
version = metadata.version || ""
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
if (err.status !== 404) {
|
if (err.status !== 404) {
|
||||||
|
|
24
yarn.lock
24
yarn.lock
|
@ -3495,10 +3495,10 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
lodash "^4.17.21"
|
lodash "^4.17.21"
|
||||||
|
|
||||||
"@koa/cors@^3.1.0":
|
"@koa/cors@^5.0.0":
|
||||||
version "3.4.3"
|
version "5.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@koa/cors/-/cors-3.4.3.tgz#d669ee6e8d6e4f0ec4a7a7b0a17e7a3ed3752ebb"
|
resolved "https://registry.yarnpkg.com/@koa/cors/-/cors-5.0.0.tgz#0029b5f057fa0d0ae0e37dd2c89ece315a0daffd"
|
||||||
integrity sha512-WPXQUaAeAMVaLTEFpoq3T2O1C+FstkjJnDQqy95Ck1UdILajsRhu6mhJ8H2f4NFPRBoCNN+qywTJfq/gGki5mw==
|
integrity sha512-x/iUDjcS90W69PryLDIMgFyV21YLTnG9zOpPXS7Bkt2b8AsY3zZsIpOLBkYr9fBcF3HbkKaER5hOBZLfpLgYNw==
|
||||||
dependencies:
|
dependencies:
|
||||||
vary "^1.1.2"
|
vary "^1.1.2"
|
||||||
|
|
||||||
|
@ -5817,10 +5817,10 @@
|
||||||
"@types/koa-compose" "*"
|
"@types/koa-compose" "*"
|
||||||
"@types/node" "*"
|
"@types/node" "*"
|
||||||
|
|
||||||
"@types/koa__cors@^3.1.1":
|
"@types/koa__cors@^5.0.0":
|
||||||
version "3.3.1"
|
version "5.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/@types/koa__cors/-/koa__cors-3.3.1.tgz#0ec7543c4c620fd23451bfdd3e21b9a6aadedccd"
|
resolved "https://registry.yarnpkg.com/@types/koa__cors/-/koa__cors-5.0.0.tgz#74567a045b599266e2cd3940cef96cedecc2ef1f"
|
||||||
integrity sha512-aFGYhTFW7651KhmZZ05VG0QZJre7QxBxDj2LF1lf6GA/wSXEfKVAJxiQQWzRV4ZoMzQIO8vJBXKsUcRuvYK9qw==
|
integrity sha512-LCk/n25Obq5qlernGOK/2LUwa/2YJb2lxHUkkvYFDOpLXlVI6tKcdfCHRBQnOY4LwH6el5WOLs6PD/a8Uzau6g==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/koa" "*"
|
"@types/koa" "*"
|
||||||
|
|
||||||
|
@ -16343,10 +16343,10 @@ node-source-walk@^5.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/parser" "^7.0.0"
|
"@babel/parser" "^7.0.0"
|
||||||
|
|
||||||
nodemailer@6.7.2:
|
nodemailer@6.9.13:
|
||||||
version "6.7.2"
|
version "6.9.13"
|
||||||
resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.7.2.tgz#44b2ad5f7ed71b7067f7a21c4fedabaec62b85e0"
|
resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.9.13.tgz#5b292bf1e92645f4852ca872c56a6ba6c4a3d3d6"
|
||||||
integrity sha512-Dz7zVwlef4k5R71fdmxwR8Q39fiboGbu3xgswkzGwczUfjp873rVxt1O46+Fh0j1ORnAC6L9+heI8uUpO6DT7Q==
|
integrity sha512-7o38Yogx6krdoBf3jCAqnIN4oSQFx+fMa0I7dK1D+me9kBxx12D+/33wSb+fhOCtIxvYJ+4x4IMEhmhCKfAiOA==
|
||||||
|
|
||||||
nodemailer@6.9.9:
|
nodemailer@6.9.9:
|
||||||
version "6.9.9"
|
version "6.9.9"
|
||||||
|
|
Loading…
Reference in New Issue