user-auth orm and meili changes

This commit is contained in:
2022-12-29 22:22:04 +05:30
parent 0e357b0d4e
commit ec907e4b5f
20 changed files with 702 additions and 175 deletions

View File

@@ -10,6 +10,26 @@ impl MigrationTrait for Migration {
// Replace the sample below with your own migration scripts
//todo!();
manager
.create_table(
Table::create()
.table(User::Table)
.if_not_exists()
.col(
ColumnDef::new(User::Id)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(User::UserName).string().unique_key().not_null())
.col(ColumnDef::new(User::PasswordHash).string().not_null())
.to_owned(),
)
.await.expect("Migration failed");
manager
.create_table(
Table::create()
@@ -34,6 +54,15 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(Book::TimeAdded).time())
.col(ColumnDef::new(Book::Rating).integer())
.col(ColumnDef::new(Book::Comments).string())
.col(ColumnDef::new(Book::UserId).integer().not_null())
.foreign_key(
ForeignKey::create()
.name("FK_2e303c3a712662f1fc2a4d0aavc")
.from(Book::Table, Book::UserId)
.to(User::Table, User::Id)
.on_delete(ForeignKeyAction::Cascade)
.on_update(ForeignKeyAction::Cascade),
)
.to_owned(),
)
.await.expect("Migration failed");
@@ -246,6 +275,7 @@ enum Book {
TimeAdded,
Rating,
Comments,
UserId
}
#[derive(Iden)]
@@ -295,3 +325,11 @@ enum BookISBN {
ISBN,
BookId,
}
#[derive(Iden)]
enum User {
Table,
Id,
UserName,
PasswordHash,
}