mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-12 08:05:44 +00:00
refresh db manager schema on migrations
This commit is contained in:
@@ -106,6 +106,11 @@
|
||||
return toSourceIdentifier(input.resourcePath)
|
||||
}
|
||||
|
||||
function refreshManager() {
|
||||
dbManagerContent?.refresh()
|
||||
dbManagerContent?.dbManager()?.dbTable()?.refresh()
|
||||
}
|
||||
|
||||
async function handleExportSchema() {
|
||||
const source = currentSourceIdentifier()
|
||||
if (!source || !$workspaceStore) return
|
||||
@@ -206,6 +211,7 @@
|
||||
<DataTableMigrationsButton
|
||||
workspace={$workspaceStore}
|
||||
datatable={uriState.selectedDatatable}
|
||||
onSchemaChanged={refreshManager}
|
||||
/>
|
||||
{/if}
|
||||
{#if enableImportExport}
|
||||
@@ -216,10 +222,7 @@
|
||||
{/if}
|
||||
<Button
|
||||
loading={dbManagerContent?.isLoading() ?? false}
|
||||
on:click={() => {
|
||||
dbManagerContent?.refresh()
|
||||
dbManagerContent?.dbManager()?.dbTable()?.refresh()
|
||||
}}
|
||||
on:click={refreshManager}
|
||||
startIcon={{ icon: RefreshCcw }}
|
||||
iconOnly
|
||||
title="Refresh"
|
||||
|
||||
@@ -30,8 +30,16 @@
|
||||
let {
|
||||
workspace,
|
||||
datatable,
|
||||
disabled = false
|
||||
}: { workspace: string; datatable: string; disabled?: boolean } = $props()
|
||||
disabled = false,
|
||||
onSchemaChanged
|
||||
}: {
|
||||
workspace: string
|
||||
datatable: string
|
||||
disabled?: boolean
|
||||
/** Called after a migration run/revert actually changes the data table
|
||||
* schema, so an open viewer (e.g. the database manager) can refresh. */
|
||||
onSchemaChanged?: () => void
|
||||
} = $props()
|
||||
|
||||
let listOpen = $state(false)
|
||||
let migrations = $state<DatatableMigrationWithStatus[]>([])
|
||||
@@ -102,6 +110,7 @@
|
||||
: 'No pending migrations to run'
|
||||
)
|
||||
await loadMigrations()
|
||||
if (res.applied.length > 0) onSchemaChanged?.()
|
||||
} catch (e: any) {
|
||||
sendUserToast(`Failed to run migrations: ${e?.body ?? e?.message ?? e}`, true)
|
||||
} finally {
|
||||
@@ -121,6 +130,7 @@
|
||||
res.applied.length > 0 ? `Applied ${res.applied[0].name}` : 'Migration already applied'
|
||||
)
|
||||
await loadMigrations()
|
||||
if (res.applied.length > 0) onSchemaChanged?.()
|
||||
} catch (e: any) {
|
||||
sendUserToast(`Failed to run migration: ${e?.body ?? e?.message ?? e}`, true)
|
||||
} finally {
|
||||
@@ -159,6 +169,7 @@
|
||||
: 'Migration was not applied'
|
||||
)
|
||||
await loadMigrations()
|
||||
if (res.rolled_back.length > 0) onSchemaChanged?.()
|
||||
} catch (e: any) {
|
||||
sendUserToast(`Failed to revert migration: ${e?.body ?? e?.message ?? e}`, true)
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user