Skip to content

Column migration helper with sequences #911

@jwoertink

Description

@jwoertink

Related: #910
Related: #797

This would be more of a column helper so when you define a column that you want a default to be a sequence, it sets everything up for you.

create :accounts do
  add number : Int64, default: :sequence
end

My thought is that this would automatiically create this column and a sequence as well as set the default value to that sequence.

CREATE SEQUENCE accounts_number_seq;
CREATE TABLE accounts (
  number int DEFAULT nextval('accounts_number_seq')
);

Maybe something like that.... One tricky part is I don't think the crystal DB allows you to run multiple statements at once. We may need will/crystal-pg#253 to be implemented before this can be done...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions