Add note scaffold

This commit is contained in:
2026-07-26 14:45:55 +03:00
parent e376ed950b
commit d640ce35b6
20 changed files with 604 additions and 8 deletions
+3 -1
View File
@@ -3,6 +3,7 @@
pub use sea_orm_migration::prelude::*;
mod m20220101_000001_users;
mod m20260726_113842_notes;
pub struct Migrator;
#[async_trait::async_trait]
@@ -10,7 +11,8 @@ impl MigratorTrait for Migrator {
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
vec![
Box::new(m20220101_000001_users::Migration),
Box::new(m20260726_113842_notes::Migration),
// inject-above (do not remove this comment)
]
}
}
}
@@ -0,0 +1,27 @@
use loco_rs::schema::*;
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
create_table(m, "notes",
&[
("id", ColType::PkAuto),
("title", ColType::StringNull),
("content", ColType::TextNull),
],
&[
("user", ""),
]
).await
}
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
drop_table(m, "notes").await
}
}