Don't allow creation of a database with an identical name for the same server; closes #2447
This commit is contained in:
parent
7b0f998f0b
commit
a4d7170fac
2 changed files with 68 additions and 1 deletions
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class ChangeUniqueDatabaseNameToAccountForServer extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('databases', function (Blueprint $table) {
|
||||
$table->dropUnique(['database_host_id', 'database']);
|
||||
});
|
||||
|
||||
Schema::table('databases', function (Blueprint $table) {
|
||||
$table->unique(['database_host_id', 'server_id', 'database']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('databases', function (Blueprint $table) {
|
||||
$table->dropUnique(['database_host_id', 'server_id', 'database']);
|
||||
});
|
||||
|
||||
Schema::table('databases', function (Blueprint $table) {
|
||||
$table->unique(['database_host_id', 'database']);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue