mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-30 16:21:39 +00:00
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
64 lines
1.4 KiB
TypeScript
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;
|
|
}
|