Make MySQL Happy

MySQL complains when we try to change the rules column to json before we change the data... If we change the data, then change the column its happy. :)
This commit is contained in:
notCharles 2024-09-07 09:47:39 -04:00
parent 49e93c1379
commit 8c64a4ad55

View File

@ -12,13 +12,13 @@ return new class extends Migration
*/ */
public function up(): void public function up(): void
{ {
Schema::table('egg_variables', function (Blueprint $table) {
$table->json('rules')->change();
});
DB::table('egg_variables')->select(['id', 'rules'])->cursor()->each(function ($eggVariable) { DB::table('egg_variables')->select(['id', 'rules'])->cursor()->each(function ($eggVariable) {
DB::table('egg_variables')->where('id', $eggVariable->id)->update(['rules' => explode('|', $eggVariable->rules)]); DB::table('egg_variables')->where('id', $eggVariable->id)->update(['rules' => explode('|', $eggVariable->rules)]);
}); });
Schema::table('egg_variables', function (Blueprint $table) {
$table->json('rules')->change();
});
} }
/** /**