From 200d443b2cc536e03a08e28257c63b77f85d3eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A0=A2=E5=BE=97=E6=B2=A1=E6=9C=8B=E5=8F=8B?= Date: Wed, 4 Apr 2018 16:39:07 +0800 Subject: [PATCH] fix migration, change the migration #d1a0d96 Remove the transaction sentence that dose not work in mysql DDL action. Change drop() to dropIfExists() function. Closes #678 --- src/views/generators/migration.blade.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/views/generators/migration.blade.php b/src/views/generators/migration.blade.php index 89e8cabd..92b78060 100644 --- a/src/views/generators/migration.blade.php +++ b/src/views/generators/migration.blade.php @@ -12,8 +12,9 @@ class EntrustSetupTables extends Migration */ public function up() { - DB::beginTransaction(); - + + try{ + // Create table for storing roles Schema::create('{{ $rolesTable }}', function (Blueprint $table) { $table->increments('id'); @@ -56,9 +57,13 @@ public function up() ->onUpdate('cascade')->onDelete('cascade'); $table->primary(['permission_id', 'role_id']); - }); + }); + } catch (\Exception $err) { + $this->down(); + throw $err; + } - DB::commit(); + } /** @@ -68,9 +73,9 @@ public function up() */ public function down() { - Schema::drop('{{ $permissionRoleTable }}'); - Schema::drop('{{ $permissionsTable }}'); - Schema::drop('{{ $roleUserTable }}'); - Schema::drop('{{ $rolesTable }}'); + Schema::dropIfExists('{{ $permissionRoleTable }}'); + Schema::dropIfExists('{{ $permissionsTable }}'); + Schema::dropIfExists('{{ $roleUserTable }}'); + Schema::dropIfExists('{{ $rolesTable }}'); } }