mirror of
https://github.com/CloudNebulaProject/barycenter.git
synced 2026-04-10 13:10:42 +00:00
fix: Rename device_code table to device_codes
The DeriveIden macro converted DeviceCode to device_code (singular), but the SeaORM entity expects device_codes (plural). Adds a migration to rename the table so queries match. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
204c2958a8
commit
dd3dd4ef31
2 changed files with 30 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ mod m20250107_000001_add_passkeys;
|
||||||
mod m20250107_000002_extend_sessions_users;
|
mod m20250107_000002_extend_sessions_users;
|
||||||
mod m20250108_000001_add_consent_table;
|
mod m20250108_000001_add_consent_table;
|
||||||
mod m20250109_000001_add_device_codes;
|
mod m20250109_000001_add_device_codes;
|
||||||
|
mod m20250222_000001_rename_device_code_table;
|
||||||
|
|
||||||
pub struct Migrator;
|
pub struct Migrator;
|
||||||
|
|
||||||
|
|
@ -17,6 +18,7 @@ impl MigratorTrait for Migrator {
|
||||||
Box::new(m20250107_000002_extend_sessions_users::Migration),
|
Box::new(m20250107_000002_extend_sessions_users::Migration),
|
||||||
Box::new(m20250108_000001_add_consent_table::Migration),
|
Box::new(m20250108_000001_add_consent_table::Migration),
|
||||||
Box::new(m20250109_000001_add_device_codes::Migration),
|
Box::new(m20250109_000001_add_device_codes::Migration),
|
||||||
|
Box::new(m20250222_000001_rename_device_code_table::Migration),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
28
migration/src/m20250222_000001_rename_device_code_table.rs
Normal file
28
migration/src/m20250222_000001_rename_device_code_table.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
use sea_orm_migration::prelude::*;
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
// Rename device_code -> device_codes to match the SeaORM entity table_name
|
||||||
|
manager
|
||||||
|
.rename_table(
|
||||||
|
Table::rename()
|
||||||
|
.table(Alias::new("device_code"), Alias::new("device_codes"))
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.rename_table(
|
||||||
|
Table::rename()
|
||||||
|
.table(Alias::new("device_codes"), Alias::new("device_code"))
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue