Closed malsgit closed 3 years ago
Hi @malblack. Try with:
php artisan vendor:publish --provider="Spatie\Multitenancy\MultitenancyServiceProvider" --tag="multitenancy-migrations"
that creates
Hi @malblack. Try with:
php artisan vendor:publish --provider="Spatie\Multitenancy\MultitenancyServiceProvider" --tag="multitenancy-migrations"
That shell command creates the following path: database>migrations>2021_03_191136_landlord>create_landlord_tenants_table.php
I think it should be database>migrations>landlord>2021_03_191136_create_landlord_tenants_table.php
I think it is something to do with the following code in the vendor>spatie>laravel=package-tools>PackageServiceProvider.php
$now = now();
foreach ($this->package->migrationFileNames as $migrationFileName) {
if (! $this->migrationFileExists($migrationFileName)) {
$this->publishes([
$this->package->basePath("/../database/migrations/{$migrationFileName}.php.stub") => database_path('migrations/' . $now->addSecond()->format('Y_m_d_His') . '_' . Str::finish($migrationFileName, '.php')),
], "{$this->package->shortName()}-migrations");
}
}
but I don't know how to change it to give the correct path, to run the landlord migration command
Sorry, but I think that the migration path should be project-by-project. For example, using a single-database tenant approach, you won't need to move your migrations into an isolated path.
The package couldn't cover all requirements but helps everyone: with or without small changes.
@masterix21 that's is fine, I just changed the migration folder and file name then ran it all works perfect now :-) and very impressed with it......
Great ;) Happy coding :)
when i try to do : php artisan migrate --path=database/migrations/landlord --database=landlord je reçois cette erreur : // PS C:\laragon\www\commerce> php artisan migrate:fresh --path=database/migrations/landlord --database=landlord
Application In Production! *
Do you really wish to run this command? (yes/no) [no]:
y
Dropped all tables successfully.
Illuminate\Database\QueryException
SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '' (SQL: create table ` (
idint unsigned not null auto_increment primary key,
migrationvarchar(191) not null,
batch` int not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci' engine = InnoDB)
at C:\laragon\www\commerce\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671 667| // If an exception occurs when attempting to run a query, we'll format the error 668| // message to include the bindings with SQL, which will make this exception a 669| // lot more helpful to the developer instead of just the database's errors. 670| catch (Exception $e) {
671| throw new QueryException( 672| $query, $this->prepareBindings($bindings), $e 673| ); 674| } 675|
1 C:\laragon\www\commerce\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDO\Exception.php:18 Doctrine\DBAL\Driver\PDO\Exception::("SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''")
2 C:\laragon\www\commerce\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:84 Doctrine\DBAL\Driver\PDO\Exception::new(Object(PDOException)) PS C:\laragon\www\commerce>
When running the follow:
php artisan vendor:publish --provider="Spatie\Multitenancy\MultitenancyServiceProvider" --tag="migrations"
I get the following errorUnable to locate publishable resources
I can select via list usingphp artisan vendor:publish
but then creates the following folder 2021_03_19_161553_landlord and file inside create_landlord_tenants_table.phpIf I then run the following as per v2 docs, I get an error php artisan migrate --path=database/migrations/landlord --database=landlord if I change the --path to php artisan migrate --path=database/migrations/2021_03_19_161553_landlord --database=landlord
I get the following error in the terminal
After looking at the Scheme::create part it is just putting ('tenants'...... I renamed folder to landlord and running
php artisan make:migration CreateLandlordTenantsTable --path=database/migrations/landlord
and adding the following to public function up$table->string('name'); $table->string('domain')->unique(); $table->string('database')->unique();