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

Migration scripts #128

Open
BenRutlandWeb opened this issue Jun 22, 2021 · 2 comments
Open

Migration scripts #128

BenRutlandWeb opened this issue Jun 22, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@BenRutlandWeb
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
It's not easy to create custom tables.

Describe the solution you'd like
A schema builder and migration commands.

Describe alternatives you've considered
Writing raw SQL queries.

Additional context
Laravel has migrations.

@BenRutlandWeb BenRutlandWeb self-assigned this Jun 22, 2021
@BenRutlandWeb BenRutlandWeb added the enhancement New feature or request label Jun 22, 2021
@BenRutlandWeb
Copy link
Collaborator Author

The majority of Radiate commands are meant to be run as developer tools rather than in deploy scripts. WP-CLI isn't available when deploying so it wouldn't be possible to run wp radiate migrate or similar during a deploy. They could of course be run afterwards but, in the context of a plugin, migration scripts should be run on install/activate/deactivate. Themes don't have the same lifecycle hooks as plugins, but running migrations from a theme would be against best practices.

Another consideration is how to manage custom table models. Currently the Radiate Model is based on WP_Query, WP_User_Query and WP_Term_Query. I would hate to have an inconsistent API to access the database.

@BenRutlandWeb
Copy link
Collaborator Author

Something like:

Schema::create('table_name', function (Blueprint $table) {
    $table->id();
    $table->string('name')->nullable();
    $table->timestamps();
});

As a fluent wrapper around dbDelta: https://developer.wordpress.org/reference/functions/dbdelta/ would be a start - a wp-cli command to run the migrations would parse the schema into the formatted query and run it with dbDelta.

The dbDelta function requires particular formatting which would be beneficial being wrapped in a nicer API anyway, but would also act more like Laravel's migrations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant