use sea_orm_migration::prelude::*; use crate::m20260616_000001_create_users::Users; #[derive(DeriveMigrationName)] pub struct Migration; #[async_trait::async_trait] impl MigrationTrait for Migration { async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { manager .create_table( Table::create() .table(AuthSession::Table) .if_not_exists() .col( ColumnDef::new(AuthSession::Id) .integer() .not_null() .auto_increment() .primary_key(), ) .col(ColumnDef::new(AuthSession::IdUser).integer().not_null()) .col(ColumnDef::new(AuthSession::Value).string()) .foreign_key( ForeignKey::create() .from(AuthSession::Table, AuthSession::IdUser) .to(Users::Table, Users::Id), ) .to_owned(), ) .await } async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { manager .drop_table(Table::drop().table(AuthSession::Table).to_owned()) .await } } #[derive(Iden)] pub enum AuthSession { Table, Id, IdUser, Value, }