fix(db): resolve migration bugs preventing fresh database initialization
- Fix composite primary keys in role_permissions and user_roles tables (PostgreSQL does not allow multiple PRIMARY KEY constraints) - Fix FK table name mismatch: tasks → tokens (was wf_tokens) - Fix FK table name mismatch: messages → message_templates (was message_templates_ref) - Fix tenant table name in main.rs SQL: tenant (not tenants) - Fix React Router nested routes: add /* wildcard for child route matching
This commit is contained in:
@@ -11,18 +11,8 @@ impl MigrationTrait for Migration {
|
||||
Table::create()
|
||||
.table(RolePermissions::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(RolePermissions::RoleId)
|
||||
.uuid()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(RolePermissions::PermissionId)
|
||||
.uuid()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(RolePermissions::RoleId).uuid().not_null())
|
||||
.col(ColumnDef::new(RolePermissions::PermissionId).uuid().not_null())
|
||||
.col(ColumnDef::new(RolePermissions::TenantId).uuid().not_null())
|
||||
.col(
|
||||
ColumnDef::new(RolePermissions::CreatedAt)
|
||||
@@ -49,6 +39,11 @@ impl MigrationTrait for Migration {
|
||||
.not_null()
|
||||
.default(1),
|
||||
)
|
||||
.primary_key(
|
||||
Index::create()
|
||||
.col(RolePermissions::RoleId)
|
||||
.col(RolePermissions::PermissionId),
|
||||
)
|
||||
.foreign_key(
|
||||
&mut ForeignKey::create()
|
||||
.name("fk_role_permissions_role_id")
|
||||
|
||||
@@ -11,18 +11,8 @@ impl MigrationTrait for Migration {
|
||||
Table::create()
|
||||
.table(UserRoles::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(UserRoles::UserId)
|
||||
.uuid()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(UserRoles::RoleId)
|
||||
.uuid()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(UserRoles::UserId).uuid().not_null())
|
||||
.col(ColumnDef::new(UserRoles::RoleId).uuid().not_null())
|
||||
.col(ColumnDef::new(UserRoles::TenantId).uuid().not_null())
|
||||
.col(
|
||||
ColumnDef::new(UserRoles::CreatedAt)
|
||||
@@ -49,6 +39,11 @@ impl MigrationTrait for Migration {
|
||||
.not_null()
|
||||
.default(1),
|
||||
)
|
||||
.primary_key(
|
||||
Index::create()
|
||||
.col(UserRoles::UserId)
|
||||
.col(UserRoles::RoleId),
|
||||
)
|
||||
.foreign_key(
|
||||
&mut ForeignKey::create()
|
||||
.name("fk_user_roles_user_id")
|
||||
|
||||
@@ -108,7 +108,7 @@ impl MigrationTrait for Migration {
|
||||
ForeignKey::create()
|
||||
.name("fk_tasks_token")
|
||||
.from(Tasks::Table, Tasks::TokenId)
|
||||
.to(WfTokens::Table, WfTokens::Id)
|
||||
.to(Tokens::Table, Tokens::Id)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
@@ -154,7 +154,7 @@ enum ProcessInstances {
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum WfTokens {
|
||||
enum Tokens {
|
||||
Table,
|
||||
Id,
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ impl MigrationTrait for Migration {
|
||||
ForeignKey::create()
|
||||
.name("fk_messages_template")
|
||||
.from(Messages::Table, Messages::TemplateId)
|
||||
.to(MessageTemplatesRef::Table, MessageTemplatesRef::Id)
|
||||
.to(MessageTemplates::Table, MessageTemplates::Id)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
@@ -137,7 +137,7 @@ enum Messages {
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum MessageTemplatesRef {
|
||||
enum MessageTemplates {
|
||||
Table,
|
||||
Id,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user