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

Improve the migration and seeder flow #40

Open
gfazioli opened this issue Jun 27, 2024 · 0 comments
Open

Improve the migration and seeder flow #40

gfazioli opened this issue Jun 27, 2024 · 0 comments

Comments

@gfazioli
Copy link
Collaborator

@balazsnasz

For now, migrations/seeders are not tracked properly if they have ran or not.
Especially, if we call new migrations/seeders in the upgrader_post_install, we must know somehow which ones have already ran and which isn't.
For WordPress, traditional migrations doesn't make sense in my opinion.

Here is my concern: if you create new migrations and/or seeder, you will most likely add columns or new data for an existing table. Now, the runOnce selects a count() for checking if it has already ran or not. If you add new columns or new lines to an existing table, the new migrations/seeders won't run due to this.

I have two possible solutions in my mind.
Attach the plugin's current version to each migration/seeder files. This way you know which files are new (in the upgrader_post_install hook) and you can run them. For example, create-websites-table-1.4.7.php.
Store every migrations/seeders' state in a new {plugin-name}-migrations table. This is closer what Laravel does.
The first solution is easier to implement. However the second one is more flexible, but for WordPress it also seems kinda overkill.

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

No branches or pull requests

1 participant