]> uap-core.de Git - note.git/commitdiff
add Note nodename main
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 6 Jul 2026 18:13:55 +0000 (20:13 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 6 Jul 2026 18:13:55 +0000 (20:13 +0200)
application/src/note.rs
entity/src/note.rs
migration/src/m20260502_184134_create_settings.rs

index de2a512bb188a88c3b2664811673d897d908a100..817a1869305b056f76880965397388bd39e71c79 100644 (file)
@@ -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()),
index 82831da581eea15f3e56541dca0c8bce1ce61c27..86ec50a63ea9109f2c572180511392632be6c25e 100644 (file)
@@ -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(),
index 89b54b34805a11143645c477353773331946a0f8..49effd2ba80950a5441ab0b531789980620a8a93 100644 (file)
@@ -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