vanilophp / framework

The truly Laravel E-commerce Framework
https://vanilo.io
MIT License
810 stars 102 forks source link

Database tables prefixes to avoid collisions with another tables in existing application. #82

Closed d-cell closed 4 years ago

d-cell commented 4 years ago

Hello! I would like to suggest an enhancement if it`s possible.

During installation of Vanilo framework into my existing application i`ve got some collisions related to the same table names in my application and the tables, which Vanilo is trying to create.

For example, before to install Vanilo, i already had "products", "permissions", "addresses" and some other tables which names are the same as Vanilo`s.

So, i guess it would be good to be able to set some prefixes for newly created Vanilo`s tables, or just make needful changes to existing tables during installation.

Best Regards and thank you for a great job!

fulopattila122 commented 4 years ago

If you already had those tables, then the ones from Vanilo are likely not even necessary.

In such cases, the best is to "mute" migrations, publish them to your app, and cherry-pick the ones you need. Here's how to do it:

  1. Make sure you're using at least Concord v1.6 (composer update konekt/concord)
  2. Disable the loading of Vanilo migrations:
    // config/concord.php
    return [
    // ...
        'modules' => [
            Vanilo\Framework\Providers\ModuleServiceProvider::class => [
                'migrations' => false
    //...
  3. Publish Vanilo migrations to your app:
    php artisan vendor:publish --provider='Vanilo\\Framework\\Providers\\ModuleServiceProvider' --tag="migrations"
  4. Delete the ones you don't need from the database/migrations/ folder.
  5. Optional: you may want to inform Vanilo about the different Product, Permission, etc models. Read How To Use Custom Models

For more details see: Turn off Migrations, Publishing File Groups

d-cell commented 4 years ago

Wow! Thank you for informative answer. This is almost what i did in my case. I just took all the migrations from Vanilo, deleted those which are not necessary for me, then edited some of those which are left. I informed Vanilo to use different models too. Also i had a trouble with roles and permissions, so i had to make some manipulations inside databases to let my user use both Vanilo and my admin interface, but i think that was my distinct issue.

Next time if iʼll face the same problem iʼll just do it the way you provided.

fulopattila122 commented 4 years ago

Your case sounds like to me like you may not need to pull in the entire vanilo framework but some of the components only.

See: https://vanilo.io/docs/1.2/modules-vs-framework

This way the admin, ACL (permissions), etc can completely be left out of the app, and you don't have to disable it. Vanilo was designed with these use cases in the head, so this is something that you're completely expected to do.

d-cell commented 4 years ago

You're right, here i could use a separate components only. It would have to be done on beginning, but for now i've done a lot of stuff in this project and it works fine, so i don't want to fix the things that work :). This is great that Vanilo is not a monolith package, but consists of independent packages.

Thank you for being in touch.