Add project and data model
This commit is contained in:
@@ -6,6 +6,8 @@ mod m20220101_000001_users;
|
||||
|
||||
mod m20241029_235230_skills;
|
||||
mod m20241030_002154_jobs;
|
||||
mod m20241030_024340_projects;
|
||||
mod m20241030_024830_data;
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -13,6 +15,8 @@ impl MigratorTrait for Migrator {
|
||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||
vec![
|
||||
// inject-below
|
||||
Box::new(m20241030_024830_data::Migration),
|
||||
Box::new(m20241030_024340_projects::Migration),
|
||||
Box::new(m20241030_002154_jobs::Migration),
|
||||
Box::new(m20241029_235230_skills::Migration),
|
||||
Box::new(m20220101_000001_users::Migration),
|
||||
|
49
migration/src/m20241030_024340_projects.rs
Normal file
49
migration/src/m20241030_024340_projects.rs
Normal file
@@ -0,0 +1,49 @@
|
||||
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(Projects::Table)
|
||||
.col(pk_auto(Projects::Id))
|
||||
.col(string(Projects::Name))
|
||||
.col(string(Projects::Technology))
|
||||
.col(string(Projects::ShortDescription))
|
||||
.col(string_null(Projects::Description))
|
||||
.col(string(Projects::Category))
|
||||
.col(string_null(Projects::GithubUrl))
|
||||
.col(string_null(Projects::DownloadUrl))
|
||||
.col(string_null(Projects::VisitUrl))
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(Projects::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum Projects {
|
||||
Table,
|
||||
Id,
|
||||
Name,
|
||||
Technology,
|
||||
ShortDescription,
|
||||
Description,
|
||||
Category,
|
||||
GithubUrl,
|
||||
DownloadUrl,
|
||||
VisitUrl,
|
||||
|
||||
}
|
||||
|
||||
|
37
migration/src/m20241030_024830_data.rs
Normal file
37
migration/src/m20241030_024830_data.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
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(Data::Table)
|
||||
.col(pk_auto(Data::Id))
|
||||
.col(string(Data::FileUrl))
|
||||
.col(boolean(Data::Protected))
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(Data::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum Data {
|
||||
Table,
|
||||
Id,
|
||||
FileUrl,
|
||||
Protected,
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user