From: Olaf Wintermann Date: Mon, 6 Jul 2026 18:13:55 +0000 (+0200) Subject: add Note nodename X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=HEAD;p=note.git add Note nodename --- diff --git a/application/src/note.rs b/application/src/note.rs index de2a512..817a186 100644 --- a/application/src/note.rs +++ b/application/src/note.rs @@ -244,6 +244,7 @@ impl Note { let note = entity::note::ActiveModel { note_id: note_id.clone(), collection_id: Set(self.collection_id), + nodename: Set(title.clone()), // TODO: create unique nodename kind: Set(self.kind.clone()), title: Set(title), lastmodified: Set(Utc::now().into()), diff --git a/entity/src/note.rs b/entity/src/note.rs index 82831da..86ec50a 100644 --- a/entity/src/note.rs +++ b/entity/src/note.rs @@ -8,6 +8,7 @@ pub struct Model { #[sea_orm(primary_key)] pub note_id: i32, pub collection_id: i32, + pub nodename: String, pub kind: NoteType, pub title: String, @@ -36,6 +37,7 @@ impl Model { Model { note_id: 0, collection_id: 0, + nodename: "".to_string(), kind: Default::default(), title: Default::default(), lastmodified: Default::default(), diff --git a/migration/src/m20260502_184134_create_settings.rs b/migration/src/m20260502_184134_create_settings.rs index 89b54b3..49effd2 100644 --- a/migration/src/m20260502_184134_create_settings.rs +++ b/migration/src/m20260502_184134_create_settings.rs @@ -71,6 +71,7 @@ impl MigrationTrait for Migration { .if_not_exists() .col(pk_auto("note_id")) .col(integer("collection_id")) + .col(string("nodename")) .col(integer("kind")) .col(string("title")) .col(timestamp_with_time_zone("lastmodified")) @@ -79,6 +80,16 @@ impl MigrationTrait for Migration { .to_owned() ).await?; + manager.create_index( + Index::create() + .name("index-note-name") + .table("note") + .col(Note::CollectionId) + .col(Note::NodeName) + .unique() + .to_owned() + ).await?; + manager .create_table( Table::create() @@ -100,6 +111,8 @@ impl MigrationTrait for Migration { } async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .drop_index(Index::drop().name("index-note-name").table("note").to_owned()).await?; manager .drop_table(Table::drop().table("note_content").to_owned()).await?; manager @@ -113,3 +126,9 @@ impl MigrationTrait for Migration { .await } } + +#[derive(Iden)] +enum Note { + CollectionId, + NodeName +} \ No newline at end of file