Fixes migrations to actually rollback all the way.

This commit is contained in:
Dane Everitt 2017-04-19 18:43:32 -04:00
parent 33262cf34c
commit d695532aa2
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
10 changed files with 20 additions and 34 deletions

View File

@ -29,6 +29,6 @@ class AddAllocationsTable extends Migration
*/
public function down()
{
Schema::dropIfExsits('allocations');
Schema::dropIfExists('allocations');
}
}

View File

@ -28,6 +28,6 @@ class CreateFailedJobsTable extends Migration
*/
public function down()
{
Schema::drop('failed_jobs');
Schema::dropIfExists('failed_jobs');
}
}

View File

@ -32,6 +32,6 @@ class CreateJobsTable extends Migration
*/
public function down()
{
Schema::drop('jobs');
Schema::dropIfExists('jobs');
}
}

View File

@ -28,8 +28,6 @@ class AddServerVariables extends Migration
*/
public function down()
{
Schema::table('server_variables', function (Blueprint $table) {
//
});
Schema::dropIfExists('server_variables');
}
}

View File

@ -30,6 +30,6 @@ class AddServiceOptions extends Migration
*/
public function down()
{
Schema::dropIfExsits('service_options');
Schema::dropIfExists('service_options');
}
}

View File

@ -32,14 +32,11 @@ class AddForeignServerVariables extends Migration
public function down()
{
Schema::table('server_variables', function (Blueprint $table) {
$table->dropForeign('server_variables_server_id_foreign');
$table->dropForeign('server_variables_variable_id_foreign');
$table->dropIndex('server_variables_server_id_foreign');
$table->dropIndex('server_variables_variable_id_foreign');
$table->dropForeign(['server_id']);
$table->dropForeign(['variable_id']);
});
DB::statement('ALTER TABLE allocations
DB::statement('ALTER TABLE server_variables
MODIFY COLUMN server_id MEDIUMINT(8) UNSIGNED NULL,
MODIFY COLUMN variable_id MEDIUMINT(8) UNSIGNED NOT NULL
');

View File

@ -26,11 +26,7 @@ class AddForeignTasks extends Migration
public function down()
{
Schema::table('tasks', function (Blueprint $table) {
$table->dropForeign('tasks_server_foreign');
$table->dropForeign('tasks_server_foreign');
$table->dropIndex('tasks_server_foreign');
$table->dropIndex('tasks_server_foreign');
$table->dropForeign(['server']);
});
}
}

View File

@ -28,8 +28,7 @@ class AddPackColumn extends Migration
public function down()
{
Schema::table('servers', function (Blueprint $table) {
$table->dropForeign('servers_pack_foreign');
$table->dropIndex('servers_pack_foreign');
$table->dropForeign(['pack']);
$table->dropColumn('pack');
});
}

View File

@ -40,6 +40,9 @@ class UpdateColumnNames extends Migration
$table->foreign('allocation_id')->references('id')->on('allocations');
$table->foreign('service_id')->references('id')->on('services');
$table->foreign('option_id')->references('id')->on('service_options');
// Pack ID was forgotten until multiple releases later, therefore it is
// contained in '2017_03_18_204953_AddForeignKeyToPacks'
});
}
@ -51,19 +54,11 @@ class UpdateColumnNames extends Migration
public function down()
{
Schema::table('servers', function (Blueprint $table) {
$table->dropForeign('servers_node_id_foreign');
$table->dropForeign('servers_owner_id_foreign');
$table->dropForeign('servers_allocation_id_foreign');
$table->dropForeign('servers_service_id_foreign');
$table->dropForeign('servers_option_id_foreign');
$table->dropForeign('servers_pack_id_foreign');
$table->dropIndex('servers_node_id_foreign');
$table->dropIndex('servers_owner_id_foreign');
$table->dropIndex('servers_allocation_id_foreign');
$table->dropIndex('servers_service_id_foreign');
$table->dropIndex('servers_option_id_foreign');
$table->dropIndex('servers_pack_id_foreign');
$table->dropForeign(['node_id']);
$table->dropForeign(['owner_id']);
$table->dropForeign(['allocation_id']);
$table->dropForeign(['service_id']);
$table->dropForeign(['option_id']);
$table->renameColumn('node_id', 'node');
$table->renameColumn('owner_id', 'owner');
@ -77,6 +72,7 @@ class UpdateColumnNames extends Migration
$table->foreign('allocation')->references('id')->on('allocations');
$table->foreign('service')->references('id')->on('services');
$table->foreign('option')->references('id')->on('service_options');
$table->foreign('pack')->references('id')->on('service_packs');
});
}
}

View File

@ -34,7 +34,7 @@ class AddNewServiceOptionsColumns extends Migration
public function down()
{
Schema::table('service_options', function (Blueprint $table) {
$table->dropForeign('config_from');
$table->dropForeign(['config_from']);
$table->dropColumn('config_from');
$table->dropColumn('config_stop');