init commit
This commit is contained in:
21
migration/src/lib.rs
Normal file
21
migration/src/lib.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
#![allow(elided_lifetimes_in_paths)]
|
||||
#![allow(clippy::wildcard_imports)]
|
||||
pub use sea_orm_migration::prelude::*;
|
||||
|
||||
mod m20220101_000001_users;
|
||||
|
||||
mod m20241029_235230_skills;
|
||||
mod m20241030_002154_jobs;
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigratorTrait for Migrator {
|
||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||
vec![
|
||||
// inject-below
|
||||
Box::new(m20241030_002154_jobs::Migration),
|
||||
Box::new(m20241029_235230_skills::Migration),
|
||||
Box::new(m20220101_000001_users::Migration),
|
||||
]
|
||||
}
|
||||
}
|
50
migration/src/m20220101_000001_users.rs
Normal file
50
migration/src/m20220101_000001_users.rs
Normal 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,
|
||||
}
|
35
migration/src/m20241029_235230_skills.rs
Normal file
35
migration/src/m20241029_235230_skills.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
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> {
|
||||
manager
|
||||
.create_table(
|
||||
table_auto_tz(Skills::Table)
|
||||
.col(pk_auto(Skills::Id))
|
||||
.col(string(Skills::Name))
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(Skills::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum Skills {
|
||||
Table,
|
||||
Id,
|
||||
Name,
|
||||
|
||||
}
|
||||
|
||||
|
45
migration/src/m20241030_002154_jobs.rs
Normal file
45
migration/src/m20241030_002154_jobs.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
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> {
|
||||
manager
|
||||
.create_table(
|
||||
table_auto_tz(Jobs::Table)
|
||||
.col(pk_auto(Jobs::Id))
|
||||
.col(string(Jobs::Position))
|
||||
.col(string(Jobs::Company))
|
||||
.col(date(Jobs::StartDate))
|
||||
.col(date_null(Jobs::EndDate))
|
||||
.col(string(Jobs::Technologies))
|
||||
.col(boolean(Jobs::StillWorking))
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(Jobs::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum Jobs {
|
||||
Table,
|
||||
Id,
|
||||
Position,
|
||||
Company,
|
||||
StartDate,
|
||||
EndDate,
|
||||
Technologies,
|
||||
StillWorking,
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user