Name
Columns
Name
Type
{features?.primaryKeys ? 'Primary' : ''}
{#each values.columns as column, i}
column.name, (newName) => { const oldName = column.name column.name = newName // Update all foreign keys that reference this column if (oldName && oldName !== newName) { values.foreignKeys.forEach((fk) => { fk.columns.forEach((fkCol) => { if (fkCol.sourceColumn === oldName) { fkCol.sourceColumn = newName } }) }) } } } /> {#if column.initialName && column.name !== column.initialName}
Old name: {column.initialName}
{/if}
column.datatype, (v) => { column.datatype = v if (datatypeHasLength(column.datatype)) { column.datatype_length = datatypeDefaultLength(column.datatype) } else { column.datatype_length = undefined } } } items={safeSelectItems(columnTypes)} class="w-48" /> {#if column.initialName && column.name !== column.initialName}
{/if}
{#if features?.primaryKeys}
{/if}
{#snippet trigger()}
{/snippet} {#snippet content()} {#if datatypeHasLength(column.datatype)}
Length
{/if} {#if features?.defaultValues}
{/if} {#if !column.primaryKey}
Nullable
{/if} {/snippet}
values.columns.splice(i, 1)} />
{/each}
addColumn({ name: '' })} > Add
{#if features?.foreignKeys}
Foreign Keys
Table
Columns
{#each values.foreignKeys as foreignKey, foreignKeyIndex} {@const fkErrors = errors?.foreignKeys?.[foreignKeyIndex]}
({ value: o, label: !features?.schemas || (currentSchema && o.toLowerCase().startsWith(currentSchema.toLowerCase())) ? o.split('.')[1] : o }))} />
{#each foreignKey.columns as column, columnIndex}
c.name.length) .map((c) => ({ value: c.name }))} clearable={false} />
({ value }))} clearable={false} />
{#if columnIndex === 0}
{#snippet trigger()}
{/snippet} {#snippet content()}
No action
Cascade
Set null
No action
Cascade
Set null
{/snippet}
{/if}
1 ? () => foreignKey.columns.splice(columnIndex, 1) : () => values.foreignKeys.splice(foreignKeyIndex, 1)} />
{/each}
foreignKey.columns.push({})} >
Add
{/each}
values.foreignKeys.push({ columns: [{}], onDelete: 'NO ACTION', onUpdate: 'NO ACTION' })} > Add
{/if}
{ let preview = computePreview?.({ values }) askingForConfirmation = { onConfirm: async () => { try { askingForConfirmation && (askingForConfirmation.loading = true) await onConfirm({ values }) } catch (e) { let msg: string | undefined = (e as Error)?.message if (typeof msg !== 'string') msg = e ? JSON.stringify(e) : 'An error occurred' sendUserToast(msg, true) } askingForConfirmation = undefined }, title: 'Confirm running the following:', confirmationText: btnProps.current.text, open: true, ...(preview && { codeContent: preview.sql, alert: preview.alert }) } }} > {btnProps.current.text}
(askingForConfirmation = undefined)} on:confirmed={askingForConfirmation?.onConfirm ?? (() => {})} > {#if askingForConfirmation?.alert}
{askingForConfirmation.alert.body}
{/if} {#if askingForConfirmation?.codeContent}
{askingForConfirmation.codeContent}
copyToClipboard(askingForConfirmation?.codeContent)} size="xs" startIcon={{ icon: ClipboardCopy }} color="none" wrapperClasses="absolute z-10 top-0 right-0" >
{/if}