Update to more generic db models
Some checks failed
Build Crate / build (push) Has been cancelled

Also integrated entities into codebase
This commit is contained in:
2024-08-18 03:26:12 -04:00
parent 5d28013f30
commit 528682d9b1
24 changed files with 314 additions and 419 deletions

View File

@@ -3,23 +3,25 @@ use sea_orm_migration::{prelude::*, schema::*};
#[derive(DeriveMigrationName)]
pub struct Migration;
// https://github.com/SeaQL/sea-orm/blob/368b1126f73f47c7ec30fe523834f6a0962a193b/sea-orm-migration/src/schema.rs
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
// User table
manager
.create_table(
Table::create()
.table(User::Table)
.if_not_exists()
.col(
ColumnDef::new(User::Id)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(pk_auto(User::Id))
.col(string(User::Username))
.col(string(User::Password))
.col(string(User::Salt))
.col(timestamp_with_time_zone(User::CreationTime))
.col(timestamp_with_time_zone(User::LastActiveTime))
.col(boolean(User::IsAdmin))
.col(string_null(User::Email))
.col(string_null(User::Avatar))
.to_owned(),
)
.await
@@ -37,6 +39,11 @@ pub enum User {
Table,
Id,
Username,
// Hash
Password,
Salt,
CreationTime,
LastActiveTime,
IsAdmin,
Email,
Avatar,
}