Skip to content

Bug: Can't track sequences properly #279

@sam-mosleh

Description

@sam-mosleh

Step 1

Create table below (old.sql)

CREATE TABLE public.table1 (
    c1 int NOT NULL,
    c2 serial,
    c3 int GENERATED ALWAYS AS IDENTITY
);

Step 2

Modify it (new.sql)

CREATE TABLE public.table1 (
    c1 serial NOT NULL,
    c2 int GENERATED ALWAYS AS IDENTITY,
    c3 int GENERATED BY DEFAULT AS IDENTITY
);

Expected behavior: To modify sequences after running the plan successfully
Actual behavior: Plan fails because of missing statements and it doesn't even detect c3

Plan: 1 to modify.

Summary by type:
  tables: 1 to modify

Tables:
  ~ table1
    ~ c1 (column)
    ~ c2 (column)

DDL to be executed:
--------------------------------------------------

ALTER TABLE table1 ALTER COLUMN c1 SET DEFAULT nextval('table1_c1_seq'::regclass);

ALTER TABLE table1 ALTER COLUMN c2 DROP DEFAULT;

Do you want to apply these changes? (yes/no): yes

Applying changes...

Executing group 1/1...
  Executing 2 statements in implicit transaction
Error: failed to execute concatenated statements in group 1: ERROR: relation "table1_c1_seq" does not exist (SQLSTATE 42P01)

Context

Tested version 1.6.2@ca0a203 darwin/arm64

@tianzhou I'd be glad to do the PR.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions