Prevent an exception when creating databases with the same name on multiple hosts.

closes #1456
This commit is contained in:
Dane Everitt 2019-03-02 15:31:25 -08:00
parent 91c9cbba6f
commit 8253246955
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
4 changed files with 63 additions and 2 deletions

View file

@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class FixUniqueIndexToAccountForHost extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('databases', function (Blueprint $table) {
$table->dropUnique(['database']);
$table->dropUnique(['username']);
$table->unique(['database_host_id', 'database']);
$table->unique(['database_host_id', 'username']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('databases', function (Blueprint $table) {
$table->dropUnique(['database_host_id', 'database']);
$table->dropUnique(['database_host_id', 'username']);
$table->unique(['database']);
$table->unique(['username']);
});
}
}