Skip to content

Commit

Permalink
internal(currency): ensure consistent constraint name
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Oct 21, 2023
1 parent f9c5685 commit f7551d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions app/Database/Migrations/2023-07-22-134147_CreateCurrencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,23 @@ public function up()
"code" => [
"type" => "VARCHAR",
"constraint" => "255",
"unique" => true,
],
"name" => [
"type" => "VARCHAR",
"constraint" => "255",
"unique" => true,
]
]);
$this->forge->addPrimaryKey("id");
$this->forge->addForeignKey("user_id", "users", "id", "CASCADE", "CASCADE");
$this->forge->addPrimaryKey("id", "pk_currencies");
$this->forge->addUniqueKey("code", "currencies_code_key");
$this->forge->addUniqueKey("name", "currencies_name_key");
$this->forge->addForeignKey(
"user_id",
"users",
"id",
"CASCADE",
"CASCADE",
"currencies_user_id_foreign"
);
$this->forge->createTable("currencies");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function up()

$this->forge->dropKey("currencies", "currencies_code_key", false);
$this->forge->dropKey("currencies", "currencies_name_key", false);
$this->forge->addUniqueKey([ "user_id", "code", "name" ]);
$this->forge->addUniqueKey([ "user_id", "code", "name" ], "currencies_user_id_code_name");
$this->forge->processIndexes("currencies");
}

Expand Down

0 comments on commit f7551d1

Please sign in to comment.