From dfb5487829cc31a079aacfd704d0b2c2ef052d4c Mon Sep 17 00:00:00 2001 From: Tr0n Date: Wed, 1 Jan 2025 19:21:49 +0100 Subject: [PATCH] Migrate spam_db to InnoDB and utf8mb4 --- ...1_01_000000_alter_common_spam_db_table.php | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 database/migrations/2025_01_01_000000_alter_common_spam_db_table.php diff --git a/database/migrations/2025_01_01_000000_alter_common_spam_db_table.php b/database/migrations/2025_01_01_000000_alter_common_spam_db_table.php new file mode 100644 index 0000000..56c2d69 --- /dev/null +++ b/database/migrations/2025_01_01_000000_alter_common_spam_db_table.php @@ -0,0 +1,59 @@ +string('word', 191)->charset('utf8mb4')->collation('utf8mb4_unicode_ci')->change(); + }); + // create index on type + Schema::table('spam_db', function (Blueprint $table) { + $table->index('type'); + }); + // update to modern standards (InnoDB & utf8mb4) + Schema::table('spam_db', function (Blueprint $table) { + DB::statement('ALTER TABLE common.spam_db ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci'); + DB::statement('ALTER TABLE common.spam_db CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // revert to old standards (MyISAM & utf8) + Schema::table('spam_db', function (Blueprint $table) { + DB::statement('ALTER TABLE spam_db ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'); + DB::statement('ALTER TABLE spam_db CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci'); + }); + // change word back to 256 characters + Schema::table('spam_db', function (Blueprint $table) { + $table->string('word', 256)->charset('utf8')->collation('utf8_general_ci')->change(); + }); + // drop index on type + Schema::table('spam_db', function (Blueprint $table) { + $table->dropIndex(['type']); + }); + } +};