user-auth orm and meili changes
This commit is contained in:
@@ -13,7 +13,7 @@ async-std = { version = "^1", features = ["attributes", "tokio1"] }
|
||||
chrono = "0.4"
|
||||
|
||||
[dependencies.sea-orm-migration]
|
||||
version = "^0.9.2"
|
||||
version = "^0.10.6"
|
||||
features = [
|
||||
# Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI.
|
||||
# View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime.
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user