···11use sea_orm_migration::{prelude::*, schema::*};
2233-use crate::types::{NANO_ID_LEN, NanoId, Priority};
33+use crate::{
44+ m20260323_002518_zettel_table::Zettel,
55+ types::{NANO_ID_LEN, Priority},
66+};
4758#[derive(DeriveMigrationName)]
69pub struct Migration;
···1821 string(Group::NanoId)
1922 .string_len(NANO_ID_LEN as u32)
2023 .unique_key()
2121- .not_null()
2222- .default(NanoId::default().0),
2424+ .not_null(),
2325 )
2426 .col(string(Group::Name).not_null())
2527 //Note: Color is a hex color with the leading #
2628 .col(string(Group::Color).not_null())
2727- .col(string(Group::DescriptionPath).not_null())
2829 .col(
2930 string(Group::Priority)
3031 .not_null()
···3233 )
3334 .col(timestamp(Group::CreatedAt).default(Expr::current_timestamp()))
3435 .col(timestamp(Group::ModifiedAt).default(Expr::current_timestamp()))
3636+ .col(string(Group::ZettelId).not_null().unique_key())
3737+ // foreign key for the zettel related to this group
3838+ .foreign_key(
3939+ ForeignKey::create()
4040+ .name("fk_task_zettel_id")
4141+ .from(Group::Table, Group::ZettelId)
4242+ .to(Zettel::Table, Zettel::NanoId)
4343+ .on_update(ForeignKeyAction::Cascade)
4444+ .on_delete(ForeignKeyAction::Cascade),
4545+ )
3546 .col(string_null(Group::ParentGroupId))
4747+ // foreign key for the parent group related to this group
3648 .foreign_key(
3749 ForeignKey::create()
3850 .name("fk_group_parent_id") // unique constraint name
···90102 /// Priority level of the group
91103 Priority,
921049393- /// The relative file path to the location of
9494- /// the description note for this task
9595- DescriptionPath,
105105+ /// The Id of the Zettel created for this Group
106106+ ZettelId,
9610797108 /// Creation time
98109 CreatedAt,