refactor: enforce unique constraints on account and account_category names; update foreign key actions
This commit is contained in:
@@ -12,7 +12,7 @@ impl MigrationTrait for Migration {
|
||||
.table("account_category")
|
||||
.if_not_exists()
|
||||
.col(pk_auto("id").not_null())
|
||||
.col(string("name").not_null())
|
||||
.col(string("name").not_null().unique_key())
|
||||
.col(string("account_type").not_null())
|
||||
.col(string("created_at").not_null())
|
||||
.col(string("updated_at").not_null())
|
||||
@@ -27,7 +27,7 @@ impl MigrationTrait for Migration {
|
||||
.if_not_exists()
|
||||
.col(pk_auto("id").not_null())
|
||||
//
|
||||
.col(string("name").not_null())
|
||||
.col(string("name").not_null().unique_key())
|
||||
.col(integer("account_category_id").not_null())
|
||||
//
|
||||
.col(string("created_at").not_null())
|
||||
@@ -37,7 +37,9 @@ impl MigrationTrait for Migration {
|
||||
ForeignKey::create()
|
||||
.name("fk-account-category")
|
||||
.from("account", "account_category_id")
|
||||
.to("account_category", "id"),
|
||||
.to("account_category", "id")
|
||||
.on_delete(ForeignKeyAction::NoAction)
|
||||
.on_update(ForeignKeyAction::Restrict),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user