Open BenRutlandWeb opened 3 years ago
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.
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.
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.