gecche / laravel-multidomain

A Laravel extension for using a laravel application on a multi domain setting
MIT License
838 stars 105 forks source link

Domain specific migration and seeders #56

Closed centralcybersecurity closed 3 years ago

centralcybersecurity commented 3 years ago

Hi, first of all, this is an amazing package, able to get it up and working.

I am a little puzzled with the migrations and seeding for specific DB/Domain. I created database/migrations/site_test folder to store site_test specific files. However, when I run the command "php artisan migrate --domain=site.test" - the system loads the migration tables from the migrations folder and not the site_test folder. Why this is happening?

Also, how do I run seeders for a specific domain? Do I have to create a subfolder sites_test under /seeders/ folder - just like /migrations/ - will that work?

Thank you for your help.

Regards

maganius commented 3 years ago

You found a solution for this?

centralcybersecurity commented 3 years ago

No.

gecche commented 3 years ago

Hi,

the package is aimed to only cope with the very basics of the Laravel framework, leaving the other stuff free to be implemented and organized as you prefer. For many reasons I strongly prefer to have a lightweight package, so the only specific domain folders given by the package are the storage ones. And the cache ones.

For migrations and seeders, I think that there are some ways to accomplish what you need:

public function up() {
   if (config('domain.dbgroup') === <SOMEGROUP>) {
      <PERFORM TASK>
   }
}

hope this helps

Cheers

Giacomo

centralcybersecurity commented 3 years ago

Ok. I see this is beyond my laravel skills. As of now, I am able to identify and control what to display based on the current domain_name. So, I am more leaning on the following approach:

  1. Build a web-based /seed-data page
  2. Identify the domain and pick a seed-domain_name.json
  3. Then insert it into the DB for that specific domain (like any other post method)
  4. That's it.

This seems to be an easy way for me and I don't know if this is an efficient way to do it.

As for migrations, I am okay with all DBs having all tables from a single migrations folder. So, that's settled now.

gecche commented 3 years ago

Hi,

I think that also your approach could work without any problem...

However, thinking about your problem, I will consider in future releases of extending some base commands in order to accept a specific path for each domain... it could be useful and of general purpose.

Thanks

Giacomo