Repository navigation
v0.1.0-alpha.2
Pre-release
Pre-release
·
4 commits
to main
since this release
Adds schema management: creating and altering tables, columns, indexes, foreign
keys and views from Tabularis's dialogs. Tested against CockroachDB v24.3 and
the latest release.
Added
- Schema management:
get_create_table_sql,get_add_column_sql,
get_alter_column_sql,get_create_index_sql,get_create_foreign_key_sql,
drop_index,drop_foreign_key,create_view,alter_viewanddrop_view.- Primary keys are named
<table>_pkey, composite keys work, andSERIAL
columns keep their width (SMALLSERIAL,SERIAL4,SERIAL). - A new primary key column is added and then extends the table's key through
ALTER PRIMARY KEY(CockroachDB rejectsADD COLUMN .. PRIMARY KEYon a
table that already has a key). A table with no key still generates, with a
warning comment. - Altering a column emits one statement per change (rename, type, nullability,
default, description). A change that converts data getsUSINGand a note
about the session setting CockroachDB v24.3 needs. - Indexes are dropped as
schema.table@index, so an index name shared by two
tables is never ambiguous. - A view whose columns change is replaced by dropping and creating it in one
transaction, so a failure in between restores the old view. A view's query
resolves unqualified table names in the view's own schema. - Types, default expressions and view queries are validated before they are
used in SQL (no;, no comment, nothing left open), names are always quoted,
foreign key actions are limited to the five SQL actions, and drops never
cascade.
- Primary keys are named
Changed
docs/architecture/04-ddl.mdrecords the host's real request and reply shapes
and what was verified on v24.3 and v26.3.
Known limitations
Tracked in #16:
EXPLAINis not implemented; the explain button returns "Method not found".- Materialized views, sequences, routines, triggers, multi-region metadata and
the schema snapshot (ER diagram) are not provided yet. - Schema management follows what the host's dialogs send. Options they do not
offer are not generated:STORING, hash-sharded, inverted and partial indexes,
NOT VALIDforeign keys, comments on tables and schemas, andLOCALITY. - On v24.3, a type change that converts data needs
SET enable_experimental_alter_column_type_general = truein the same session.
The host runs each generated statement separately, so the setting is explained
in a comment and not emitted; v26.3 needs nothing. - Replacing a view whose columns change makes it invisible for about 70 ms. A
view other views depend on cannot be replaced, and an index behind a referenced
UNIQUEconstraint is not dropped (the error gives theCASCADEstatement). - Not exercised against a real CockroachDB Cloud cluster, nor query cancellation
behind a load balancer; a real40001retry of an implicit statement could not
be provoked on the tested releases.