Skip to content

feat: ALTER TABLE DDL generation for all database plugins#804

Merged
datlechin merged 3 commits intomainfrom
feat/alter-table-ddl
Apr 20, 2026
Merged

feat: ALTER TABLE DDL generation for all database plugins#804
datlechin merged 3 commits intomainfrom
feat/alter-table-ddl

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

  • Implement ALTER TABLE DDL generation (add/modify/drop columns, indexes, foreign keys, primary keys) across 8 database plugins: MySQL, PostgreSQL, SQLite, ClickHouse, MSSQL, DuckDB, Cassandra, Oracle
  • Add granular schema editing capability flags (supportsAddColumn, supportsModifyColumn, supportsDropColumn, supportsRenameColumn, supportsAddIndex, supportsDropIndex, supportsModifyPrimaryKey) to DriverPlugin protocol
  • Gate add/delete operations in Structure tab UI per database type capabilities
  • Fix pre-existing supportsDropDatabase sync gap between Plugins and Packages copies of DriverPlugin.swift

Closes #803

Details

MySQL: CHANGE COLUMN (rename) / MODIFY COLUMN (same name), full column definition rebuild reusing buildColumnDefinitionSQL

PostgreSQL: Multi-statement modify — diffs old vs new column, emits only changed properties (RENAME COLUMN, ALTER COLUMN TYPE, SET/DROP NOT NULL, SET/DROP DEFAULT, COMMENT ON COLUMN)

SQLite: Limited to natively supported operations — ADD COLUMN, RENAME COLUMN, DROP COLUMN, CREATE/DROP INDEX. Modify column type/nullable/default returns nil (no table rebuild).

ClickHouse: ADD/MODIFY/DROP COLUMN with Nullable() wrapping, data-skipping index support. No FK/PK (immutable ORDER BY).

MSSQL: Complex modify — rename via sp_rename first, dynamic SQL to discover and drop default constraints, then ALTER COLUMN, then add new default constraint.

DuckDB: PostgreSQL-compatible syntax, full support.

Cassandra/ScyllaDB: ADD/DROP column only (CQL limitations).

Oracle: Full support with Oracle-specific syntax (ADD (col TYPE), MODIFY (col TYPE), RENAME COLUMN).

Test plan

  • MySQL: add column, modify column (type + rename), drop column, add/drop index, add/drop FK, modify PK
  • PostgreSQL: same matrix, verify schema-qualified names, verify multi-statement modify generates correct SQL in preview
  • SQLite: add column, rename column, drop column, add/drop index. Verify modify type/nullable is blocked
  • ClickHouse: add/modify/drop column, add/drop index. Verify FK/PK operations are blocked
  • MSSQL: full matrix, verify default constraint handling on modify
  • Verify SQL preview popover shows correct DDL before execution
  • Verify unsupported operations are disabled in context menus (e.g., SQLite "Add Foreign Key")

@datlechin datlechin merged commit 86df3d2 into main Apr 20, 2026
2 checks passed
@datlechin datlechin deleted the feat/alter-table-ddl branch April 20, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

修改表结构 不支持的 Schema 操作

1 participant