A simple to-do app focused on tasks that can be completed within a specific time span.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add basic todo migration

ToBinio 176e63c1 84782a2c

+219 -4
+2
api/migration/src/lib.rs
··· 2 2 3 3 mod m20260503_093223_add_tag_table; 4 4 mod m20260503_125344_add_category_table; 5 + mod m20260504_125311_add_basic_todo_table; 5 6 6 7 pub struct Migrator; 7 8 ··· 11 12 vec![ 12 13 Box::new(m20260503_093223_add_tag_table::Migration), 13 14 Box::new(m20260503_125344_add_category_table::Migration), 15 + Box::new(m20260504_125311_add_basic_todo_table::Migration), 14 16 ] 15 17 } 16 18 }
+1 -1
api/migration/src/m20260503_093223_add_tag_table.rs
··· 28 28 } 29 29 30 30 #[derive(DeriveIden)] 31 - enum Tag { 31 + pub enum Tag { 32 32 Table, 33 33 Id, 34 34 OwnerId,
+1 -1
api/migration/src/m20260503_125344_add_category_table.rs
··· 29 29 } 30 30 31 31 #[derive(DeriveIden)] 32 - enum Category { 32 + pub enum Category { 33 33 Table, 34 34 Id, 35 35 OwnerId,
+85
api/migration/src/m20260504_125311_add_basic_todo_table.rs
··· 1 + use sea_orm_migration::{prelude::*, schema::*}; 2 + 3 + use crate::{m20260503_093223_add_tag_table::Tag, m20260503_125344_add_category_table::Category}; 4 + 5 + #[derive(DeriveMigrationName)] 6 + pub struct Migration; 7 + 8 + #[async_trait::async_trait] 9 + impl MigrationTrait for Migration { 10 + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { 11 + manager 12 + .create_table( 13 + Table::create() 14 + .table(Todo::Table) 15 + .if_not_exists() 16 + .col(pk_uuid(Todo::Id)) 17 + .col(uuid(Todo::OwnerId)) 18 + .col(string(Todo::Title)) 19 + .col(string(Todo::Note)) 20 + .col(uuid_null(Todo::CategoryId)) 21 + .foreign_key( 22 + ForeignKey::create() 23 + .from(Todo::Table, Todo::CategoryId) 24 + .to(Category::Table, Category::Id) 25 + .on_delete(ForeignKeyAction::SetNull) 26 + .on_update(ForeignKeyAction::Cascade), 27 + ) 28 + .to_owned(), 29 + ) 30 + .await?; 31 + 32 + manager 33 + .create_table( 34 + Table::create() 35 + .table(TodoTag::Table) 36 + .if_not_exists() 37 + .primary_key(Index::create().col(TodoTag::TagId).col(TodoTag::TodoId)) 38 + .col(uuid(TodoTag::TagId)) 39 + .col(uuid(TodoTag::TodoId)) 40 + .foreign_key( 41 + ForeignKey::create() 42 + .from(TodoTag::Table, TodoTag::TagId) 43 + .to(Tag::Table, Tag::Id) 44 + .on_delete(ForeignKeyAction::Cascade) 45 + .on_update(ForeignKeyAction::Cascade), 46 + ) 47 + .foreign_key( 48 + ForeignKey::create() 49 + .from(TodoTag::Table, TodoTag::TodoId) 50 + .to(Todo::Table, Todo::Id) 51 + .on_delete(ForeignKeyAction::Cascade) 52 + .on_update(ForeignKeyAction::Cascade), 53 + ) 54 + .to_owned(), 55 + ) 56 + .await 57 + } 58 + 59 + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { 60 + manager 61 + .drop_table(Table::drop().table(TodoTag::Table).to_owned()) 62 + .await?; 63 + 64 + manager 65 + .drop_table(Table::drop().table(Todo::Table).to_owned()) 66 + .await 67 + } 68 + } 69 + 70 + #[derive(DeriveIden)] 71 + enum Todo { 72 + Table, 73 + Id, 74 + OwnerId, 75 + Title, 76 + Note, 77 + CategoryId, 78 + } 79 + 80 + #[derive(DeriveIden)] 81 + enum TodoTag { 82 + Table, 83 + TodoId, 84 + TagId, 85 + }
+10 -1
api/src/entities/category.rs
··· 14 14 } 15 15 16 16 #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 17 - pub enum Relation {} 17 + pub enum Relation { 18 + #[sea_orm(has_many = "super::todo::Entity")] 19 + Todo, 20 + } 21 + 22 + impl Related<super::todo::Entity> for Entity { 23 + fn to() -> RelationDef { 24 + Relation::Todo.def() 25 + } 26 + } 18 27 19 28 impl ActiveModelBehavior for ActiveModel {}
+2
api/src/entities/mod.rs
··· 4 4 5 5 pub mod category; 6 6 pub mod tag; 7 + pub mod todo; 8 + pub mod todo_tag;
+2
api/src/entities/prelude.rs
··· 2 2 3 3 pub use super::category::Entity as Category; 4 4 pub use super::tag::Entity as Tag; 5 + pub use super::todo::Entity as Todo; 6 + pub use super::todo_tag::Entity as TodoTag;
+19 -1
api/src/entities/tag.rs
··· 13 13 } 14 14 15 15 #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 16 - pub enum Relation {} 16 + pub enum Relation { 17 + #[sea_orm(has_many = "super::todo_tag::Entity")] 18 + TodoTag, 19 + } 20 + 21 + impl Related<super::todo_tag::Entity> for Entity { 22 + fn to() -> RelationDef { 23 + Relation::TodoTag.def() 24 + } 25 + } 26 + 27 + impl Related<super::todo::Entity> for Entity { 28 + fn to() -> RelationDef { 29 + super::todo_tag::Relation::Todo.def() 30 + } 31 + fn via() -> Option<RelationDef> { 32 + Some(super::todo_tag::Relation::Tag.def().rev()) 33 + } 34 + } 17 35 18 36 impl ActiveModelBehavior for ActiveModel {}
+51
api/src/entities/todo.rs
··· 1 + //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20 2 + 3 + use sea_orm::entity::prelude::*; 4 + 5 + #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] 6 + #[sea_orm(table_name = "todo")] 7 + pub struct Model { 8 + #[sea_orm(primary_key, auto_increment = false)] 9 + pub id: Uuid, 10 + pub owner_id: Uuid, 11 + pub title: String, 12 + pub note: String, 13 + pub category_id: Option<Uuid>, 14 + } 15 + 16 + #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 17 + pub enum Relation { 18 + #[sea_orm( 19 + belongs_to = "super::category::Entity", 20 + from = "Column::CategoryId", 21 + to = "super::category::Column::Id", 22 + on_update = "Cascade", 23 + on_delete = "SetNull" 24 + )] 25 + Category, 26 + #[sea_orm(has_many = "super::todo_tag::Entity")] 27 + TodoTag, 28 + } 29 + 30 + impl Related<super::category::Entity> for Entity { 31 + fn to() -> RelationDef { 32 + Relation::Category.def() 33 + } 34 + } 35 + 36 + impl Related<super::todo_tag::Entity> for Entity { 37 + fn to() -> RelationDef { 38 + Relation::TodoTag.def() 39 + } 40 + } 41 + 42 + impl Related<super::tag::Entity> for Entity { 43 + fn to() -> RelationDef { 44 + super::todo_tag::Relation::Tag.def() 45 + } 46 + fn via() -> Option<RelationDef> { 47 + Some(super::todo_tag::Relation::Todo.def().rev()) 48 + } 49 + } 50 + 51 + impl ActiveModelBehavior for ActiveModel {}
+46
api/src/entities/todo_tag.rs
··· 1 + //! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.20 2 + 3 + use sea_orm::entity::prelude::*; 4 + 5 + #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] 6 + #[sea_orm(table_name = "todo_tag")] 7 + pub struct Model { 8 + #[sea_orm(primary_key, auto_increment = false)] 9 + pub tag_id: Uuid, 10 + #[sea_orm(primary_key, auto_increment = false)] 11 + pub todo_id: Uuid, 12 + } 13 + 14 + #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] 15 + pub enum Relation { 16 + #[sea_orm( 17 + belongs_to = "super::tag::Entity", 18 + from = "Column::TagId", 19 + to = "super::tag::Column::Id", 20 + on_update = "Cascade", 21 + on_delete = "Cascade" 22 + )] 23 + Tag, 24 + #[sea_orm( 25 + belongs_to = "super::todo::Entity", 26 + from = "Column::TodoId", 27 + to = "super::todo::Column::Id", 28 + on_update = "Cascade", 29 + on_delete = "Cascade" 30 + )] 31 + Todo, 32 + } 33 + 34 + impl Related<super::tag::Entity> for Entity { 35 + fn to() -> RelationDef { 36 + Relation::Tag.def() 37 + } 38 + } 39 + 40 + impl Related<super::todo::Entity> for Entity { 41 + fn to() -> RelationDef { 42 + Relation::Todo.def() 43 + } 44 + } 45 + 46 + impl ActiveModelBehavior for ActiveModel {}