diff --git a/app/database/migrations/2014_12_01_121947_AlterTableIncidentsRenameComponentColumn.php b/app/database/migrations/2014_12_01_121947_AlterTableIncidentsRenameComponentColumn.php index 1142f2c3..63c97378 100644 --- a/app/database/migrations/2014_12_01_121947_AlterTableIncidentsRenameComponentColumn.php +++ b/app/database/migrations/2014_12_01_121947_AlterTableIncidentsRenameComponentColumn.php @@ -14,7 +14,7 @@ class AlterTableIncidentsRenameComponentColumn extends Migration public function up() { Schema::table('incidents', function (Blueprint $table) { - $table->rename('component', 'component_id'); + $table->renameColumn('component', 'component_id'); }); } @@ -26,7 +26,7 @@ class AlterTableIncidentsRenameComponentColumn extends Migration public function down() { Schema::table('incidents', function (Blueprint $table) { - $table->rename('component_id', 'component'); + $table->renameColumn('component_id', 'component'); }); } } diff --git a/app/database/migrations/2014_12_13_121410_AlterTableIncidentsRemoveDefaultComponent.php b/app/database/migrations/2014_12_13_121410_AlterTableIncidentsRemoveDefaultComponent.php index 87fbb64b..2f8dc9f4 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';"); + } elseif (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';"); + } elseif (Config::get('database')['default'] === 'pgsql') { + DB::statement("ALTER TABLE incidents ALTER COLUMN component_id SET DEFAULT '1';"); + } }); } } +