This commit is contained in:
2022-10-22 16:46:45 +05:30
parent 44f9a8b15f
commit 2143923ee8
20 changed files with 409 additions and 229 deletions

View File

@@ -38,32 +38,6 @@ impl MigrationTrait for Migration {
)
.await;
manager
.create_table(
Table::create()
.table(BookAuthor::Table)
.if_not_exists()
.col(
ColumnDef::new(BookAuthor::Id)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(BookAuthor::AuthorName).string().not_null())
.col(ColumnDef::new(BookAuthor::BookId).integer().not_null())
.foreign_key(
ForeignKey::create()
.name("FK_2e303c3a712662f1fc2a4d0aad6")
.from(BookAuthor::Table, BookAuthor::BookId)
.to(Book::Table, Book::Id)
.on_delete(ForeignKeyAction::Cascade)
.on_update(ForeignKeyAction::Cascade),
)
.to_owned(),
)
.await;
manager
.create_table(
Table::create()
@@ -192,6 +166,32 @@ impl MigrationTrait for Migration {
)
.to_owned(),
)
.await;
manager
.create_table(
Table::create()
.table(BookISBN::Table)
.if_not_exists()
.col(
ColumnDef::new(BookISBN::Id)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(BookISBN::ISBN).string().not_null())
.col(ColumnDef::new(BookISBN::BookId).integer().not_null())
.foreign_key(
ForeignKey::create()
.name("FK_2e303c3a712662f1fc2a4d0aae0")
.from(BookISBN::Table, BookISBN::BookId)
.to(Book::Table, Book::Id)
.on_delete(ForeignKeyAction::Cascade)
.on_update(ForeignKeyAction::Cascade),
)
.to_owned(),
)
.await
}
@@ -216,6 +216,9 @@ impl MigrationTrait for Migration {
.await;
manager
.drop_table(Table::drop().table(BookTime::Table).to_owned())
.await;
manager
.drop_table(Table::drop().table(BookISBN::Table).to_owned())
.await
}
}
@@ -235,6 +238,7 @@ enum Book {
//Place,
//Subject,
//Time,
//ISBN,
GoodreadId,
Description,
Cover,
@@ -283,3 +287,11 @@ enum BookTime {
Time,
BookId,
}
#[derive(Iden)]
enum BookISBN {
Table,
Id,
ISBN,
BookId,
}