Files
dbx/apps/desktop/src/lib/tableStructureEditorSql.ts
T
t8y2 6c0db6f517 feat: add "Copy as SQL ALTER" to DataGrid column header context menu
Right-click a column header in the data grid to copy the ALTER TABLE
statement for that column, making it easy to replicate column definitions
across databases. Supports all major dialects (MySQL, Postgres, SQL Server,
Oracle, ClickHouse, SQLite, DuckDB, H2).

Closes #516
2026-05-29 15:09:10 +08:00

64 lines
1.4 KiB
TypeScript

import type { ColumnInfo, DatabaseType, IndexInfo } from "../types/database.ts";
export interface ColumnIdentity {
generation?: "BY DEFAULT" | "ALWAYS";
seed?: number;
increment?: number;
}
export interface ColumnExtra {
autoIncrement?: boolean;
onUpdateCurrentTimestamp?: boolean;
identity?: ColumnIdentity;
}
export interface EditableStructureColumn {
id: string;
name: string;
dataType: string;
isNullable: boolean;
defaultValue: string;
comment: string;
isPrimaryKey: boolean;
extra: ColumnExtra;
original?: ColumnInfo;
originalPosition?: number;
markedForDrop: boolean;
}
export interface EditableStructureIndex {
id: string;
name: string;
columns: string[];
isUnique: boolean;
isPrimary: boolean;
filter: string;
indexType: string;
includedColumns: string[];
comment: string;
original?: IndexInfo;
markedForDrop: boolean;
}
export interface BuildTableStructureChangeSqlOptions {
databaseType?: DatabaseType;
schema?: string;
tableName: string;
columns: EditableStructureColumn[];
indexes: EditableStructureIndex[];
tableComment?: string;
originalTableComment?: string;
}
export interface TableStructureChangeSql {
statements: string[];
warnings: string[];
}
export interface BuildSingleColumnAlterSqlOptions {
databaseType?: DatabaseType;
schema?: string;
tableName: string;
column: EditableStructureColumn;
}