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

[FEATURE]: Use native Eloquent migration #28

Open
dimitriBouteille opened this issue Mar 4, 2024 · 5 comments
Open

[FEATURE]: Use native Eloquent migration #28

dimitriBouteille opened this issue Mar 4, 2024 · 5 comments
Assignees
Labels
development enhancement New feature or request v4
Milestone

Comments

@dimitriBouteille
Copy link
Owner

dimitriBouteille commented Mar 4, 2024

Replace robmorgan/phinx by custom migration tool. The migration system should ideally take over the same logic and functionality as what is proposed by Laravel.

  • Create migration
  • Run migration
  • Execute one migration
  • Show migration status
  • Rollback migration

In order to make the system configurable, it is necessary to provide :

  • The migration directory configuration - probably via filter or constant
  • The migration table name configuration - probably via filter or constant
@rafaucau
Copy link
Contributor

rafaucau commented Oct 16, 2024

Maybe this would be a code inspiration on how it can be done in WordPress:

@dimitriBouteille
Copy link
Owner Author

Hi @rafaucau

Thanks for sharing the links, the goal of dbout/wp-orm is to avoid overusing third party dependencies in order to reduce problems. I think to start on a migration system as simple as possible with wp-cli.

I already started working on the subject by checking that the Dbout\WpOrm\Orm\Schemas\WordPressBuilder class works well: #96

This new migration system is probably the last topic before releasing the v4 :)

@dimitriBouteille
Copy link
Owner Author

@rafaucau

For information, I updated the ticket with the desired features. If you have ideas, do not hesitate to suggest :)

@dimitriBouteille dimitriBouteille modified the milestones: 4.x.x, 4.1.x Nov 12, 2024
@rafaucau
Copy link
Contributor

rafaucau commented Nov 30, 2024

I could create a Pull Request for this when I find some time. Here's my vision for it:

  • Add a setup method that would handle WP-CLI command registration. It could also register facades ([FEATURE] Add Illuminate\Support\Facades\DB facade  #64). The mu-plugin / plugin would then call this method.
  • The WP-CLI commands would proxy all necessary Laravel commands, for example:
    • php artisan make:migration create_some_table ➡️ wp orm make:migration create_some_table
    • php artisan migrate ➡️ wp orm migrate
    • and so on...

And this is what the setup method could look like:

Dbout\WpOrm\Orm::setup([
    'migrations' => [
        'directory' => WP_ORM_MIGRATIONS_DIR,
        'table' => apply_filters('my-plugin/migrations-table', 'my_plugin_migrations'),
    ],
    'commands' => [
        'enabled' => true,
        'prefix' => 'orm',
    ],
    'facades' => [
        'enabled' => true 
    ]
]);

This approach would enable the use of WordPress filters and custom constants, allowing the library to be used across different independent plugins without conflicts. Plugins could define their own constants and filters. Note: When multiple independent plugins use this library, they should use tools like Strauss to prefix namespaces and other things to avoid version conflicts.

What do you think about this approach?

@dimitriBouteille
Copy link
Owner Author

Hi @rafaucau

Thanks for the proposal, I have a little less time than expected to work on this feature, thank you for your help:)

I think the approach is good, just a little remark for the facades. In my own projects I use the Laravel facade system with a custom container, so it should be possible to pass its own container when initializing the DB facade.

Dbout\WpOrm\Orm::setup([
    ...,
    'facades' => [
        'container' => new MyContainer(),
        'enabled' => true 
    ]
]);

@dimitriBouteille dimitriBouteille pinned this issue Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development enhancement New feature or request v4
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants