From 5283d87a4e85cf17743039f85c8b00e3c3f82e7e Mon Sep 17 00:00:00 2001 From: Hafifie PKB Date: Tue, 14 Nov 2023 16:07:13 +0800 Subject: [PATCH] fix database migration --- ...8_115215_add_onepercent_to_gadai_table.php | 10 ++- ...0612_add_onepercent_to_kadarupah_table.php | 3 +- ...ercent_to_transaction_keuntungan_table.php | 38 +++++++++++ ...1_104203_add_onepercent_to_tebus_table.php | 65 +++++++++++++++++++ 4 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2023_11_11_101144_add_onepercent_to_transaction_keuntungan_table.php create mode 100644 database/migrations/2023_11_11_104203_add_onepercent_to_tebus_table.php diff --git a/database/migrations/2023_11_08_115215_add_onepercent_to_gadai_table.php b/database/migrations/2023_11_08_115215_add_onepercent_to_gadai_table.php index 0a346ee..3262f74 100644 --- a/database/migrations/2023_11_08_115215_add_onepercent_to_gadai_table.php +++ b/database/migrations/2023_11_08_115215_add_onepercent_to_gadai_table.php @@ -13,6 +13,12 @@ class AddOnepercentToGadaiTable extends Migration * @return void */ + /** + * + * @var object $db_connection + */ + + public function getActiveDB(){ $config_db = array_keys(config("database.connections")); @@ -40,6 +46,7 @@ class AddOnepercentToGadaiTable extends Migration $table->decimal('ujrah', 9, 2); $table->decimal('onepercent', 9, 2); $table->decimal('margin_semasa', 5, 2); + $table->tinyInteger('tagbaru')->default(0); }); } @@ -56,8 +63,7 @@ class AddOnepercentToGadaiTable extends Migration foreach($db_connection as $dbase){ Schema::connection($dbase)->table('gadai', function (Blueprint $table) { - // $table->dropColumn('votes'); - $table->dropColumn(['kadarujrah', 'ujrah', 'onepercent','margin_semasa']); + $table->dropColumn(['kadarujrah', 'ujrah', 'onepercent','margin_semasa','tagbaru']); }); } } diff --git a/database/migrations/2023_11_08_150612_add_onepercent_to_kadarupah_table.php b/database/migrations/2023_11_08_150612_add_onepercent_to_kadarupah_table.php index e7cb116..022542c 100644 --- a/database/migrations/2023_11_08_150612_add_onepercent_to_kadarupah_table.php +++ b/database/migrations/2023_11_08_150612_add_onepercent_to_kadarupah_table.php @@ -27,7 +27,8 @@ class AddOnepercentToKadarupahTable extends Migration public function down() { Schema::connection('mysql7')->table('kadarupah', function (Blueprint $table) { - $table->dropColumn(['kadarujrah', 'kadaronepercent']); + $table->dropColumn(['kadarujrah','kadaronepercent']); + }); } } diff --git a/database/migrations/2023_11_11_101144_add_onepercent_to_transaction_keuntungan_table.php b/database/migrations/2023_11_11_101144_add_onepercent_to_transaction_keuntungan_table.php new file mode 100644 index 0000000..59d4036 --- /dev/null +++ b/database/migrations/2023_11_11_101144_add_onepercent_to_transaction_keuntungan_table.php @@ -0,0 +1,38 @@ +table('transaksi_keuntungan', function (Blueprint $table) { + $table->decimal('ujrah', 5, 2); + $table->decimal('ujrah_rebet', 5, 2); + $table->decimal('onepercent', 5, 2); + $table->decimal('onepercent_rebet', 5, 2); + $table->decimal('tempoh', 5, 2); + $table->decimal('beza_tempoh', 5, 2); + $table->decimal('margin_semasa', 5, 2); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::connection('mysql7')->table('transaksi_keuntungan', function (Blueprint $table) { + $table->dropColumn(['ujrah', 'ujrah_rebet', 'onepercent', 'onepercent_rebet', 'tempoh', 'beza_tempoh', 'margin_semasa']); + }); + } +} diff --git a/database/migrations/2023_11_11_104203_add_onepercent_to_tebus_table.php b/database/migrations/2023_11_11_104203_add_onepercent_to_tebus_table.php new file mode 100644 index 0000000..8b09cc0 --- /dev/null +++ b/database/migrations/2023_11_11_104203_add_onepercent_to_tebus_table.php @@ -0,0 +1,65 @@ +getPdo(); + return true; + } catch(\Exception $e){ + return false; + } + }); + return $db_connection; +} + + public function up() + { + $db_connection = $this->getActiveDB(); + + foreach($db_connection as $dbase){ + Schema::connection($dbase)->table('tebus', function (Blueprint $table) { + $table->decimal('ujrah', 9, 2); + $table->decimal('onepercent', 9, 2); + }); + }; + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + $db_connection = $this->getActiveDB(); + + foreach($db_connection as $dbase){ + Schema::connection($dbase)->table('tebus', function (Blueprint $table) { + $table->dropColumn(['ujrah', 'onepercent']); + }); + } + } +}