From f1bc87e3ad97dc0ef3e5734f106f6418b1d612e1 Mon Sep 17 00:00:00 2001 From: Kristian <10348902@pm.me> Date: Sat, 30 May 2026 13:12:22 +0200 Subject: [PATCH] feat: add cfm model and migration (#43) * custom fe matter migration * add custom_fe_matter --- core/models/custom_frontmatter.go | 27 +++++++++++++++++++ .../migrations/004_custom_frontmatter.sql | 9 +++++++ 2 files changed, 36 insertions(+) create mode 100644 core/models/custom_frontmatter.go create mode 100644 persistence/migrations/004_custom_frontmatter.sql diff --git a/core/models/custom_frontmatter.go b/core/models/custom_frontmatter.go new file mode 100644 index 0000000..69f8dab --- /dev/null +++ b/core/models/custom_frontmatter.go @@ -0,0 +1,27 @@ +package models + +type CustomFronMatter struct { + nodeID string + key string + value string +} + +func NewCustomFrontMatter(nodeID, key, value string) *CustomFronMatter { + return &CustomFronMatter{ + nodeID: nodeID, + key: key, + value: value, + } +} + +func (cfm *CustomFronMatter) NodeID() string { + return cfm.nodeID +} + +func (cfm *CustomFronMatter) Key() string { + return cfm.key +} + +func (cfm *CustomFronMatter) Value() string { + return cfm.value +} diff --git a/persistence/migrations/004_custom_frontmatter.sql b/persistence/migrations/004_custom_frontmatter.sql new file mode 100644 index 0000000..30fb316 --- /dev/null +++ b/persistence/migrations/004_custom_frontmatter.sql @@ -0,0 +1,9 @@ +CREATE TABLE custom_frontmatter( + note_id TEXT, + key TEXT, + value TEXT, + PRIMARY KEY (note_id, key, value), + FOREIGN KEY (note_id) REFERENCES note(id) ON DELETE CASCADE +); + +CREATE INDEX IF NOT EXISTS idx_cfe_key_value on custom_frontmatter(key, value);