removing rbac cos its not needed at all
This commit is contained in:
@@ -10,6 +10,8 @@ mod m20260517_000005_audio_albums;
|
||||
mod m20260517_000006_audio_tracks;
|
||||
mod m20260517_000007_audio_tags;
|
||||
mod m20260517_000008_audio_track_tags;
|
||||
mod m20260517_000009_simple_constraints;
|
||||
mod m20260517_000010_drop_user_roles;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
@@ -26,6 +28,8 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20260517_000006_audio_tracks::Migration),
|
||||
Box::new(m20260517_000007_audio_tags::Migration),
|
||||
Box::new(m20260517_000008_audio_track_tags::Migration),
|
||||
Box::new(m20260517_000009_simple_constraints::Migration),
|
||||
Box::new(m20260517_000010_drop_user_roles::Migration),
|
||||
// inject-above (do not remove this comment)
|
||||
]
|
||||
}
|
||||
|
||||
60
migration/src/m20260517_000009_simple_constraints.rs
Normal file
60
migration/src/m20260517_000009_simple_constraints.rs
Normal file
@@ -0,0 +1,60 @@
|
||||
use sea_orm_migration::{prelude::*, sea_orm::ConnectionTrait};
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum AudioTrackTags {
|
||||
Table,
|
||||
TagId,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||
if matches!(
|
||||
m.get_database_backend(),
|
||||
sea_orm_migration::sea_orm::DatabaseBackend::Postgres
|
||||
) {
|
||||
m.get_connection()
|
||||
.execute_unprepared(
|
||||
"ALTER TABLE users \
|
||||
ADD CONSTRAINT chk_users_theme \
|
||||
CHECK (theme IN ('light', 'dark'))",
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
m.create_index(
|
||||
Index::create()
|
||||
.name("idx-audio_track_tags-tag_id")
|
||||
.table(AudioTrackTags::Table)
|
||||
.col(AudioTrackTags::TagId)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||
m.drop_index(
|
||||
Index::drop()
|
||||
.name("idx-audio_track_tags-tag_id")
|
||||
.table(AudioTrackTags::Table)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
if matches!(
|
||||
m.get_database_backend(),
|
||||
sea_orm_migration::sea_orm::DatabaseBackend::Postgres
|
||||
) {
|
||||
m.get_connection()
|
||||
.execute_unprepared("ALTER TABLE users DROP CONSTRAINT chk_users_theme")
|
||||
.await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
28
migration/src/m20260517_000010_drop_user_roles.rs
Normal file
28
migration/src/m20260517_000010_drop_user_roles.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum UserRoles {
|
||||
Table,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||
m.drop_table(
|
||||
Table::drop()
|
||||
.table(UserRoles::Table)
|
||||
.if_exists()
|
||||
.cascade()
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn down(&self, _m: &SchemaManager) -> Result<(), DbErr> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user