Skip to content

Commit

Permalink
internal(migration): prevent migration of key renewals
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Sep 23, 2023
1 parent d90ccd8 commit db655eb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@

use CodeIgniter\Database\Migration;

use Config\Database;

class RenewCurrencyUniqueness extends Migration
{
public function up()
{
$database = Database::connect();

if ($database->DBDriver === "SQLite3") return;

$this->forge->dropKey("currencies", "currencies_code_key", false);
$this->forge->dropKey("currencies", "currencies_name_key", false);
$this->forge->addUniqueKey([ "user_id", "code", "name" ]);
Expand All @@ -16,6 +22,10 @@ public function up()

public function down()
{
$database = Database::connect();

if ($database->DBDriver === "SQLite3") return;

$this->forge->dropKey("currencies", "currencies_user_id_code_name", false);
$this->forge->addUniqueKey("code", "currencies_code_key");
$this->forge->addUniqueKey("name", "currencies_name_key");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@

use CodeIgniter\Database\Migration;

use Config\Database;

class RenewAccountUniqueness extends Migration
{
public function up()
{
$database = Database::connect();

if ($database->DBDriver === "SQLite3") return;

$this->forge->dropKey("accounts", "accounts_name_key", false);
$this->forge->addUniqueKey([ "currency_id", "name" ]);
$this->forge->processIndexes("accounts");
}

public function down()
{
$database = Database::connect();

if ($database->DBDriver === "SQLite3") return;

$this->forge->dropKey("accounts", "accounts_currency_id_name", false);
$this->forge->addUniqueKey("name", "accounts_name_key");
$this->forge->processIndexes("accounts");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@

use CodeIgniter\Database\Migration;

use Config\Database;

class RenewModifierUniqueness extends Migration
{
public function up()
{
$database = Database::connect();

if ($database->DBDriver === "SQLite3") return;

$this->forge->dropKey("modifiers", "modifiers_name_key", false);
$this->forge->addUniqueKey([ "debit_account_id", "credit_account_id", "name" ]);
$this->forge->processIndexes("modifiers");
}

public function down()
{
$database = Database::connect();

if ($database->DBDriver === "SQLite3") return;

$this->forge->dropKey(
"modifiers",
"modifiers_debit_account_id_credit_account_id_name",
Expand Down

0 comments on commit db655eb

Please sign in to comment.