From 9b45721609eab303c95d16bbf082a476b778a8d0 Mon Sep 17 00:00:00 2001 From: Prophet731 Date: Mon, 9 May 2016 02:11:37 -0700 Subject: [PATCH] Fixed setup errors --- .../2016_01_02_173641_add_russian_language.php | 9 ++++++++- .../2016_01_06_002532_add_pusher_permission.php | 9 ++++++++- app/database/seeds/DatabaseSeeder.php | 7 +++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/database/migrations/2016_01_02_173641_add_russian_language.php b/app/database/migrations/2016_01_02_173641_add_russian_language.php index 55761e499..5f48b39a7 100644 --- a/app/database/migrations/2016_01_02_173641_add_russian_language.php +++ b/app/database/migrations/2016_01_02_173641_add_russian_language.php @@ -5,7 +5,6 @@ class AddRussianLanguage extends Migration { - /** * Run the migrations. * @@ -13,6 +12,14 @@ class AddRussianLanguage extends Migration */ public function up() { + if (Option::count() == 0) { + if (! defined('FIRST_RUN')) { + define('FIRST_RUN', true); + } + + return; + } + $setting = Option::setting('site.languages')->first(); $keys = explode(',', $setting->option_value); diff --git a/app/database/migrations/2016_01_06_002532_add_pusher_permission.php b/app/database/migrations/2016_01_06_002532_add_pusher_permission.php index c3c4f9338..1e92dad0f 100644 --- a/app/database/migrations/2016_01_06_002532_add_pusher_permission.php +++ b/app/database/migrations/2016_01_06_002532_add_pusher_permission.php @@ -7,7 +7,6 @@ class AddPusherPermission extends Migration { - /** * Run the migrations. * @@ -15,6 +14,14 @@ class AddPusherPermission extends Migration */ public function up() { + if (Permission::count() == 0) { + if (! defined('FIRST_RUN')) { + define('FIRST_RUN', true); + } + + return; + } + $now = Carbon::now(); $permissions = [ diff --git a/app/database/seeds/DatabaseSeeder.php b/app/database/seeds/DatabaseSeeder.php index 46aa5d47e..4c34a3970 100644 --- a/app/database/seeds/DatabaseSeeder.php +++ b/app/database/seeds/DatabaseSeeder.php @@ -2,7 +2,6 @@ class DatabaseSeeder extends Seeder { - /** * Run the database seeds. * @@ -19,7 +18,11 @@ public function run() $this->call('PermissionsTableSeeder'); $this->call('UserTableSeeder'); + if (defined('FIRST_RUN')) { + DB::delete("DELETE FROM `bfacp_migrations` WHERE `migration` IN ('2016_01_02_173641_add_russian_language', '2016_01_06_002532_add_pusher_permission')"); + Artisan::call('migrate', ['--force' => true]); + } + DB::statement('SET FOREIGN_KEY_CHECKS=1'); } - }