agentsclimarketplace

Data model

Skill Marycka9/oh-my-claude-obsidian/skills/data-model

Design the data model for a feature and draft staged forward + rollback SQL migrations - an ER diagram, entity/field tables, and paired .up.sql/.down.sql drafts saved to the vault, never to the live repo migrations tree. Use when a feature needs schema design, "data model for X", "draft migrations for X", or before implementing anything that touches the database. Do not use for API contracts (api-contract), general feature docs (obsidian-topic), or applying migrations to a real database.From its SKILL.md

Install
npx -y skills add Marycka9/oh-my-claude-obsidian --skill data-model

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

7.6 KB, as published. Nobody here has run it

data-model

Produces the persistence design for one feature: topics/<Feature> — Data Model.md (ER diagram + entity tables + index justifications) plus draft migration pairs under {base_path}/_scripts/migrations/<feature-slug>/. Drafts live in the vault; the real migration files land in the code repo during implementation, with the real sequence number assigned then. This staging is deliberate: a half-designed schema must never sit where a stray migrate up (CI, a teammate, a deploy) can apply it.

The skill imposes no DB philosophy. It detects the repo's conventions and follows them; migration safety (reversibility, FK indexes, zero-downtime decomposition, no PII in seeds) applies regardless of stack.

Shared references: config-resolution, vault-structure, obsidian-format, hot-md, handoff, self-check.

Arguments

/data-model "Feature Name"
/data-model "Feature Name" brownfield   (delta on an existing schema — default is auto-detected)

Step 1 — Resolve configuration

Per config-resolution. Not initialized -> stop: Run /obsidian-init first. Resolve base_path, language, and the repo root (registry Repo column — needed for convention detection).

Step 2 — Gather inputs (soft prerequisite)

In priority order, read what exists — none of these is a hard gate:

  1. topics/<Feature>.md or the plan topic from /task-planning — entities implied by the plan's steps and acceptance criteria.
  2. A SAD/architecture topic (topics/ with sad/architecture tags) — building blocks that persist data; sequence diagrams whose writes/reads <entity> notes become index candidates (one index per real query).
  3. Related ADRs in decisions/ with data/storage tags.

If none exists, interview instead of refusing: ask (a) which entities the feature owns, (b) which entity is the aggregate root of which, (c) the 2-3 queries that must be fast. Note in the final topic that the model came from an interview, not a plan.

Step 3 — Detect repo conventions (read-only)

Scan the code repo's live migrations directory and schema (never modify anything there). Detect and follow:

TopicHow to decide
Migration tool + file namingFrom existing migration files (sequential vs timestamp; .up/.down vs single-file)
Table/column namingFrom existing DDL
PK strategyUUID / bigint identity / sequence / composite — whatever the repo uses
Audit columns (created_at/updated_at/none)Match the repo's pattern
Delete strategy (hard / soft / status)Match the repo
CHECK / DEFAULT / triggers, string/JSON typesUse them iff the repo does

Greenfield repo with no signal -> confirm each choice with the user (short options, one question block), never default to a house style. Record detected conventions in the topic's "Conventions" section, flagging any deliberate divergence.

Step 4 — Design the model

  • Group entities by aggregate root (unclear ownership -> ask; without explicit aggregates the FK graph becomes a hairball).
  • Columns + constraints per entity, matching Step 3 conventions; bound VARCHAR(N) sizes from validation limits in the plan/AC where stated; mark honestly undecided cells %%TBD%%.
  • Indexes per query: every index row must name the concrete query it serves (from a sequence diagram note or plan step). No "just in case" indexes — each one costs writes.

Step 5 — Write the topic

{base_path}/topics/<Feature> — Data Model.md from templates/data-model-topic.md. Existing file -> update in place (History entry appended), never blind-overwrite.

  • Frontmatter: type: topic, status: active, tags: [topic, data-model, data], related: "[[<Feature topic>]]" (quoted wikilinks per obsidian-format).
  • Mermaid erDiagram: one clean, manually ordered block. Validate before finishing: valid cardinality glyphs (||--o{ etc.), attribute lines as type name, no stray </> or unbalanced quotes in labels.
  • Body in the project's language; SQL, identifiers, and frontmatter stay English.

Step 6 — Draft the migrations (staged in the vault)

Write paired files to {base_path}/_scripts/migrations/<feature-slug>/:

01_create_<entity>.up.sql   01_create_<entity>.down.sql
02_..._.up.sql              02_..._.down.sql

Feature-local ordinals preserve intra-feature order; the real number/timestamp is assigned when the files are promoted into the repo during implementation. Add a _about.md (one line) in the folder: Draft migrations for <Feature>. Promote into the repo's migrations tree during implementation — do not run from here.

Safety rules (applied regardless of stack):

  • A .down.sql for every .up.sql — every CREATE has a DROP, every ADD COLUMN a DROP COLUMN, every CREATE INDEX a DROP INDEX.
  • Idempotent DDL where the tool supports it (IF NOT EXISTS; ON CONFLICT DO NOTHING on seeds).
  • An index on every FK column.
  • Breaking change on an existing table -> expand -> backfill -> contract, as separate ordinal files; flag the backfill SQL for user review.
  • No real-looking PII in seeds — [email protected], Test User.
  • One logical change per pair — never one mega-migration with five ALTERs.

A legitimate outcome is zero migrations (the feature touches only existing tables) — the topic then documents the touched entities and says so.

Step 7 — Integrate

  1. Feature topic link: add [[<Feature> — Data Model]] to the feature topic's related links (and its frontmatter related), so the model is reachable from the feature.
  2. Decisions: a schema choice with blast radius beyond this feature (shared table changed, PK strategy set for the project, soft-delete introduced, a convention divergence) -> propose recording it via /obsidian-decision; do not silently bury it in the topic.
  3. topics/_index.md: add/update the row. Update the registry's Last touched.
  4. Refresh hot.md per hot-md.

Step 8 — Report

Short report: entities designed, indexes with their queries, migration drafts written (paths), conventions detected, any TBDs. Then the handoff block (Next: /api-contract "<Feature>" if the feature has an API surface, else the implementation step) and the self-check line.

Self-check items: frontmatter valid; erDiagram parses; every FK has an index row; every .up.sql has a matching .down.sql; wikilinks resolve; _index.md row present; hot.md under ~500 words.

Anti-patterns

  • Imposing a DB philosophy the repo does not use (forcing UUIDs, forbidding CHECK, adding updated_at to a repo that has none).
  • Writing drafts into the code repo's live migrations/ tree — they go to the vault _scripts/migrations/ only.
  • Indexes without a named query; migrations without rollback; real PII in seeds.
  • Refusing to run because no plan topic exists — interview instead, and say the model is interview-sourced.

Keep looking

Skills are one crate of 607,533. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.