mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Multi-db support
This commit is contained in:
parent
bff3160dc2
commit
6108196ee7
@ -93,8 +93,12 @@ class LookupModel extends Eloquent
|
||||
}
|
||||
}
|
||||
|
||||
public static function setDbServer($server, $isUser = false)
|
||||
protected static function setDbServer($server, $isUser = false)
|
||||
{
|
||||
if (! env('MULTI_DB_ENABLED')) {
|
||||
return;
|
||||
}
|
||||
|
||||
config(['database.default' => $server]);
|
||||
|
||||
if ($isUser) {
|
||||
|
@ -46,12 +46,7 @@ return [
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'database' => storage_path().'/database.sqlite',
|
||||
'prefix' => '',
|
||||
],
|
||||
|
||||
// single database setup
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
@ -65,6 +60,7 @@ return [
|
||||
'engine' => 'InnoDB',
|
||||
],
|
||||
|
||||
// multi-database setup
|
||||
'db-ninja-0' => [
|
||||
'driver' => 'mysql',
|
||||
'host' => env('DB_HOST', env('DB_HOST0', 'localhost')),
|
||||
@ -104,26 +100,6 @@ return [
|
||||
'engine' => 'InnoDB',
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'database' => env('DB_DATABASE', 'forge'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => 'utf8',
|
||||
'prefix' => '',
|
||||
'schema' => 'public',
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'database' => env('DB_DATABASE', 'forge'),
|
||||
'username' => env('DB_USERNAME', 'forge'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'prefix' => '',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|
@ -49,12 +49,6 @@ class AddMultipleDatabaseSupport extends Migration
|
||||
|
||||
Schema::rename('lookup_tokens', 'lookup_account_tokens');
|
||||
|
||||
DB::table('db_servers')->insert(
|
||||
['name' => 'db-ninja-1']
|
||||
);
|
||||
DB::table('db_servers')->insert(
|
||||
['name' => 'db-ninja-2']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,5 +29,6 @@ class DatabaseSeeder extends Seeder
|
||||
$this->call('LanguageSeeder');
|
||||
$this->call('IndustrySeeder');
|
||||
$this->call('FrequencySeeder');
|
||||
$this->call('DbServerSeeder');
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,8 @@ class UpdateSeeder extends Seeder
|
||||
$this->call('LanguageSeeder');
|
||||
$this->call('IndustrySeeder');
|
||||
$this->call('FrequencySeeder');
|
||||
|
||||
$this->call('DbServerSeeder');
|
||||
|
||||
Cache::flush();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user