1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 14:34:04 +00:00

Create MySQL/PostgreSQL DBs while using sqlite as the central DB driver

This commit is contained in:
Samuel Štancl 2019-09-21 11:11:36 +02:00
parent 1e6b21cfd4
commit eb6cba8f1a
11 changed files with 62 additions and 22 deletions

View file

@ -59,6 +59,13 @@ return [
'mysql' => 'Stancl\Tenancy\TenantDatabaseManagers\MySQLDatabaseManager',
'pgsql' => 'Stancl\Tenancy\TenantDatabaseManagers\PostgreSQLDatabaseManager',
],
'database_manager_connections' => [
// Connections used by TenantDatabaseManagers. This tells, for example, the
// MySQLDatabaseManager to use the mysql connection to create databases.
'sqlite' => 'sqlite',
'mysql' => 'mysql',
'pgsql' => 'pgsql',
],
'bootstrappers' => [
// Tenancy bootstrappers are executed when tenancy is initialized.
// Their responsibility is making Laravel features tenant-aware.

View file

@ -17,7 +17,7 @@ class CreateTenantsTable extends Migration
{
Schema::create('tenants', function (Blueprint $table) {
$table->string('id', 36)->primary(); // 36 characters is the default uuid length
// your custom, indexed columns go here
// (optional) your custom, indexed columns can go here
$table->json('data');
});

View file

@ -16,8 +16,10 @@ class CreateDomainsTable extends Migration
public function up()
{
Schema::create('domains', function (Blueprint $table) {
$table->string('tenant_id', 36); // 36 characters is the default uuid length // todo foreign key?
$table->string('tenant_id', 36); // 36 characters is the default uuid length
$table->string('domain', 255)->unique(); // don't change this
$table->foreign('tenant_id')->references('id')->on('tenants')->onUpdate('cascade')->onDelete('cascade');
});
}