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

[5.8] Add ability to drop types when running the migrate:fresh command #28382

Merged
merged 2 commits into from May 6, 2019

Conversation

Projects
None yet
2 participants
@drewrichards
Copy link

commented May 1, 2019

PostgresSQL uses types for for enums. Currently, when using the migrate:fresh command or the RefreshDatabase trait all the tables are dropped but the types used for enums remain. This causes an error when the migrations that created those types are rerun.

This change allows dropping database types when running the migrate:fresh command. It also adds the ability to drop types when using the RefreshDatabase trait in tests.

This code change follows the same pattern that was used to allow dropping views. It adds an option to the migrate:fresh command that will drop types and allows adding a class property to have the RefreshDatabase trait drop types.

Drew Richards added some commits Apr 30, 2019

@drewrichards drewrichards changed the title Add ability to drop types when running the migrate:fresh command [5.8] Add ability to drop types when running the migrate:fresh command May 1, 2019

@taylorotwell

This comment has been minimized.

Copy link
Member

commented May 1, 2019

Why would it be an option? Would you ever want to run migrate:refresh without dropping types?

@drewrichards

This comment has been minimized.

Copy link
Author

commented May 2, 2019

This change affects migrate:fresh rather than migrate:refresh. I believe migrate:refresh would not have a problem with Postgres types since migrate:refresh runs all the down migrations and then performs the up migrations. As long as the up migrations that created the types have corresponding down migrations that drop the types then migrate:refresh will not have any errors.

The issue is with migrate:fresh which drops all tables and then runs all the up migrations. The RefreshDatabase trait relies on migrate:fresh (I assume because it is faster).

My goal with making this change optional was to match the way views were handled. Handling views and handling types in migrate:fresh seemed like very similar problems to me so I thought the code should approach them in the same way. If you prefer that migrate:fresh always drop types if the db connection uses Postgres then I'm happy to make that change.

@taylorotwell taylorotwell merged commit dc2babc into laravel:5.8 May 6, 2019

2 checks passed

continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.