You've already forked flix
Throw away flix files in favor of a flix database
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
use seamantic::schema::sqlite_rowid_alias;
|
||||
|
||||
use sea_orm::sea_query;
|
||||
use sea_orm::sea_query::{ForeignKeyCreateStatement, Table};
|
||||
use sea_orm::{DbErr, Iden};
|
||||
use sea_orm_migration::SchemaManager;
|
||||
use sea_orm_migration::schema::{binary, binary_null, integer, integer_null, string};
|
||||
|
||||
use crate::migration::m_000001::FlixInfoMovies;
|
||||
use crate::migration::m_000003::{FlixCollections, FlixLibraries};
|
||||
|
||||
#[derive(Iden)]
|
||||
pub enum FlixMovies {
|
||||
Table,
|
||||
Id,
|
||||
Parent,
|
||||
Slug,
|
||||
Library,
|
||||
Directory,
|
||||
RelativeMediaPath,
|
||||
RelativePosterPath,
|
||||
}
|
||||
|
||||
pub async fn up(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(FlixMovies::Table)
|
||||
.col(sqlite_rowid_alias(FlixMovies::Id))
|
||||
.col(integer_null(FlixMovies::Parent))
|
||||
.col(string(FlixMovies::Slug))
|
||||
.col(integer(FlixMovies::Library))
|
||||
.col(binary(FlixMovies::Directory))
|
||||
.col(binary(FlixMovies::RelativeMediaPath))
|
||||
.col(binary_null(FlixMovies::RelativePosterPath))
|
||||
.foreign_key(
|
||||
ForeignKeyCreateStatement::new()
|
||||
.name("fk-flix_movies-id")
|
||||
.from_tbl(FlixMovies::Table)
|
||||
.from_col(FlixMovies::Id)
|
||||
.to_tbl(FlixInfoMovies::Table)
|
||||
.to_col(FlixInfoMovies::Id),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKeyCreateStatement::new()
|
||||
.name("fk-flix_movies-parent")
|
||||
.from_tbl(FlixMovies::Table)
|
||||
.from_col(FlixMovies::Parent)
|
||||
.to_tbl(FlixCollections::Table)
|
||||
.to_col(FlixCollections::Id),
|
||||
)
|
||||
.foreign_key(
|
||||
ForeignKeyCreateStatement::new()
|
||||
.name("fk-flix_movies-library")
|
||||
.from_tbl(FlixMovies::Table)
|
||||
.from_col(FlixMovies::Library)
|
||||
.to_tbl(FlixLibraries::Table)
|
||||
.to_col(FlixLibraries::Id),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn down(manager: &SchemaManager<'_>) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(FlixMovies::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
Reference in New Issue
Block a user