feat(mysql): add auto-increment counter action

Closes #3019
This commit is contained in:
t8y2 committed 2026-08-14 01:59:04 +00:00
1 parent 278429ab07
commit 4c6c3142c0
18 files changed
+456 -7

No files matched your search

+19 -1
View File
@@ -1,4 +1,4 @@
import type { ColumnInfo, DatabaseObjectType, DatabaseType, ForeignKeyInfo, IndexInfo, TriggerInfo } from "@/types/database";
import type { ColumnInfo, ConnectionConfig, DatabaseObjectType, DatabaseType, ForeignKeyInfo, IndexInfo, TriggerInfo } from "@/types/database";
import * as api from "@/lib/backend/api";
import { createColumnDrafts, createForeignKeyDrafts, createIndexDrafts, createTriggerDrafts } from "@/lib/table/tableStructureEditorState";
import type { BuildTableStructureChangeSqlOptions } from "@/lib/table/tableStructureEditorSql";
@@ -18,6 +18,14 @@ export interface TableAdminSqlOptions {
cascade?: boolean;
}
export interface MysqlAutoIncrementSqlOptions {
databaseType: DatabaseType;
driverProfile?: string | null;
schema?: string | null;
tableName: string;
value: string;
}
export type TableChildObjectType = "COLUMN" | "INDEX" | "FOREIGN_KEY" | "TRIGGER";
export interface DropTableChildObjectSqlOptions {
@@ -278,6 +286,16 @@ export function buildTruncateTableSql(options: TableAdminSqlOptions): Promise<st
return api.buildTruncateTableSql(options);
}
export function buildMysqlAutoIncrementSql(options: MysqlAutoIncrementSqlOptions): Promise<string> {
return api.buildMysqlAutoIncrementSql(options);
}
export function supportsNativeMysqlAutoIncrement(connection: Pick<ConnectionConfig, "db_type" | "driver_profile"> | undefined): boolean {
if (connection?.db_type !== "mysql") return false;
const profile = connection.driver_profile?.trim().toLowerCase();
return !profile || profile === "mysql";
}
const DROP_TABLE_CASCADE_DATABASE_TYPES: readonly DatabaseType[] = ["postgres", "redshift", "gaussdb", "kwdb", "kingbase", "highgo", "uxdb", "vastbase", "opengauss"];
const TRUNCATE_TABLE_CASCADE_DATABASE_TYPES: readonly DatabaseType[] = ["postgres", "gaussdb", "kwdb", "kingbase", "highgo", "uxdb", "vastbase", "opengauss"];