zettelkasten.organizations_migration¶
zettelkasten.organizations_migration ¶
Lazy, one-time migration of legacy review tables into organizations.
The review-table MIGRATION logic extracted verbatim from
:mod:zettelkasten.organizations (Phase 3 structural decomposition). This is a
behavior-preserving relocation: every function keeps its exact signature and
body, and :mod:zettelkasten.organizations re-exports each name so all existing
zettelkasten.organizations.<name> import (and monkeypatch) paths keep working
unchanged.
Shared core helpers (paths, validation, normalization, IO, markers) live in
:mod:zettelkasten.organizations; every one is referenced through the _org
module alias at CALL TIME (_org.<name>) rather than a frozen
from zettelkasten.organizations import <name> value-binding, so a
monkeypatch.setattr(organizations, '<name>', ...) on ANY shared helper —
not just a curated few — is honored inside the moved functions here. Only
symbols DEFINED in this module are referenced directly.
ensure_migrated ¶
Import legacy review tables for this owner into organizations (idempotent).
For every review whose scope matches (owner_type, owner_name) and which has
NOT been absorbed yet (per the per-owner marker), each of its persisted tables
becomes a lens organization carrying that table's row axis + columns. The
review name is then recorded in the marker, so a subsequent call is a no-op and
a user deleting a migrated org never resurrects it.
Returns the number of organizations created.
Source code in zettelkasten/organizations_migration.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | |
migrate_all ¶
Upgrade an entire existing store: import every review's tables into orgs.
Walks all review manifests, derives each one's owner, and runs the per-owner
:func:ensure_migrated once per distinct owner. Safe to run repeatedly — it
is idempotent (the per-owner marker makes re-runs no-ops) and non-destructive
(legacy _reviews/*.tables.json files are read, never modified or removed).
Returns {"<owner_type>/<owner_name>": orgs_created} for each owner touched.
Use this to migrate an old directory eagerly; otherwise migration happens
lazily the first time an owner is listed.