Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

New idea for migrations and seeders. #1199

Open
Fox4Iit opened this issue Jun 4, 2018 · 4 comments
Open

New idea for migrations and seeders. #1199

Fox4Iit opened this issue Jun 4, 2018 · 4 comments

Comments

@Fox4Iit
Copy link

Fox4Iit commented Jun 4, 2018

If we can make migrations available for editing at any time, even on a production server.
When a migration is being performed, we would check for the column attributes, or the column existence, if it does exists, then move to next, if not, then create it, if it DOESN'T exists, or have a different attribute, it will change or the column will be deleted from the database.
As for the seeder, we would check for the value of the column, if it does exists, then we can resume next.
I don't know how to make this myself, any help or guide to read on how to accomplish that?

@sisve
Copy link

sisve commented Jun 4, 2018

If we can make migrations available for editing at any time, even on a production server.

wee-woo-wee-woo

What you're suggesting goes against how migrations are meant to work. Once written they should not change. You should be able to run them again to create an identical database.

Have you looked into similar ideas? #980 and #944 seems relevant.

@Fox4Iit
Copy link
Author

Fox4Iit commented Jun 4, 2018

@sisve Well, I believe it doesn't. If we made that work, then we can create an identical database. But for an existing database ON PRODUCTION, we can't update the columns. We would drop all tables, then recreate. Or create a migration file for editing only. And this will create a very long chain of files to be migrated. I think you know, customers change their minds each day :D :D So, the best solution to make things easier and more peaceful, is to make the migration handle dropped columns and newly created columns...

@sisve
Copy link

sisve commented Jun 4, 2018

I disagree that we need to ability to edit migrations, or even have them change once deployed. However, a schema file (or any source of "this is the way the database should look like) could be used to generate migration files for you. This allows you to verify them before you deploy them, but they should still not be changed after deployment. How does this sound?

@martinbean
Copy link

But for an existing database ON PRODUCTION, we can't update the columns.

@Fox4Iit Why can’t you? You can write migrations that add/edit/remove individual columns.

And this will create a very long chain of files to be migrated.

But that’s how migrations are meant to work. Migrations are like source control for your database schema: each change to your schema is represented by a migration file.

I think you know, customers change their minds each day :D :D So, the best solution to make things easier and more peaceful, is to make the migration handle dropped columns and newly created columns...

Your migrations should be dropping and creating columns.

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

No branches or pull requests

3 participants