-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: databases with sequence that another table depends upon can't be renamed #34416
Copy link
Copy link
Closed
Labels
A-schema-changesA-schema-descriptorsRelating to SQL table/db descriptor handling.Relating to SQL table/db descriptor handling.A-sql-pgcompatSemantic compatibility with PostgreSQLSemantic compatibility with PostgreSQLA-sql-sequencesSequence handling in SQLSequence handling in SQLC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Description
Today CockroachDb's implementation of sequences is incomplete and does not allow renaming the database containing a sequence that's depended on by a table it's a limitation in the support of sequences.
Work Around
Unfortunately, I think you can't simply drop the DEFAULT expression on the id column to get rid of the table -> sequence dependency, because IIRC we don't properly update the dependency information when the DEFAULT expression is changed. (that's another limitation/bug)
maybe (I'm not sure) it's possible to
- create a new empty database with the new database name.
- rename the sequence to go to the new database.
- change the DEFAULT expression for that
idcolumn to use the new sequence name in the new database (make it usenextval('newdb.public.seqname')instead of justpublic.seqname). - "move" the tables from old to new database name using
alter table rename
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-schema-changesA-schema-descriptorsRelating to SQL table/db descriptor handling.Relating to SQL table/db descriptor handling.A-sql-pgcompatSemantic compatibility with PostgreSQLSemantic compatibility with PostgreSQLA-sql-sequencesSequence handling in SQLSequence handling in SQLC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.