Skip to content

Sequence problems in breedbase db #5

@bellerbrock

Description

@bellerbrock

Many sequences in the empty breedbase db are not reset, and some of them are out of sync with what data there is, causing problems.

For example even though there is a single example project row in the project table with a project_id of 1, SELECT last_value FROM project_project_id_seq; returns 324.

More importantly the single row in the projectprop table used projectprop_id 456. SELECT last_value FROM projectprop_projectprop_id_seq; returns 455, meaning any additions to the table will increment the seq to 456 and run into a duplicate key value violates unique constraint "projectprop_pkey" error.

To fix the problem for the project tables I ended up just manually deleting the example program and prop, then reset the sequences:

breedbase=# delete from projectprop where project_id = 1;
DELETE 1
breedbase=# delete from project where project_id = 1;
DELETE 1
breedbase=# alter sequence project_project_id_seq restart with 1;
ALTER SEQUENCE
breedbase=# alter sequence projectprop_projectprop_id_seq restart with 1;
ALTER SEQUENCE

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions