Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column migration helper with sequences #911

Open
jwoertink opened this issue Nov 29, 2022 · 0 comments
Open

Column migration helper with sequences #911

jwoertink opened this issue Nov 29, 2022 · 0 comments

Comments

@jwoertink
Copy link
Member

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant