Add project and data model

This commit is contained in:
2024-10-30 03:52:26 +01:00
parent ea4942bda1
commit c83c0e7ec4
16 changed files with 234 additions and 4 deletions

View File

@@ -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),

View 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,
}

View 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,
}