Skip to content

sql: databases with sequence that another table depends upon can't be renamed #34416

@awoods187

Description

@awoods187

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

  1. create a new empty database with the new database name.
  2. rename the sequence to go to the new database.
  3. change the DEFAULT expression for that id column to use the new sequence name in the new database (make it use nextval('newdb.public.seqname') instead of just public.seqname).
  4. "move" the tables from old to new database name using alter table rename

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-schema-changesA-schema-descriptorsRelating to SQL table/db descriptor handling.A-sql-pgcompatSemantic compatibility with PostgreSQLA-sql-sequencesSequence handling in SQLC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions