Skip to content

Commit c285216

Browse files
authored
Merge pull request #22 from yjacolin/fixSQLUpgrade
Fix SQL upgrade for Pgsql
2 parents db4a86d + 8ea669b commit c285216

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

database/migrations/2022_05_15_030940_control_score_to_int.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@ class ControlScoreToInt extends Migration
1313
*/
1414
public function up()
1515
{
16-
Schema::table('controls', function (Blueprint $table) {
17-
$table->integer('score')->nullable()->change();
18-
});
16+
if (DB::getDriverName() !== 'pgsql') {
17+
DB::statement('ALTER TABLE "controls"
18+
ALTER COLUMN "score" TYPE integer USING (score)::integer,
19+
ALTER COLUMN "score" DROP NOT NULL,
20+
ALTER COLUMN "score" DROP DEFAULT,
21+
ALTER COLUMN "score" DROP identity IF EXISTS);'
22+
} else {
23+
Schema::table('controls', function (Blueprint $table) {
24+
$table->integer('score')->nullable()->change();
25+
});
26+
}
1927
}
2028

2129
/**

0 commit comments

Comments
 (0)