{#if tableInfo && (tableFormOptions || isCreateTable)}
{#key resetCounter}
= 0 ? schemaList : null}
values={_.pick(tableInfo, ['schemaName', 'pureName', ...(tableFormOptions ?? []).map(x => x.name)])}
onChangeValues={vals => {
if (!_.isEmpty(vals) && setTableInfo) {
setTableInfo(tbl => ({ ...tbl, ...vals }));
}
}}
/>
{/key}
{/if}
({ ...x, ordinal: index + 1 }))}
title={`Columns (${columns?.length || 0})`}
emptyMessage="No columns defined"
clickable
on:clickrow={e => showModal(ColumnEditorModal, { columnInfo: e.detail, tableInfo, setTableInfo, driver })}
onAddNew={isWritable ? addColumn : null}
displayNameFieldName="columnName"
columns={[
!driver?.dialect?.specificNullabilityImplementation && {
fieldName: 'notNull',
header: 'Nullability',
sortable: true,
slot: 0,
},
{
fieldName: 'dataType',
header: 'Data Type',
sortable: true,
filterable: true,
},
{
fieldName: 'defaultValue',
header: 'Default value',
sortable: true,
filterable: true,
},
driver?.dialect?.columnProperties?.isSparse && {
fieldName: 'isSparse',
header: 'Is Sparse',
sortable: true,
slot: 1,
},
{
fieldName: 'computedExpression',
header: 'Computed Expression',
sortable: true,
filterable: true,
},
driver?.dialect?.columnProperties?.isPersisted && {
fieldName: 'isPersisted',
header: 'Is Persisted',
sortable: true,
slot: 2,
},
driver?.dialect?.columnProperties?.isUnsigned && {
fieldName: 'isUnsigned',
header: 'Unsigned',
sortable: true,
slot: 4,
},
driver?.dialect?.columnProperties?.isZerofill && {
fieldName: 'isZerofill',
header: 'Zero fill',
sortable: true,
slot: 5,
},
driver?.dialect?.columnProperties?.columnComment && {
fieldName: 'columnComment',
header: 'Comment',
sortable: true,
filterable: true,
},
isWritable
? {
fieldName: 'actions',
filterable: false,
slot: 3,
}
: null,
]}
>
{row?.notNull ? 'NOT NULL' : 'NULL'}
{row?.isSparse ? 'YES' : 'NO'}
{row?.isPersisted ? 'YES' : 'NO'}
{
e.stopPropagation();
setTableInfo(tbl => editorDeleteColumn(tbl, row));
}}>Remove
{row?.isUnsigned ? 'YES' : 'NO'}
{row?.isZerofill ? 'YES' : 'NO'}
{#if driver?.dialect?.sortingKeys}
{/if}
{#if !driver?.dialect?.omitIndexes}
0 ? addIndex : null}
title={`Indexes (${indexes?.length || 0})`}
emptyMessage={isWritable ? 'No index defined' : null}
clickable
on:clickrow={e => showModal(IndexEditorModal, { constraintInfo: e.detail, tableInfo, setTableInfo, driver })}
columns={[
{
fieldName: 'columns',
header: 'Columns',
slot: 0,
sortable: true,
},
{
fieldName: 'unique',
header: 'Unique',
slot: 1,
sortable: true,
},
isWritable
? {
fieldName: 'actions',
slot: 2,
}
: null,
]}
>
{row?.columns.map(x => x.columnName).join(', ')}
{row?.isUnique ? 'YES' : 'NO'}
{
e.stopPropagation();
setTableInfo(tbl => editorDeleteConstraint(tbl, row));
}}>Remove
{/if}
{#if !driver?.dialect?.omitUniqueConstraints}
0 ? addUnique : null}
title={`Unique constraints (${uniques?.length || 0})`}
emptyMessage={isWritable ? 'No unique defined' : null}
clickable
on:clickrow={e => showModal(UniqueEditorModal, { constraintInfo: e.detail, tableInfo, setTableInfo })}
columns={[
{
fieldName: 'columns',
header: 'Columns',
slot: 0,
sortable: true,
},
isWritable
? {
fieldName: 'actions',
sortable: true,
slot: 1,
}
: null,
]}
>
{row?.columns.map(x => x.columnName).join(', ')}
{
e.stopPropagation();
setTableInfo(tbl => editorDeleteConstraint(tbl, row));
}}>Remove
{/if}
{#if !driver?.dialect?.omitForeignKeys}
0 ? addForeignKey : null}
title={`Foreign keys (${foreignKeys?.length || 0})`}
emptyMessage={isWritable ? 'No foreign key defined' : null}
clickable
onRemove={row => setTableInfo(tbl => editorDeleteConstraint(tbl, row))}
on:clickrow={e => showModal(ForeignKeyEditorModal, { constraintInfo: e.detail, tableInfo, setTableInfo, dbInfo })}
/>
{/if}