Initialize loco app
Some checks failed
CI / Check Style (push) Successful in 18s
CI / Run Tests (push) Failing after 49s
CI / Run Clippy (push) Successful in 53s

This commit is contained in:
Dylan Knutson
2024-11-30 12:41:45 -08:00
parent 9fe2bd20c7
commit acb33d4730
84 changed files with 8194 additions and 8 deletions

23
migration/Cargo.toml Normal file
View File

@@ -0,0 +1,23 @@
[package]
name = "migration"
version = "0.1.0"
edition = "2021"
publish = false
[lib]
name = "migration"
path = "src/lib.rs"
[dependencies]
async-std = { version = "1", features = ["attributes", "tokio1"] }
loco-rs = { workspace = true }
[dependencies.sea-orm-migration]
version = "1.1.0"
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.
# e.g.
"runtime-tokio-rustls", # `ASYNC_RUNTIME` feature
]

17
migration/src/lib.rs Normal file
View File

@@ -0,0 +1,17 @@
#![allow(elided_lifetimes_in_paths)]
#![allow(clippy::wildcard_imports)]
pub use sea_orm_migration::prelude::*;
mod m20220101_000001_users;
pub struct Migrator;
#[async_trait::async_trait]
impl MigratorTrait for Migrator {
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
vec![
Box::new(m20220101_000001_users::Migration),
// inject-above (do not remove this comment)
]
}
}

View File

@@ -0,0 +1,50 @@
use loco_rs::schema::table_auto_tz;
use sea_orm_migration::{prelude::*, schema::*};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let table = table_auto_tz(Users::Table)
.col(pk_auto(Users::Id))
.col(uuid(Users::Pid))
.col(string_uniq(Users::Email))
.col(string(Users::Password))
.col(string(Users::ApiKey).unique_key())
.col(string(Users::Name))
.col(string_null(Users::ResetToken))
.col(timestamp_with_time_zone_null(Users::ResetSentAt))
.col(string_null(Users::EmailVerificationToken))
.col(timestamp_with_time_zone_null(
Users::EmailVerificationSentAt,
))
.col(timestamp_with_time_zone_null(Users::EmailVerifiedAt))
.to_owned();
manager.create_table(table).await?;
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(Users::Table).to_owned())
.await
}
}
#[derive(Iden)]
pub enum Users {
Table,
Id,
Pid,
Email,
Name,
Password,
ApiKey,
ResetToken,
ResetSentAt,
EmailVerificationToken,
EmailVerificationSentAt,
EmailVerifiedAt,
}