My personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities.
2
fork

Configure Feed

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

feat: remove path column from zettel table

+41 -70
+4 -4
.config/config.ron
··· 1 1 ( 2 2 directory: "/Users/suri/dev/projects/filaments/ZettelKasten", 3 3 global_key_binds: { 4 + "down": MoveDown, 4 5 "up": MoveUp, 5 - "ctrl-c": Quit, 6 6 "ctrl-z": Suspend, 7 - "down": MoveDown, 7 + "ctrl-c": Quit, 8 8 }, 9 9 zk: ( 10 10 keybinds: { 11 - "enter": OpenZettel, 12 11 "tab": SwitchTo( 13 12 region: Todo, 14 13 ), 15 14 "<Ctrl-n>": NewZettel, 15 + "enter": OpenZettel, 16 16 }, 17 17 ), 18 18 todo: ( 19 19 keybinds: { 20 - "k": MoveUp, 21 20 "j": MoveDown, 21 + "k": MoveUp, 22 22 "tab": SwitchTo( 23 23 region: Zk, 24 24 ),
+1
.harper-dictionary.txt
··· 6 6 dir 7 7 env 8 8 eyre 9 + zettel
+2
crates/dto/migration/src/lib.rs
··· 7 7 mod m20260323_002518_zettel_table; 8 8 mod m20260327_175853_tag_table; 9 9 mod m20260327_180618_zettel_tag_table; 10 + mod m20260406_200424_remove_path_from_zettel; 10 11 11 12 pub struct Migrator; 12 13 ··· 19 20 Box::new(m20260323_002518_zettel_table::Migration), 20 21 Box::new(m20260327_175853_tag_table::Migration), 21 22 Box::new(m20260327_180618_zettel_tag_table::Migration), 23 + Box::new(m20260406_200424_remove_path_from_zettel::Migration), 22 24 ] 23 25 } 24 26 }
+31
crates/dto/migration/src/m20260406_200424_remove_path_from_zettel.rs
··· 1 + use sea_orm_migration::{prelude::*, schema::*}; 2 + 3 + use crate::m20260323_002518_zettel_table::Zettel; 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 + .alter_table( 13 + Table::alter() 14 + .table(Zettel::Table) 15 + .drop_column(Zettel::FilePath) 16 + .to_owned(), 17 + ) 18 + .await 19 + } 20 + 21 + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { 22 + manager 23 + .alter_table( 24 + Table::alter() 25 + .table(Zettel::Table) 26 + .add_column(string(Zettel::FilePath).not_null()) 27 + .to_owned(), 28 + ) 29 + .await 30 + } 31 + }
-1
crates/dto/src/entity/zettel.rs
··· 15 15 #[sea_orm(unique)] 16 16 pub nano_id: NanoId, 17 17 pub title: String, 18 - pub file_path: String, 19 18 pub created_at: DateTime, 20 19 pub modified_at: DateTime, 21 20 #[sea_orm(has_one)]
-2
crates/dto/tests/task.rs
··· 13 13 14 14 let group_zettel: ZettelModel = ZettelActiveModel { 15 15 title: Set("Something".to_owned()), 16 - file_path: Set("/voo/doo".to_owned()), 17 16 ..Default::default() 18 17 } 19 18 .insert(&db) ··· 33 32 let task_zettel: ZettelModel = ZettelActiveModel { 34 33 // nano_id: Set(NanoId::default()), 35 34 title: Set("nomething".to_owned()), 36 - file_path: Set("/voo/doo".to_owned()), 37 35 ..Default::default() 38 36 } 39 37 .insert(&db)
-3
crates/dto/tests/zettel.rs
··· 22 22 let _: ZettelModel = ZettelActiveModel { 23 23 // nano_id: Set(NanoId::default()), 24 24 title: Set("something1".to_owned()), 25 - file_path: Set("/voo/doo".to_owned()), 26 25 ..Default::default() 27 26 } 28 27 .insert(&db) ··· 31 30 32 31 let x = ZettelActiveModel::builder() 33 32 .set_title("Hello") 34 - .set_file_path("/voo/doo") 35 33 // .add_tag( 36 34 // TagActiveModel::builder() 37 35 // .set_name("Hi") ··· 46 44 let _: ZettelModel = ZettelActiveModel { 47 45 // nano_id: Set(NanoId::default()), 48 46 title: Set("nomething2".to_owned()), 49 - file_path: Set("/voo/doo".to_owned()), 50 47 ..Default::default() 51 48 } 52 49 .insert(&db)
-55
src/types/index.rs
··· 188 188 pub fn sync_with_db(&self, _db: &DatabaseConnection) { 189 189 todo!() 190 190 } 191 - 192 - //NOTE: we dont support links just yet 193 - // fn parse_links(src: &ZettelId, body: Body) -> Result<Vec<Link>> { 194 - // let parsed = Parser::new(&body); 195 - 196 - // let mut links = vec![]; 197 - 198 - // for event in parsed { 199 - // if let Event::Start(MkTag::Link { dest_url, .. }) = event { 200 - // info!("Found dest_url: {dest_url:#?}"); 201 - 202 - // let dest_path = { 203 - // // remove leading "./" 204 - // let without_prefix = dest_url.strip_prefix("./").unwrap_or(&dest_url); 205 - 206 - // // remove "#" and everything after it 207 - // let without_anchor = without_prefix.split('#').next().unwrap(); 208 - 209 - // // add .md if not present 210 - // let normalized = if std::path::Path::new(without_anchor) 211 - // .extension() 212 - // .is_some_and(|ext| ext.eq_ignore_ascii_case("md")) 213 - // { 214 - // without_anchor.to_string() 215 - // } else { 216 - // format!("{without_anchor}.md") 217 - // }; 218 - 219 - // let mut tmp_root = self 220 - // .zods 221 - // .get(src) 222 - // .expect("Invariant Broken! src must exist inside index") 223 - // .path 224 - // .clone(); 225 - // tmp_root.push(normalized); 226 - // tmp_root 227 - // }; 228 - // // simplest way to validate that the path exists 229 - // let Ok(canon_url) = dest_path.canonicalize() else { 230 - // error!("Link not found!: {dest_path:?}"); 231 - // continue; 232 - // }; 233 - 234 - // // TODO: check that the thing actually exists inside the ws.db 235 - // // instead of just seeing if we can turn it into a ZettelId 236 - // let dst_id = ZettelId::try_from(canon_url)?; 237 - 238 - // let link = Link::new(src.clone(), dst_id); 239 - 240 - // links.push(link); 241 - // } 242 - // } 243 - 244 - // Ok(links) 245 - // } 246 191 }
+3 -5
src/types/zettel/mod.rs
··· 1 - use std::path::{Path, PathBuf}; 1 + use std::path::Path; 2 2 3 3 use dto::{ 4 4 DatabaseConnection, DateTime, TagEntity, ZettelActiveModel, ZettelEntity, ZettelModelEx, ··· 25 25 _private: (), 26 26 pub id: ZettelId, 27 27 pub title: String, 28 - /// a workspace-local file path, needs to be canonicalized before usage 29 - pub file_path: PathBuf, 30 28 pub created_at: DateTime, 31 29 pub modified_at: DateTime, 32 30 pub tags: Vec<Tag>, ··· 64 62 65 63 let inserted = ZettelActiveModel::builder() 66 64 .set_title(title.clone()) 67 - .set_file_path(local_file_path) 68 65 .set_nano_id(nano_id) 69 66 .insert(&kt.db) 70 67 .await?; ··· 113 110 &idx.get_zod(&self.id).path 114 111 } 115 112 113 + /// Get the formatted creation datetime for this `Zettel` 116 114 pub fn created_at(&self) -> String { 117 115 self.created_at 118 116 .format(frontmatter::DATE_FMT_STR) 119 117 .to_string() 120 118 } 121 119 120 + /// Get the formatted modified datetime for this `Zettel` 122 121 pub fn modified_at(&self) -> String { 123 122 self.modified_at 124 123 .format(frontmatter::DATE_FMT_STR) ··· 138 137 _private: (), 139 138 id: value.nano_id.into(), 140 139 title: value.title, 141 - file_path: value.file_path.into(), 142 140 created_at: value.created_at, 143 141 modified_at: value.modified_at, 144 142 tags: value.tags.into_iter().map(Into::into).collect(),