You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't get access to the active tenant (& db connection) when executing PHP artisan tenancy:migrate.
I need to change some data after migrating some structural changes
Information
hyn/multi-tenant version: 5.4
laravel version: 5.8
database driver and version: MySQL 8.0.19
webserver software and version: Apache/2.4.41
php version: 7.4.2
The text was updated successfully, but these errors were encountered:
@sasokovacic Instead of running php artisan tenancy:migrate, please run php artisan tenancy:run migrate. Then you should be able to retrieve the current tenant in the migrations using app(\Hyn\Tenancy\Environment::class)->tenant();.
@sasokovacic For the record there is another solution if you do not want to change your script and continue with tenancy:migrate. Please note this solution kind of a band-aid.
In your migration you can identify the tenant yourself by putting the following code in your migration:
/** * Run the migrations. * * @return void */publicfunctionup()
{
$environment = app(\Hyn\Tenancy\Environment::class);
$tenantUuid = DB::connection()->getDatabaseName();
$website = \Hyn\Tenancy\Models\Website::where('uuid', $tenantUuid)->firstOrFail();
$environment->tenant($website);
// Tenant is now identified like in a request
}
I can't get access to the active tenant (& db connection) when executing PHP artisan tenancy:migrate.
I need to change some data after migrating some structural changes
Information
The text was updated successfully, but these errors were encountered: