use sea_orm_migration::prelude::*;

#[derive(DeriveMigrationName)]
pub struct Migration;

#[derive(DeriveIden)]
enum AudioTrackTags {
    Table,
}
#[derive(DeriveIden)]
enum AudioTracks {
    Table,
}
#[derive(DeriveIden)]
enum AudioTags {
    Table,
}
#[derive(DeriveIden)]
enum AudioAlbums {
    Table,
}

#[async_trait::async_trait]
impl MigrationTrait for Migration {
    async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
        // Drop child tables before parents to satisfy foreign keys.
        m.drop_table(Table::drop().table(AudioTrackTags::Table).if_exists().to_owned())
            .await?;
        m.drop_table(Table::drop().table(AudioTracks::Table).if_exists().to_owned())
            .await?;
        m.drop_table(Table::drop().table(AudioTags::Table).if_exists().to_owned())
            .await?;
        m.drop_table(Table::drop().table(AudioAlbums::Table).if_exists().to_owned())
            .await?;
        Ok(())
    }

    async fn down(&self, _m: &SchemaManager) -> Result<(), DbErr> {
        // The music domain has been retired; recreating it is out of scope.
        Ok(())
    }
}
