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

Document adding a default value to an existing column #946

Open
notramo opened this issue Jun 23, 2023 · 5 comments
Open

Document adding a default value to an existing column #946

notramo opened this issue Jun 23, 2023 · 5 comments
Labels
documentation This just needs more/better documentation

Comments

@notramo
Copy link

notramo commented Jun 23, 2023

The table has a column already, with no default value. I want to add a default value to it without changing anything other.

@jwoertink
Copy link
Member

alter table_for(Post) do
  change_default published_at : Time, default: :now
end

@notramo notramo changed the title Add a default value to an existing column Document adding a default value to an existing column Jun 23, 2023
@notramo
Copy link
Author

notramo commented Jun 23, 2023

As far as I know, it's not documented anywhere.

@jwoertink
Copy link
Member

Nope, not currently luckyframework/website#1077

@notramo
Copy link
Author

notramo commented Jul 3, 2023

@jwoertink Is it possible to remove a default value from a column?

ALTER TABLE users ALTER COLUMN role DROP DEFAULT;

@jwoertink
Copy link
Member

There's no helper method to do that, but you can just run the raw SQL like you have.

@jwoertink jwoertink added the documentation This just needs more/better documentation label Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation This just needs more/better documentation
Projects
None yet
Development

No branches or pull requests

2 participants