-
Notifications
You must be signed in to change notification settings - Fork 10
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
Consider removing enum types as part of db:drop
/ db:reset
#11
Comments
What if I changed |
Yeah, I think that would work. I doubt you'd ever have colliding names in a single app. Once I finish up what I'm currently working on at work, I'll have an environment for you to play with. |
It turns out that |
@alassek thanks for this really handy gem! Im really enjoying using it in production. I frequently reset my localdev databases, and run into this issue as well. In the meantime, I just wrote my own .sql file to destroy my custom enum types when I db:reset or db:setup. As for
Im not sure if you meant a Ruby block or a SQL DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'my_type') THEN
CREATE TYPE my_type AS
(
-- add fields...
);
END IF;
END$$; If I had more time Id contribute towards a PR! Perhaps in a few weekends from now. |
@stratigos yes, that is basically what I had in mind... but I think there's another wrinkle to this. I don't want to blithely wipe out preexisting enums in a production environment, so I think this also needs to tap into the functionality added by rails/rails#22967 So in development, |
Since Postgres defines types in the
postgres
tables, runningdb:reset
can get you into a situation where you cannot re-run your migrations that define your Postgres enums. As a simple reproduction:create_enum
db:migrate
db:reset
The migration will fail because the type already exists.
This all makes sense, but I wonder if there's a way we could make it so
db:drop
also drops any enums defined by this gem?The text was updated successfully, but these errors were encountered: