Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

feat(editor): add extended column properties support for MySQL, PostgreSQL, and SQL Server

t8y2c7b7bed140f9
diff --git a/apps/desktop/src/components/structure/TableStructureEditor.vue b/apps/desktop/src/components/structure/TableStructureEditor.vue
index a94f1964f0..54d42d5b6e 100644
--- a/apps/desktop/src/components/structure/TableStructureEditor.vue
+++ b/apps/desktop/src/components/structure/TableStructureEditor.vue
@@ -147,17 +147,28 @@ const indexTypeOptions = computed(() =>
structureCapabilities.value.indexType ? (indexTypesByDb[databaseType.value ?? ""] ?? []) : [],
);
-const colLabels = computed(() => [
- "#",
- t("structureEditor.columnName"),
- t("structureEditor.dataType"),
- t("structureEditor.length"),
- t("structureEditor.nullable"),
- t("structureEditor.primaryKey"),
- t("structureEditor.defaultValue"),
- t("structureEditor.comment"),
- t("structureEditor.actions"),
-]);
+const showExtendedProperties = computed(() => {
+ const dt = databaseType.value;
+ return dt === "mysql" || dt === "postgres" || dt === "sqlserver";
+});
+
+const colLabels = computed(() => {
+ const labels = [
+ "#",
+ t("structureEditor.columnName"),
+ t("structureEditor.dataType"),
+ t("structureEditor.length"),
+ t("structureEditor.nullable"),
+ t("structureEditor.primaryKey"),
+ t("structureEditor.defaultValue"),
+ t("structureEditor.comment"),
+ ];
+ if (showExtendedProperties.value) {
+ labels.push(t("structureEditor.extendedProperties"));
+ }
+ labels.push(t("structureEditor.actions"));
+ return labels;
+});
const indexColLabels = computed(() => [
t("structureEditor.indexName"),
t("structureEditor.indexColumns"),
@@ -252,7 +263,7 @@ async function loadStructure(silent = false) {
api.listForeignKeys(props.connectionId, props.database, targetSchema.value, props.tableName).catch(() => []),
api.listTriggers(props.connectionId, props.database, targetSchema.value, props.tableName).catch(() => []),
]);
- columns.value = createColumnDrafts(nextColumns);
+ columns.value = createColumnDrafts(nextColumns, databaseType.value);
indexes.value = createIndexDrafts(nextIndexes);
foreignKeys.value = nextForeignKeys;
triggers.value = nextTriggers;
@@ -284,6 +295,7 @@ async function addColumn() {
defaultValue: "",
comment: "",
isPrimaryKey: false,
+ extra: {},
markedForDrop: false,
});
await nextTick();
@@ -693,6 +705,106 @@ watch(
</Popover>
</div>
</td>
+ <td v-if="showExtendedProperties" class="border-b border-r px-1.5 py-1">
+ <div class="flex items-center gap-2">
+ <!-- MySQL: AUTO_INCREMENT + ON UPDATE CURRENT_TIMESTAMP -->
+ <template v-if="databaseType === 'mysql'">
+ <label class="flex items-center gap-1 text-[11px] whitespace-nowrap">
+ <input v-model="column.extra.autoIncrement" type="checkbox" class="h-3.5 w-3.5" />
+ {{ t("structureEditor.autoIncrement") }}
+ </label>
+ <label class="flex items-center gap-1 text-[11px] whitespace-nowrap">
+ <input v-model="column.extra.onUpdateCurrentTimestamp" type="checkbox" class="h-3.5 w-3.5" />
+ {{ t("structureEditor.onUpdateCurrentTimestamp") }}
+ </label>
+ </template>
+ <!-- PostgreSQL: IDENTITY -->
+ <template v-else-if="databaseType === 'postgres'">
+ <select
+ :value="column.extra.identity?.generation ?? ''"
+ class="h-6 rounded border bg-background px-1 text-[11px]"
+ @change="
+ (e) => {
+ const v = (e.target as HTMLSelectElement).value;
+ if (v) {
+ column.extra.identity = {
+ ...column.extra.identity,
+ generation: v as 'BY DEFAULT' | 'ALWAYS',
+ };
+ } else {
+ column.extra.identity = undefined;
+ }
+ }
+ "
+ >
+ <option value="">{{ t("structureEditor.no") }}</option>
+ <option value="BY DEFAULT">BY DEFAULT</option>
+ <option value="ALWAYS">ALWAYS</option>
+ </select>
+ <template v-if="column.extra.identity?.generation">
+ <Input
+ :model-value="column.extra.identity.seed?.toString() ?? ''"
+ type="number"
+ class="h-6 w-14 text-[10px]"
+ :placeholder="t('structureEditor.identitySeed')"
+ @update:model-value="
+ (v) => {
+ if (column.extra.identity) {
+ column.extra.identity.seed = v ? Number(v) : undefined;
+ }
+ }
+ "
+ />
+ <Input
+ :model-value="column.extra.identity.increment?.toString() ?? ''"
+ type="number"
+ class="h-6 w-14 text-[10px]"
+ :placeholder="t('structureEditor.identityIncrement')"
+ @update:model-value="
+ (v) => {
+ if (column.extra.identity) {
+ column.extra.identity.increment = v ? Number(v) : undefined;
+ }
+ }
+ "
+ />
+ </template>
+ </template>
+ <!-- SQL Server: IDENTITY -->
+ <template v-else-if="databaseType === 'sqlserver'">
+ <label class="flex items-center gap-1 text-[11px] whitespace-nowrap">
+ <input v-model="column.extra.autoIncrement" type="checkbox" class="h-3.5 w-3.5" />
+ {{ t("structureEditor.identity") }}
+ </label>
+ <template v-if="column.extra.autoIncrement">
+ <Input
+ :model-value="column.extra.identity?.seed?.toString() ?? '1'"
+ type="number"
+ class="h-6 w-14 text-[10px]"
+ :placeholder="t('structureEditor.identitySeed')"
+ @update:model-value="
+ (v) => {
+ if (!column.extra.identity) column.extra.identity = {};
+ column.extra.identity.seed = v ? Number(v) : undefined;
+ }
+ "
+ />
+ <Input
+ :model-value="column.extra.identity?.increment?.toString() ?? '1'"
+ type="number"
+ class="h-6 w-14 text-[10px]"
+ :placeholder="t('structureEditor.identityIncrement')"
+ @update:model-value="
+ (v) => {
+ if (!column.extra.identity) column.extra.identity = {};
+ column.extra.identity.increment = v ? Number(v) : undefined;
+ }
+ "
+ />
+ </template>
+ </template>
+ </div>
+ </td>
<td class="border-b px-1.5 py-1">
<div class="flex items-center gap-1">
<Button
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index de14ab0ea7..7e73e930e2 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -1012,6 +1012,13 @@ export default {
apply: "Apply Changes",
ready: "Ready",
saved: "Table structure updated",
+ extendedProperties: "Extended",
+ autoIncrement: "Auto Increment",
+ onUpdateCurrentTimestamp: "Auto Update Time",
+ identity: "Identity",
+ identityGeneration: "Generation",
+ identitySeed: "Seed",
+ identityIncrement: "Increment",
},
diagram: {
title: "Relationship Diagram",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 255ce92b89..68e7e7336c 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -906,6 +906,13 @@ export default {
apply: "Aplicar cambios",
ready: "Listo",
saved: "Estructura de tabla actualizada",
+ extendedProperties: "Extendido",
+ autoIncrement: "Auto Incremento",
+ onUpdateCurrentTimestamp: "Actualización Auto",
+ identity: "Identidad",
+ identityGeneration: "Generación",
+ identitySeed: "Semilla",
+ identityIncrement: "Incremento",
},
diagram: {
title: "Diagrama de relaciones",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index 001b718144..077b48cc06 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -990,6 +990,13 @@ export default {
apply: "应用变更",
ready: "可执行",
saved: "表结构已更新",
+ extendedProperties: "扩展属性",
+ autoIncrement: "自增",
+ onUpdateCurrentTimestamp: "自动更新时间",
+ identity: "标识列",
+ identityGeneration: "生成方式",
+ identitySeed: "起始值",
+ identityIncrement: "增量",
},
diagram: {
title: "关系图",
diff --git a/apps/desktop/src/lib/tableStructureEditorSql.ts b/apps/desktop/src/lib/tableStructureEditorSql.ts
index eb6882dcbd..bbfb7f6d66 100644
--- a/apps/desktop/src/lib/tableStructureEditorSql.ts
+++ b/apps/desktop/src/lib/tableStructureEditorSql.ts
@@ -1,5 +1,17 @@
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;
@@ -8,6 +20,7 @@ export interface EditableStructureColumn {
defaultValue: string;
comment: string;
isPrimaryKey: boolean;
+ extra: ColumnExtra;
original?: ColumnInfo;
originalPosition?: number;
markedForDrop: boolean;
diff --git a/apps/desktop/src/lib/tableStructureEditorState.ts b/apps/desktop/src/lib/tableStructureEditorState.ts
index 010f7ada36..236dd7ec2c 100644
--- a/apps/desktop/src/lib/tableStructureEditorState.ts
+++ b/apps/desktop/src/lib/tableStructureEditorState.ts
@@ -1,5 +1,5 @@
import type { ColumnInfo, DatabaseType, IndexInfo } from "../types/database.ts";
-import type { EditableStructureColumn, EditableStructureIndex } from "./tableStructureEditorSql.ts";
+import type { ColumnExtra, EditableStructureColumn, EditableStructureIndex } from "./tableStructureEditorSql.ts";
export const DATA_TYPE_OPTIONS: Record<string, string[]> = {
mysql: [
@@ -260,7 +260,36 @@ export const DEFAULT_TYPE_LENGTHS: Record<string, string> = {
year: "4",
};
-export function createColumnDrafts(columns: ColumnInfo[]): EditableStructureColumn[] {
+export function parseExtraToColumnExtra(extra: string | null | undefined, databaseType?: DatabaseType): ColumnExtra {
+ const result: ColumnExtra = {};
+ if (!extra) return result;
+ const lower = extra.toLowerCase().trim();
+ if (!lower) return result;
+
+ if (databaseType === "mysql") {
+ if (lower.includes("auto_increment")) {
+ result.autoIncrement = true;
+ }
+ if (lower.includes("on update current_timestamp")) {
+ result.onUpdateCurrentTimestamp = true;
+ }
+ } else if (databaseType === "postgres") {
+ const identityMatch = lower.match(/generated\s+(by\s+default|always)\s+as\s+identity/i);
+ if (identityMatch) {
+ result.identity = {
+ generation: identityMatch[1].toUpperCase() === "BY DEFAULT" ? "BY DEFAULT" : "ALWAYS",
+ };
+ }
+ } else if (databaseType === "sqlserver") {
+ if (lower.includes("identity")) {
+ result.autoIncrement = true;
+ }
+ }
+
+ return result;
+}
+
+export function createColumnDrafts(columns: ColumnInfo[], databaseType?: DatabaseType): EditableStructureColumn[] {
return columns.map((column, index) => ({
id: `existing:${column.name}`,
name: column.name,
@@ -269,6 +298,7 @@ export function createColumnDrafts(columns: ColumnInfo[]): EditableStructureColu
defaultValue: column.column_default ?? "",
comment: column.comment ?? "",
isPrimaryKey: column.is_primary_key,
+ extra: parseExtraToColumnExtra(column.extra, databaseType),
original: column,
originalPosition: index,
markedForDrop: false,
diff --git a/crates/dbx-core/src/table_structure_sql.rs b/crates/dbx-core/src/table_structure_sql.rs
index 633fdba1f0..15786fc5fa 100644
--- a/crates/dbx-core/src/table_structure_sql.rs
+++ b/crates/dbx-core/src/table_structure_sql.rs
@@ -16,6 +16,8 @@ pub struct EditableStructureColumn {
#[serde(default)]
pub is_primary_key: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
+ pub extra: Option<ColumnExtra>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
pub original: Option<ColumnInfo>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub original_position: Option<usize>,
@@ -23,6 +25,28 @@ pub struct EditableStructureColumn {
pub marked_for_drop: bool,
}
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ColumnExtra {
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub auto_increment: Option<bool>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub on_update_current_timestamp: Option<bool>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub identity: Option<ColumnIdentity>,
+}
+
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ColumnIdentity {
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub generation: Option<String>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub seed: Option<i64>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub increment: Option<i64>,
+}
+
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ColumnInfo {
pub name: String,
@@ -365,10 +389,18 @@ pub fn build_create_table_sql(options: TableStructureSqlOptions) -> TableStructu
if !column.is_nullable && !column.is_primary_key && dialect != StructureDialect::ClickHouse {
parts.push("NOT NULL".to_string());
}
+ if let Some(extra_clause) = column_extra_clause(dialect, column) {
+ parts.push(extra_clause);
+ }
let default_value = normalize_default(Some(&column.default_value));
if !default_value.is_empty() {
parts.push(format!("DEFAULT {default_value}"));
}
+ if let Some(on_update) = column.extra.as_ref().and_then(|e| e.on_update_current_timestamp).filter(|v| *v) {
+ if on_update && dialect == StructureDialect::Mysql {
+ parts.push("ON UPDATE CURRENT_TIMESTAMP".to_string());
+ }
+ }
if dialect == StructureDialect::Mysql && capabilities.comment && !clean(&column.comment).is_empty() {
parts.push(format!("COMMENT {}", quote_string(&clean(&column.comment))));
}
@@ -1205,16 +1237,65 @@ fn column_definition(dialect: StructureDialect, column: &EditableStructureColumn
if !column.is_nullable && !is_oracle_like(dialect) && dialect != StructureDialect::ClickHouse {
parts.push("NOT NULL".to_string());
}
+ if let Some(extra_clause) = column_extra_clause(dialect, column) {
+ parts.push(extra_clause);
+ }
let default_value = normalize_default(Some(&column.default_value));
if !default_value.is_empty() {
parts.push(format!("DEFAULT {default_value}"));
}
+ if let Some(on_update) = column.extra.as_ref().and_then(|e| e.on_update_current_timestamp).filter(|v| *v) {
+ if on_update && dialect == StructureDialect::Mysql {
+ parts.push("ON UPDATE CURRENT_TIMESTAMP".to_string());
+ }
+ }
if dialect == StructureDialect::Mysql && !clean(&column.comment).is_empty() {
parts.push(format!("COMMENT {}", quote_string(&clean(&column.comment))));
}
parts.join(" ")
}
+fn column_extra_clause(dialect: StructureDialect, column: &EditableStructureColumn) -> Option<String> {
+ let extra = column.extra.as_ref()?;
+ match dialect {
+ StructureDialect::Mysql => {
+ let mut clauses = Vec::new();
+ if extra.auto_increment.unwrap_or(false) {
+ clauses.push("AUTO_INCREMENT".to_string());
+ }
+ if clauses.is_empty() {
+ None
+ } else {
+ Some(clauses.join(" "))
+ }
+ }
+ StructureDialect::Postgres | StructureDialect::H2 => {
+ if let Some(identity) = &extra.identity {
+ let generation = identity.generation.as_deref().unwrap_or("BY DEFAULT");
+ let mut clause = format!("GENERATED {generation} AS IDENTITY");
+ if identity.seed.is_some() || identity.increment.is_some() {
+ let start = identity.seed.unwrap_or(1);
+ let inc = identity.increment.unwrap_or(1);
+ clause.push_str(&format!(" (START WITH {start} INCREMENT BY {inc})"));
+ }
+ Some(clause)
+ } else {
+ None
+ }
+ }
+ StructureDialect::SqlServer => {
+ if extra.auto_increment.unwrap_or(false) || extra.identity.is_some() {
+ let seed = extra.identity.as_ref().and_then(|i| i.seed).unwrap_or(1);
+ let increment = extra.identity.as_ref().and_then(|i| i.increment).unwrap_or(1);
+ Some(format!("IDENTITY({seed}, {increment})"))
+ } else {
+ None
+ }
+ }
+ _ => None,
+ }
+}
+
fn column_data_type(dialect: StructureDialect, column: &EditableStructureColumn) -> String {
if dialect == StructureDialect::ClickHouse {
return clickhouse_column_type(column);
@@ -1577,6 +1658,7 @@ mod tests {
default_value: String::new(),
comment: String::new(),
is_primary_key: false,
+ extra: None,
original: None,
original_position: None,
marked_for_drop: false,
@@ -2138,4 +2220,115 @@ mod tests {
assert_eq!(result.warnings.len(), 1);
assert!(result.warnings[0].contains("primary key"));
}
+
+ #[test]
+ fn mysql_create_table_with_auto_increment() {
+ let mut col = column("id");
+ col.data_type = "int".to_string();
+ col.is_nullable = false;
+ col.is_primary_key = true;
+ col.extra = Some(ColumnExtra {
+ auto_increment: Some(true),
+ on_update_current_timestamp: None,
+ identity: None,
+ });
+
+ let result = build_create_table_sql(TableStructureSqlOptions {
+ database_type: Some(DatabaseType::Mysql),
+ schema: None,
+ table_name: "users".to_string(),
+ columns: vec![col],
+ indexes: Vec::new(),
+ table_comment: None,
+ original_table_comment: None,
+ });
+
+ assert_eq!(result.warnings, Vec::<String>::new());
+ assert_eq!(result.statements.len(), 1);
+ assert!(result.statements[0].contains("AUTO_INCREMENT"));
+ }
+
+ #[test]
+ fn mysql_create_table_with_on_update_current_timestamp() {
+ let mut col = column("updated_at");
+ col.data_type = "timestamp".to_string();
+ col.is_nullable = false;
+ col.default_value = "CURRENT_TIMESTAMP".to_string();
+ col.extra = Some(ColumnExtra {
+ auto_increment: None,
+ on_update_current_timestamp: Some(true),
+ identity: None,
+ });
+
+ let result = build_create_table_sql(TableStructureSqlOptions {
+ database_type: Some(DatabaseType::Mysql),
+ schema: None,
+ table_name: "users".to_string(),
+ columns: vec![col],
+ indexes: Vec::new(),
+ table_comment: None,
+ original_table_comment: None,
+ });
+
+ assert_eq!(result.warnings, Vec::<String>::new());
+ assert!(result.statements[0].contains("ON UPDATE CURRENT_TIMESTAMP"));
+ }
+
+ #[test]
+ fn postgres_create_table_with_identity() {
+ let mut col = column("id");
+ col.data_type = "integer".to_string();
+ col.is_nullable = false;
+ col.extra = Some(ColumnExtra {
+ auto_increment: None,
+ on_update_current_timestamp: None,
+ identity: Some(ColumnIdentity {
+ generation: Some("BY DEFAULT".to_string()),
+ seed: None,
+ increment: None,
+ }),
+ });
+
+ let result = build_create_table_sql(TableStructureSqlOptions {
+ database_type: Some(DatabaseType::Postgres),
+ schema: None,
+ table_name: "users".to_string(),
+ columns: vec![col],
+ indexes: Vec::new(),
+ table_comment: None,
+ original_table_comment: None,
+ });
+
+ assert_eq!(result.warnings, Vec::<String>::new());
+ assert!(result.statements[0].contains("GENERATED BY DEFAULT AS IDENTITY"));
+ }
+
+ #[test]
+ fn sqlserver_create_table_with_identity() {
+ let mut col = column("id");
+ col.data_type = "int".to_string();
+ col.is_nullable = false;
+ col.extra = Some(ColumnExtra {
+ auto_increment: Some(true),
+ on_update_current_timestamp: None,
+ identity: Some(ColumnIdentity {
+ generation: None,
+ seed: Some(100),
+ increment: Some(5),
+ }),
+ });
+
+ let result = build_create_table_sql(TableStructureSqlOptions {
+ database_type: Some(DatabaseType::SqlServer),
+ schema: None,
+ table_name: "users".to_string(),
+ columns: vec![col],
+ indexes: Vec::new(),
+ table_comment: None,
+ original_table_comment: None,
+ });
+
+ assert_eq!(result.warnings, Vec::<String>::new());
+ assert!(result.statements[0].contains("IDENTITY(100, 5)"));
+ }
}
diff --git a/packages/app-tests/tableStructureEditorState.test.ts b/packages/app-tests/tableStructureEditorState.test.ts
index 9d38933e2a..8a45b1009b 100644
--- a/packages/app-tests/tableStructureEditorState.test.ts
+++ b/packages/app-tests/tableStructureEditorState.test.ts
@@ -6,6 +6,7 @@ import {
createColumnDrafts,
createIndexDrafts,
normalizeDataTypeParams,
+ parseExtraToColumnExtra,
toColumnNames,
} from "../../apps/desktop/src/lib/tableStructureEditorState.ts";
import type { ColumnInfo, IndexInfo } from "../../apps/desktop/src/types/database.ts";
@@ -37,7 +38,7 @@ const indexes: IndexInfo[] = [
];
test("creates editable column drafts from column metadata", () => {
- const drafts = createColumnDrafts(columns);
+ const drafts = createColumnDrafts(columns, "mysql");
assert.deepEqual(
drafts.map((draft) => ({
@@ -48,6 +49,7 @@ test("creates editable column drafts from column metadata", () => {
defaultValue: draft.defaultValue,
comment: draft.comment,
isPrimaryKey: draft.isPrimaryKey,
+ extra: draft.extra,
originalPosition: draft.originalPosition,
markedForDrop: draft.markedForDrop,
originalName: draft.original?.name,
@@ -61,6 +63,7 @@ test("creates editable column drafts from column metadata", () => {
defaultValue: "",
comment: "identifier",
isPrimaryKey: true,
+ extra: { autoIncrement: true },
originalPosition: 0,
markedForDrop: false,
originalName: "id",
@@ -73,6 +76,7 @@ test("creates editable column drafts from column metadata", () => {
defaultValue: "'guest'",
comment: "",
isPrimaryKey: false,
+ extra: {},
originalPosition: 1,
markedForDrop: false,
originalName: "name",
@@ -81,6 +85,28 @@ test("creates editable column drafts from column metadata", () => {
);
});
+test("parses MySQL extra string to ColumnExtra", () => {
+ assert.deepEqual(parseExtraToColumnExtra("auto_increment", "mysql"), { autoIncrement: true });
+ assert.deepEqual(parseExtraToColumnExtra("on update CURRENT_TIMESTAMP", "mysql"), {
+ onUpdateCurrentTimestamp: true,
+ });
+ assert.deepEqual(parseExtraToColumnExtra("auto_increment on update current_timestamp", "mysql"), {
+ autoIncrement: true,
+ onUpdateCurrentTimestamp: true,
+ });
+ assert.deepEqual(parseExtraToColumnExtra(null, "mysql"), {});
+ assert.deepEqual(parseExtraToColumnExtra("", "mysql"), {});
+});
+
+test("parses PostgreSQL extra string to ColumnExtra", () => {
+ assert.deepEqual(parseExtraToColumnExtra("generated by default as identity", "postgres"), {
+ identity: { generation: "BY DEFAULT" },
+ });
+ assert.deepEqual(parseExtraToColumnExtra("GENERATED ALWAYS AS IDENTITY", "postgres"), {
+ identity: { generation: "ALWAYS" },
+ });
+});
+
test("creates editable index drafts and splits pasted column lists", () => {
const drafts = createIndexDrafts(indexes);