Skip to content

Commit c52d5cc

Browse files
tarrowdeer-wmde
authored andcommitted
bug: fix WikiProfile audience not nullable (#909)
WikiProfile audiences should be nullable but aren't I was unable to make them nullable using the laravel ORM This migration does it using raw SQL following this issue [0] in the laravel bug tracker [0] laravel/framework#35096 (comment)
1 parent 83dc682 commit c52d5cc

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
DB::statement('
15+
ALTER TABLE `wiki_profiles` CHANGE COLUMN `audience` `audience`
16+
ENUM("narrow", "wide", "other")
17+
');
18+
}
19+
20+
/**
21+
* Reverse the migrations.
22+
*/
23+
public function down(): void
24+
{
25+
// n.b. this rollback won't work if there are null audience values in the db
26+
DB::statement('
27+
ALTER TABLE `wiki_profiles` CHANGE COLUMN `audience` `audience`
28+
ENUM("narrow", "wide", "other")
29+
NOT NULL
30+
');
31+
32+
}
33+
};

0 commit comments

Comments
 (0)