From 593cb915ffc1948d9e05386f6e7678b0da9d8e38 Mon Sep 17 00:00:00 2001 From: "Aaron C. de Bruyn" Date: Wed, 24 Dec 2014 14:31:54 -0800 Subject: [PATCH] Account for differences between mysql and postgresql. Closes GH-89 --- ..._AlterTableIncidentsRemoveDefaultComponent.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/database/migrations/2014_12_13_121410_AlterTableIncidentsRemoveDefaultComponent.php b/app/database/migrations/2014_12_13_121410_AlterTableIncidentsRemoveDefaultComponent.php index cbf60714..6f49f1e8 100644 --- a/app/database/migrations/2014_12_13_121410_AlterTableIncidentsRemoveDefaultComponent.php +++ b/app/database/migrations/2014_12_13_121410_AlterTableIncidentsRemoveDefaultComponent.php @@ -14,7 +14,11 @@ class AlterTableIncidentsRemoveDefaultComponent extends Migration public function up() { Schema::table('incidents', function (Blueprint $table) { - DB::statement("ALTER TABLE incidents CHANGE component_id component_id TINYINT(4) NOT NULL DEFAULT '0';"); + if (Config::get('database')['default'] === 'mysql'){ + DB::statement("ALTER TABLE incidents CHANGE component_id component_id TINYINT(4) NOT NULL DEFAULT '0';"); + } else if (Config::get('database')['default'] === 'pgsql'){ + DB::statement("ALTER TABLE incidents ALTER COLUMN component_id SET DEFAULT '0';"); + } }); } @@ -22,11 +26,16 @@ class AlterTableIncidentsRemoveDefaultComponent extends Migration * Reverse the migrations. * * @return void - */ + */ public function down() { Schema::table('incidents', function (Blueprint $table) { - DB::statement("ALTER TABLE incidents CHANGE component_id component_id TINYINT(4) NOT NULL DEFAULT '1';"); + if (Config::get('database')['default'] === 'mysql'){ + DB::statement("ALTER TABLE incidents CHANGE component_id component_id TINYINT(4) NOT NULL DEFAULT '1';"); + } else if (Config::get('database')['default'] === 'pgsql'){ + DB::statement("ALTER TABLE incidents ALTER COLUMN component_id SET DEFAULT '1';"); + } }); } } +