From 774ac1976ff0085210b3705508e06fb8c42feb09 Mon Sep 17 00:00:00 2001 From: "LDFOUR\\luisd" Date: Wed, 16 Apr 2025 16:48:53 -0300 Subject: [PATCH] resolved migration logic. --- ...25_127530_change_region_to_subnational.php | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/database/migrations/2025_03_25_127530_change_region_to_subnational.php b/database/migrations/2025_03_25_127530_change_region_to_subnational.php index 32a7ad9..e2c0b98 100644 --- a/database/migrations/2025_03_25_127530_change_region_to_subnational.php +++ b/database/migrations/2025_03_25_127530_change_region_to_subnational.php @@ -6,28 +6,33 @@ class ChangeRegionToSubnational extends Migration { - /** - * Run the migrations. - * - * @return void - */ public function up() { + Schema::table('usage_logs', function (Blueprint $table) { + $table->string('subnational')->nullable(); + }); + DB::table('usage_logs')->update([ 'subnational' => DB::raw('region') ]); + + Schema::table('usage_logs', function (Blueprint $table) { + $table->dropColumn('region'); + }); } - - /** - * Reverse the migrations. - * - * @return void - */ + public function down() - { +{ + Schema::table('usage_logs', function (Blueprint $table) { + $table->string('region')->nullable(); + }); - DB::table('usage_logs')->update([ - 'region' => DB::raw('subnational') - ]); - } + DB::table('usage_logs')->update([ + 'region' => DB::raw('subnational') + ]); + + Schema::table('usage_logs', function (Blueprint $table) { + $table->dropColumn('subnational'); + }); +} }