[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EVYQXW4A11NFP06PAAS34Y":3,"skill-same:01M7EVYQXW4A11NFP06PAAS34Y":46},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":29,"ownerDescription":30,"updatedAt":31,"install":32,"resources":45},"01M7EVYQXW4A11NFP06PAAS34Y","update-schema",null,"Update the LMFDB database schema across ALL affected files for the hecke\u002FClifford-Bianchi codebase. Use this skill whenever the user wants to add, remove, or modify columns, table definitions, storage paths, label schemes, or LMFDB object attributes — even if they just say \"add X to the schema\" or \"schema needs a column for Y\". Touches schema.md, package-LMFDB.mag, package-IO.mag, db_schema_staging.sql, db_schema_lmfdb.sql, db_load.py, and db_migrate.py to keep everything in sync. After editing, commits and pushes via the claude-commit skill.","tdupu\u002Fagent-skills-public","tdupu","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F3440403?v=4","01M7EV32X9J0EFE5T4P8TKQTCQ","Taylor Dupuy","01M7EV32XZ1Z4MDBYAFRCJD3BP",0,"GPL-3.0","https:\u002F\u002Fgithub.com\u002Ftdupu\u002Fagent-skills-public\u002Fblob\u002Fmain\u002Fskills\u002Fupdate-schema\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: update-schema\ndescription: Update the LMFDB database schema across ALL affected files for the hecke\u002FClifford-Bianchi codebase. Use this skill whenever the user wants to add, remove, or modify columns, table definitions, storage paths, label schemes, or LMFDB object attributes — even if they just say \"add X to the schema\" or \"schema needs a column for Y\". Touches schema.md, package-LMFDB.mag, package-IO.mag, db_schema_staging.sql, db_schema_lmfdb.sql, db_load.py, and db_migrate.py to keep everything in sync. After editing, commits and pushes via the claude-commit skill.\n---\n\n## Dependency check\n\n```bash\nCONF=\"\"\nfor candidate in \\\n    \"$(git rev-parse --show-toplevel 2>\u002Fdev\u002Fnull)\u002Flmfdb-pipeline.conf\" \\\n    \"magma\u002Fscripts\u002Fdata-generation.conf\"; do\n  [ -f \"$candidate\" ] && { CONF=\"$candidate\"; break; }\ndone\nif [ -z \"$CONF\" ]; then\n  echo \"I'm sorry, I can't do that — no database pipeline conf found.\"\n  echo \"Run \u002Fconfigure-database (mathcity-lmfdb.configure-database) to create lmfdb-pipeline.conf at your project root.\"\n  echo \"(This conf holds your PostgreSQL and DATA_DIR settings for the LMFDB pipeline.)\"\n  exit 1\nfi\nsource \"$CONF\"\n```\n\n## Overview\n\nA schema change touches **seven files** that must all stay in sync. This skill walks through every one. Never update just `schema.md` in isolation — a column added to the documentation but missing from `package-IO.mag` or `db_load.py` will silently break serialization or loading.\n\n## Step 0 — Parse the instructions\n\nThe user will describe what to change. Common cases:\n- Adding or removing a column on an existing LMFDB type\n- Adding a new LMFDB object type (see `create-lmfdb-type` skill for full scaffolding)\n- Changing a label scheme or storage path\n- Fixing documentation, examples, or **Not implemented** annotations\n\nClarify before proceeding if:\n- The **column type** is ambiguous (Text \u002F Integer \u002F Bool \u002F Jsonb)\n- The **LMFDB type name** is unclear (e.g. which `*_ATTRS` list it belongs to)\n- The change touches `db_migrate.py` INSERT\u002FUPDATE logic in a non-obvious way\n\n## Step 1 — Read all affected files\n\nRead these in parallel before making any edits:\n\n1. `magma\u002Fschema.md`\n2. `magma\u002Fpackage-LMFDB.mag` — type declaration and `*_ATTRS` list\n3. `magma\u002Fpackage-IO.mag` — `TextCols`, `IntegerCols`, `BoolCols`, `JsonbCols` at the top\n4. `magma\u002Fpython\u002Fdb_schema_staging.sql`\n5. `magma\u002Fpython\u002Fdb_schema_lmfdb.sql`\n6. `magma\u002Fpython\u002Fdb_load.py` — `*_ATTRS` Python lists and `_TEXT_COLS` \u002F `_INTEGER_COLS` \u002F `_BOOL_COLS` sets\n7. `magma\u002Fpython\u002Fdb_migrate.py` — INSERT column lists and ON CONFLICT SET clauses\n\n## Step 2 — Apply changes to each file\n\nWork through every file below. For each one, note what changed and why.\n\n---\n\n### 2a. `magma\u002Fschema.md`\n\n- **Tables**: GitHub-flavored pipe-delimited markdown. Columns: `Column | Type | Example | Notes`. Align pipes.\n- **Section order**: Orders → Clifford Bianchi Groups → Gamma0 Subgroups → Hecke Matrices → Low Index Subgroups → Modular Forms → Conjugate Intersections → Label Scheme\n- **Storage paragraphs**: bold `**Storage:**` prefix, path pattern, one-file-per-object vs multi-line, concrete example path.\n- **Section separators**: `---` horizontal rule between every section.\n- **Not implemented** notes: italicized or bold if columns are defined but not yet coded.\n\n---\n\n### 2b. `magma\u002Fpackage-LMFDB.mag`\n\nLocate the `declare attributes LMFDBXXX` block and the corresponding `LMFDBXXX_ATTRS` list for the type being changed.\n\n**Adding a column:**\n1. Add the attribute name to the `declare attributes` block (alphabetical order).\n2. Add the attribute name to the `Sort([...])` in `LMFDBXXX_ATTRS`. The comment `\u002F\u002FALWAYS ALPHABETICAL!` must remain.\n3. If the attribute can be absent (optional\u002Fnullable), update `load_lmfdb_xxx` to handle `\\N` (the backward-compat pattern: check `#data eq #attrs - 1` and insert `\"\\\\N\"` at the right position).\n4. Update `create_lmfdb_xxx` to populate the new attribute.\n\n**Removing a column:**\n1. Remove from `declare attributes` and from `LMFDBXXX_ATTRS`.\n2. Remove from `load_lmfdb_xxx` (no special handling needed — the field will no longer be read).\n3. Remove from `create_lmfdb_xxx`.\n\n**Critical invariants:**\n- `ATTRS` must be `Sort([...])` — never hand-sort.\n- Every name in `declare attributes` must appear in `ATTRS` and vice versa.\n- Never edit `.sig` files.\n\n---\n\n### 2c. `magma\u002Fpackage-IO.mag`\n\nThe column type lists at the top of the file drive `LoadAttr`\u002F`SaveAttr` dispatch. Add or remove the attribute name from exactly one of:\n\n| List           | Use for                                      |\n|----------------|----------------------------------------------|\n| `TextCols`     | `MonStgElt` — always includes `label`        |\n| `IntegerCols`  | `RngIntElt`                                  |\n| `BoolCols`     | `BoolElt` — serialized as `t`\u002F`f`            |\n| `JsonbCols`    | Sequences, nested lists, Clifford matrices   |\n\nEach list is a `Sort([...])` call — keep it sorted. Do NOT create new column type lists.\n\n---\n\n### 2d. `magma\u002Fpython\u002Fdb_schema_staging.sql`\n\nLocate the `CREATE TABLE IF NOT EXISTS staging.\u003Ctype>_src` block. Add or remove the column with the correct PostgreSQL type:\n\n| Magma column type | PostgreSQL type |\n|-------------------|-----------------|\n| TextCols          | `text`          |\n| IntegerCols       | `integer`       |\n| BoolCols          | `boolean`       |\n| JsonbCols         | `jsonb`         |\n\nColumn order in SQL should match the alphabetical `*_ATTRS` order (for readability — SQL doesn't require it, but it helps). The comment `-- Column order matches LMFDBXXX_ATTRS` must stay accurate.\n\n---\n\n### 2e. `magma\u002Fpython\u002Fdb_schema_lmfdb.sql`\n\nLocate the `CREATE TABLE IF NOT EXISTS lmfdb.clifford_\u003Ctype>` block. Apply the same column addition\u002Fremoval with the same PostgreSQL types. Note: some column names differ from Magma (e.g. `order` → `order_label_old` to avoid the SQL reserved word).\n\n---\n\n### 2f. `magma\u002Fpython\u002Fdb_load.py`\n\nTwo places to update:\n\n1. **`*_ATTRS` list** (e.g. `ORDERS_ATTRS`, `GAMMA0_ATTRS`): add\u002Fremove the attribute name inside the `sorted([...])` call. Must exactly match `package-LMFDB.mag`.\n\n2. **Column type sets** (`_TEXT_COLS`, `_INTEGER_COLS`, `_BOOL_COLS`): add\u002Fremove the attribute name from the matching frozenset. JsonbCols attributes need no entry here — they are the default COPY path.\n\nIf a legacy compat format exists (e.g. `SUBGROUPS_ATTRS_LEGACY`), decide whether it also needs updating; usually legacy formats are frozen.\n\n---\n\n### 2g. `magma\u002Fpython\u002Fdb_migrate.py`\n\nLocate the `INSERT INTO lmfdb.clifford_\u003Ctype>` block(s) in `promote_to_lmfdb`. Three things to keep in sync:\n\n1. **INSERT column list** — add\u002Fremove the column name.\n2. **SELECT column list** (the `SELECT ... FROM staging.\u003Ctype>_src` that feeds it) — add\u002Fremove the same name (or its alias if renamed).\n3. **ON CONFLICT DO UPDATE SET** clause — add\u002Fremove `\u003Ccol> = EXCLUDED.\u003Ccol>`.\n\n---\n\n## Step 3 — Legacy data streams (read-only)\n\nThe `magma\u002FDATA\u002Fdata-legacy-01\u002F` directory tree contains old data that does not match the current schema. Each legacy subdirectory has a `SCHEMA` file at its root (and sometimes per-subdirectory `SCHEMA` files) that document the field layout of *that specific frozen format*.\n\n**Never modify these `SCHEMA` files.** They are the authoritative record of how legacy data was serialized and are required for migrating that data into the current database format. They describe the old format, not the aspirational one.\n\nThe `magma\u002Fschema.md` file is the **aspirational \u002F official** schema — what the current codebase targets. The legacy `SCHEMA` files describe **historical snapshots** used by `db_load.py`'s legacy compat paths (e.g. `SUBGROUPS_ATTRS_LEGACY`). When the official schema changes, the legacy SCHEMA files and legacy ATTRS lists in `db_load.py` stay frozen.\n\nWhen adding a new column: the new column will be absent from legacy files — `db_load.py` must continue to handle the old field count via its existing compat logic (inserting `r\"\\N\"` at the new column's position). Do not assume legacy files will be regenerated.\n\n---\n\n## Step 4 — Migrate affected data files\n\nAfter updating the code files, find all DATA\u002F flat files whose format has changed and archive + regenerate them.\n\n### 4a. Identify affected files\n\nFor each table that gained or lost columns, determine which DATA\u002F directory holds its flat files:\n\n| Table                    | DATA\u002F path pattern                            |\n|--------------------------|-----------------------------------------------|\n| `LMFDBCliffOrd`          | `DATA\u002Forders\u002F\u003Calg_label>`                     |\n| `LMFDBGrpSL2Cliff`       | `DATA\u002Fsl2\u002F\u003Calg_label>`                        |\n| `LMFDBGrpSL2CliffGamma0` | `DATA\u002Fgamma0\u002F\u003Cord_label>\u002F\u003Cgamma0_label>`       |\n| `LMFDBPSL2GrpCliffSub`   | `DATA\u002Fsubgroups\u002F\u003Cord_label>\u002F\u003Csub_label>`       |\n\nCheck whether any files exist for each affected type:\n```bash\nls magma\u002FDATA\u002F\u003Ctype_dir>\u002F\n```\n\nIf the directory is empty or absent, skip to Step 5.\n\n### 4b. Archive old files\n\nMove the outdated files into a dated legacy folder so they are preserved (not deleted). Use the date format `mm-dd-yyyy`:\n\n```bash\nmkdir -p magma\u002FDATA\u002Fdata-legacy-\u003Cmm-dd-yyyy>\u002F\u003Ctype_dir>\u002F\nmv magma\u002FDATA\u002F\u003Ctype_dir>\u002F* magma\u002FDATA\u002Fdata-legacy-\u003Cmm-dd-yyyy>\u002F\u003Ctype_dir>\u002F\n```\n\nWrite a `SCHEMA` file at the top of the new legacy directory documenting the old field layout — field names in order, the ATTRS list commit reference or date, and field types. This is the frozen record of the old format.\n\nExample `SCHEMA` content:\n```\n# Schema: data-legacy-\u003Cmm-dd-yyyy>\u002F\u003Ctype_dir>\u002F\n\nArchived \u003Cdate>. Format preceding addition of \u003Cnew_columns>.\nCorresponds to \u003CTypeName>_ATTRS before this change.\n\n## Field layout (N fields, pipe-delimited)\n\n| # | Field name     | Type    |\n|---|----------------|---------|\n| 1 | field1         | jsonb   |\n...\n```\n\n### 4c. Regenerate files with null entries\n\nFor each archived file, reload the objects and re-emit them with `\\N` for every new nullable column.\n\n**Preferred approach — Magma script:**\nWrite a `make\u002Fupdate-\u003Ctype>-\u003CN>.mag` script that:\n1. Reads the archived file line by line using `load_lmfdb_\u003Ctype>`\n2. For each object, sets the new attribute(s) to the appropriate null\u002Fempty default (see column type defaults below)\n3. Re-saves with `write_lmfdb_\u003Ctype>` (or `print_file`) to the live `DATA\u002F\u003Ctype_dir>\u002F` path\n\n**Column-type null defaults:**\n| Column type | Magma default before saving | Serialized as |\n|-------------|----------------------------|---------------|\n| TextCols    | `\"\"` (empty string → skip assignment) | `\\N` |\n| IntegerCols | not assigned (→ `Get` returns `None()`) | `\\N` |\n| BoolCols    | not assigned | `\\N` |\n| JsonbCols   | not assigned | `\\N` |\n\nThe key: `SaveLMFDBObject` calls `Get(X, attr)` which returns `None()` for unset attributes, and `SaveAttr` serializes `None()` as `\\N`. So simply do not assign the new attribute when re-creating the object from old data.\n\n**Alternative — Python one-liner** (for simple column additions where the ATTRS order is known):\n```python\n# insert \\N at position idx (0-based) in each pipe-delimited line\nfor line in open(\"old_file\"):\n    parts = line.rstrip(\"\\n\").split(\"|\")\n    parts.insert(idx, r\"\\N\")\n    print(\"|\".join(parts))\n```\n\n### 4d. Reload into staging database\n\nAfter regenerating the files, run `\u002Ftextfile-to-database` (or the `textfile-to-database` skill) to reload the updated files into the staging tables:\n\n```bash\ncd magma\u002Fpython\npython3 db_load.py --data-root ..\u002FDATA --only \u003Ctype>\n```\n\nVerify the new columns are present and contain `NULL`:\n```sql\nSELECT COUNT(*) FROM staging.\u003Ctype>_src WHERE \u003Cnew_col> IS NOT NULL;\n-- should be 0 for freshly-null columns\n```\n\n---\n\n## Step 5 — Verify consistency\n\nAfter all edits, do a quick cross-check:\n\n- Column appears in `schema.md` ↔ `package-LMFDB.mag` ATTRS ↔ `package-IO.mag` type list ↔ both SQL files ↔ `db_load.py` ATTRS and type set ↔ `db_migrate.py` INSERT\u002FSELECT\u002FUPDATE.\n- Archived files are in `DATA\u002Fdata-legacy-\u003Cmm-dd-yyyy>\u002F` with a `SCHEMA` file.\n- New DATA\u002F files have `\\N` for all new columns.\n- Legacy `SCHEMA` files in `data-legacy-01\u002F` and `*_ATTRS_LEGACY` lists in `db_load.py` are untouched.\n- No `.sig` files were touched.\n- `Sort([...])` and `\u002F\u002FALWAYS ALPHABETICAL!` comment intact in `package-LMFDB.mag`.\n\n---\n\n## Step 6 — Commit and push\n\nInvoke the `claude-commit` skill. The commit message body should name every file changed and describe what column\u002Ftype was added\u002Fremoved\u002Fmodified and why. Include a note that data files were archived to `data-legacy-\u003Cmm-dd-yyyy>\u002F`.\n","## Dependency check\n\n```bash\nCONF=\"\"\nfor candidate in \\\n    \"$(git rev-parse --show-toplevel 2>\u002Fdev\u002Fnull)\u002Flmfdb-pipeline.conf\" \\\n    \"magma\u002Fscripts\u002Fdata-generation.conf\"; do\n  [ -f \"$candidate\" ] && { CONF=\"$candidate\"; break; }\ndone\nif [ -z \"$CONF\" ]; then\n  echo \"I'm sorry, I can't do that — no database pipeline conf found.\"\n  echo \"Run \u002Fconfigure-database (mathcity-lmfdb.configure-database) to create lmfdb-pipeline.conf at your project root.\"\n  echo \"(This conf holds your PostgreSQL and DATA_DIR settings for the LMFDB pipeline.)\"\n  exit 1\nfi\nsource \"$CONF\"\n```\n\n## Overview\n\nA schema change touches **seven files** that must all stay in sync. This skill walks through every one. Never update just `schema.md` in isolation — a column added to the documentation but missing from `package-IO.mag` or `db_load.py` will silently break serialization or loading.\n\n## Step 0 — Parse the instructions\n\nThe user will describe what to change. Common cases:\n- Adding or removing a column on an existing LMFDB type\n- Adding a new LMFDB object type (see `create-lmfdb-type` skill for full scaffolding)\n- Changing a label scheme or storage path\n- Fixing documentation, examples, or **Not implemented** annotations\n\nClarify before proceeding if:\n- The **column type** is ambiguous (Text \u002F Integer \u002F Bool \u002F Jsonb)\n- The **LMFDB type name** is unclear (e.g. which `*_ATTRS` list it belongs to)\n- The change touches `db_migrate.py` INSERT\u002FUPDATE logic in a non-obvious way\n\n## Step 1 — Read all affected files\n\nRead these in parallel before making any edits:\n\n1. `magma\u002Fschema.md`\n2. `magma\u002Fpackage-LMFDB.mag` — type declaration and `*_ATTRS` list\n3. `magma\u002Fpackage-IO.mag` — `TextCols`, `IntegerCols`, `BoolCols`, `JsonbCols` at the top\n4. `magma\u002Fpython\u002Fdb_schema_staging.sql`\n5. `magma\u002Fpython\u002Fdb_schema_lmfdb.sql`\n6. `magma\u002Fpython\u002Fdb_load.py` — `*_ATTRS` Python lists and `_TEXT_COLS` \u002F `_INTEGER_COLS` \u002F `_BOOL_COLS` sets\n7. `magma\u002Fpython\u002Fdb_migrate.py` — INSERT column lists and ON CONFLICT SET clauses\n\n## Step 2 — Apply changes to each file\n\nWork through every file below. For each one, note what changed and why.\n\n---\n\n### 2a. `magma\u002Fschema.md`\n\n- **Tables**: GitHub-flavored pipe-delimited markdown. Columns: `Column | Type | Example | Notes`. Align pipes.\n- **Section order**: Orders → Clifford Bianchi Groups → Gamma0 Subgroups → Hecke Matrices → Low Index Subgroups → Modular Forms → Conjugate Intersections → Label Scheme\n- **Storage paragraphs**: bold `**Storage:**` prefix, path pattern, one-file-per-object vs multi-line, concrete example path.\n- **Section separators**: `---` horizontal rule between every section.\n- **Not implemented** notes: italicized or bold if columns are defined but not yet coded.\n\n---\n\n### 2b. `magma\u002Fpackage-LMFDB.mag`\n\nLocate the `declare attributes LMFDBXXX` block and the corresponding `LMFDBXXX_ATTRS` list for the type being changed.\n\n**Adding a column:**\n1. Add the attribute name to the `declare attributes` block (alphabetical order).\n2. Add the attribute name to the `Sort([...])` in `LMFDBXXX_ATTRS`. The comment `\u002F\u002FALWAYS ALPHABETICAL!` must remain.\n3. If the attribute can be absent (optional\u002Fnullable), update `load_lmfdb_xxx` to handle `\\N` (the backward-compat pattern: check `#data eq #attrs - 1` and insert `\"\\\\N\"` at the right position).\n4. Update `create_lmfdb_xxx` to populate the new attribute.\n\n**Removing a column:**\n1. Remove from `declare attributes` and from `LMFDBXXX_ATTRS`.\n2. Remove from `load_lmfdb_xxx` (no special handling needed — the field will no longer be read).\n3. Remove from `create_lmfdb_xxx`.\n\n**Critical invariants:**\n- `ATTRS` must be `Sort([...])` — never hand-sort.\n- Every name in `declare attributes` must appear in `ATTRS` and vice versa.\n- Never edit `.sig` files.\n\n---\n\n### 2c. `magma\u002Fpackage-IO.mag`\n\nThe column type lists at the top of the file drive `LoadAttr`\u002F`SaveAttr` dispatch. Add or remove the attribute name from exactly one of:\n\n| List           | Use for                                      |\n|----------------|----------------------------------------------|\n| `TextCols`     | `MonStgElt` — always includes `label`        |\n| `IntegerCols`  | `RngIntElt`                                  |\n| `BoolCols`     | `BoolElt` — serialized as `t`\u002F`f`            |\n| `JsonbCols`    | Sequences, nested lists, Clifford matrices   |\n\nEach list is a `Sort([...])` call — keep it sorted. Do NOT create new column type lists.\n\n---\n\n### 2d. `magma\u002Fpython\u002Fdb_schema_staging.sql`\n\nLocate the `CREATE TABLE IF NOT EXISTS staging.\u003Ctype>_src` block. Add or remove the column with the correct PostgreSQL type:\n\n| Magma column type | PostgreSQL type |\n|-------------------|-----------------|\n| TextCols          | `text`          |\n| IntegerCols       | `integer`       |\n| BoolCols          | `boolean`       |\n| JsonbCols         | `jsonb`         |\n\nColumn order in SQL should match the alphabetical `*_ATTRS` order (for readability — SQL doesn't require it, but it helps). The comment `-- Column order matches LMFDBXXX_ATTRS` must stay accurate.\n\n---\n\n### 2e. `magma\u002Fpython\u002Fdb_schema_lmfdb.sql`\n\nLocate the `CREATE TABLE IF NOT EXISTS lmfdb.clifford_\u003Ctype>` block. Apply the same column addition\u002Fremoval with the same PostgreSQL types. Note: some column names differ from Magma (e.g. `order` → `order_label_old` to avoid the SQL reserved word).\n\n---\n\n### 2f. `magma\u002Fpython\u002Fdb_load.py`\n\nTwo places to update:\n\n1. **`*_ATTRS` list** (e.g. `ORDERS_ATTRS`, `GAMMA0_ATTRS`): add\u002Fremove the attribute name inside the `sorted([...])` call. Must exactly match `package-LMFDB.mag`.\n\n2. **Column type sets** (`_TEXT_COLS`, `_INTEGER_COLS`, `_BOOL_COLS`): add\u002Fremove the attribute name from the matching frozenset. JsonbCols attributes need no entry here — they are the default COPY path.\n\nIf a legacy compat format exists (e.g. `SUBGROUPS_ATTRS_LEGACY`), decide whether it also needs updating; usually legacy formats are frozen.\n\n---\n\n### 2g. `magma\u002Fpython\u002Fdb_migrate.py`\n\nLocate the `INSERT INTO lmfdb.clifford_\u003Ctype>` block(s) in `promote_to_lmfdb`. Three things to keep in sync:\n\n1. **INSERT column list** — add\u002Fremove the column name.\n2. **SELECT column list** (the `SELECT ... FROM staging.\u003Ctype>_src` that feeds it) — add\u002Fremove the same name (or its alias if renamed).\n3. **ON CONFLICT DO UPDATE SET** clause — add\u002Fremove `\u003Ccol> = EXCLUDED.\u003Ccol>`.\n\n---\n\n## Step 3 — Legacy data streams (read-only)\n\nThe `magma\u002FDATA\u002Fdata-legacy-01\u002F` directory tree contains old data that does not match the current schema. Each legacy subdirectory has a `SCHEMA` file at its root (and sometimes per-subdirectory `SCHEMA` files) that document the field layout of *that specific frozen format*.\n\n**Never modify these `SCHEMA` files.** They are the authoritative record of how legacy data was serialized and are required for migrating that data into the current database format. They describe the old format, not the aspirational one.\n\nThe `magma\u002Fschema.md` file is the **aspirational \u002F official** schema — what the current codebase targets. The legacy `SCHEMA` files describe **historical snapshots** used by `db_load.py`'s legacy compat paths (e.g. `SUBGROUPS_ATTRS_LEGACY`). When the official schema changes, the legacy SCHEMA files and legacy ATTRS lists in `db_load.py` stay frozen.\n\nWhen adding a new column: the new column will be absent from legacy files — `db_load.py` must continue to handle the old field count via its existing compat logic (inserting `r\"\\N\"` at the new column's position). Do not assume legacy files will be regenerated.\n\n---\n\n## Step 4 — Migrate affected data files\n\nAfter updating the code files, find all DATA\u002F flat files whose format has changed and archive + regenerate them.\n\n### 4a. Identify affected files\n\nFor each table that gained or lost columns, determine which DATA\u002F directory holds its flat files:\n\n| Table                    | DATA\u002F path pattern                            |\n|--------------------------|-----------------------------------------------|\n| `LMFDBCliffOrd`          | `DATA\u002Forders\u002F\u003Calg_label>`                     |\n| `LMFDBGrpSL2Cliff`       | `DATA\u002Fsl2\u002F\u003Calg_label>`                        |\n| `LMFDBGrpSL2CliffGamma0` | `DATA\u002Fgamma0\u002F\u003Cord_label>\u002F\u003Cgamma0_label>`       |\n| `LMFDBPSL2GrpCliffSub`   | `DATA\u002Fsubgroups\u002F\u003Cord_label>\u002F\u003Csub_label>`       |\n\nCheck whether any files exist for each affected type:\n```bash\nls magma\u002FDATA\u002F\u003Ctype_dir>\u002F\n```\n\nIf the directory is empty or absent, skip to Step 5.\n\n### 4b. Archive old files\n\nMove the outdated files into a dated legacy folder so they are preserved (not deleted). Use the date format `mm-dd-yyyy`:\n\n```bash\nmkdir -p magma\u002FDATA\u002Fdata-legacy-\u003Cmm-dd-yyyy>\u002F\u003Ctype_dir>\u002F\nmv magma\u002FDATA\u002F\u003Ctype_dir>\u002F* magma\u002FDATA\u002Fdata-legacy-\u003Cmm-dd-yyyy>\u002F\u003Ctype_dir>\u002F\n```\n\nWrite a `SCHEMA` file at the top of the new legacy directory documenting the old field layout — field names in order, the ATTRS list commit reference or date, and field types. This is the frozen record of the old format.\n\nExample `SCHEMA` content:\n```\n# Schema: data-legacy-\u003Cmm-dd-yyyy>\u002F\u003Ctype_dir>\u002F\n\nArchived \u003Cdate>. Format preceding addition of \u003Cnew_columns>.\nCorresponds to \u003CTypeName>_ATTRS before this change.\n\n## Field layout (N fields, pipe-delimited)\n\n| # | Field name     | Type    |\n|---|----------------|---------|\n| 1 | field1         | jsonb   |\n...\n```\n\n### 4c. Regenerate files with null entries\n\nFor each archived file, reload the objects and re-emit them with `\\N` for every new nullable column.\n\n**Preferred approach — Magma script:**\nWrite a `make\u002Fupdate-\u003Ctype>-\u003CN>.mag` script that:\n1. Reads the archived file line by line using `load_lmfdb_\u003Ctype>`\n2. For each object, sets the new attribute(s) to the appropriate null\u002Fempty default (see column type defaults below)\n3. Re-saves with `write_lmfdb_\u003Ctype>` (or `print_file`) to the live `DATA\u002F\u003Ctype_dir>\u002F` path\n\n**Column-type null defaults:**\n| Column type | Magma default before saving | Serialized as |\n|-------------|----------------------------|---------------|\n| TextCols    | `\"\"` (empty string → skip assignment) | `\\N` |\n| IntegerCols | not assigned (→ `Get` returns `None()`) | `\\N` |\n| BoolCols    | not assigned | `\\N` |\n| JsonbCols   | not assigned | `\\N` |\n\nThe key: `SaveLMFDBObject` calls `Get(X, attr)` which returns `None()` for unset attributes, and `SaveAttr` serializes `None()` as `\\N`. So simply do not assign the new attribute when re-creating the object from old data.\n\n**Alternative — Python one-liner** (for simple column additions where the ATTRS order is known):\n```python\n# insert \\N at position idx (0-based) in each pipe-delimited line\nfor line in open(\"old_file\"):\n    parts = line.rstrip(\"\\n\").split(\"|\")\n    parts.insert(idx, r\"\\N\")\n    print(\"|\".join(parts))\n```\n\n### 4d. Reload into staging database\n\nAfter regenerating the files, run `\u002Ftextfile-to-database` (or the `textfile-to-database` skill) to reload the updated files into the staging tables:\n\n```bash\ncd magma\u002Fpython\npython3 db_load.py --data-root ..\u002FDATA --only \u003Ctype>\n```\n\nVerify the new columns are present and contain `NULL`:\n```sql\nSELECT COUNT(*) FROM staging.\u003Ctype>_src WHERE \u003Cnew_col> IS NOT NULL;\n-- should be 0 for freshly-null columns\n```\n\n---\n\n## Step 5 — Verify consistency\n\nAfter all edits, do a quick cross-check:\n\n- Column appears in `schema.md` ↔ `package-LMFDB.mag` ATTRS ↔ `package-IO.mag` type list ↔ both SQL files ↔ `db_load.py` ATTRS and type set ↔ `db_migrate.py` INSERT\u002FSELECT\u002FUPDATE.\n- Archived files are in `DATA\u002Fdata-legacy-\u003Cmm-dd-yyyy>\u002F` with a `SCHEMA` file.\n- New DATA\u002F files have `\\N` for all new columns.\n- Legacy `SCHEMA` files in `data-legacy-01\u002F` and `*_ATTRS_LEGACY` lists in `db_load.py` are untouched.\n- No `.sig` files were touched.\n- `Sort([...])` and `\u002F\u002FALWAYS ALPHABETICAL!` comment intact in `package-LMFDB.mag`.\n\n---\n\n## Step 6 — Commit and push\n\nInvoke the `claude-commit` skill. The commit message body should name every file changed and describe what column\u002Ftype was added\u002Fremoved\u002Fmodified and why. Include a note that data files were archived to `data-legacy-\u003Cmm-dd-yyyy>\u002F`.\n",{"name":5,"description":7},"main","8d13efb5e66306aeae6e3b948bc463e7e2db1b65","skills\u002Fupdate-schema","https:\u002F\u002Fgithub.com\u002Ftdupu\u002Fagent-skills-public","https:\u002F\u002Fgithub.com\u002Ftdupu","https:\u002F\u002Ftdupu.github.io\u002Findex.html","Associate Professor, Department of Mathematics and Statistics, University of Vermont --- last updated Fall 2019","2026-11-13 09:07:19",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add tdupu\u002Fagent-skills-public --skill update-schema",{"tool":38,"command":39},"bunx","bunx skills add tdupu\u002Fagent-skills-public --skill update-schema",{"tool":41,"command":42},"pnpm","pnpm dlx skills add tdupu\u002Fagent-skills-public --skill update-schema","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Ftdupu\u002Fagent-skills-public\u002Fblob\u002Fmain\u002Fskills\u002Fupdate-schema\u002FSKILL.md",true,[],[47,54,61,68,75,82],{"skillNo":48,"name":49,"nameZh":6,"description":50,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":51,"categories":52,"keywords":53,"publishedAt":19},"01M7EW4PT586KKE7VRCAD80Z9K","writing-skills","Use when creating new skills, editing existing skills, or verifying skills work before deployment","https:\u002F\u002Fgithub.com\u002Ftdupu\u002Fagent-skills-public\u002Fblob\u002Fmain\u002Fsuperpowers\u002Fskills\u002Fwriting-skills\u002FSKILL.md",[],[],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M7EW4HV5V74AF3PTV8N4T0PS","writing-plans","Use when you have a spec or requirements for a multi-step task, before touching code","https:\u002F\u002Fgithub.com\u002Ftdupu\u002Fagent-skills-public\u002Fblob\u002Fmain\u002Fsuperpowers\u002Fskills\u002Fwriting-plans\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M7EW4DNKGP5CR1RAJP2J9PHA","verification-before-completion","Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always","https:\u002F\u002Fgithub.com\u002Ftdupu\u002Fagent-skills-public\u002Fblob\u002Fmain\u002Fsuperpowers\u002Fskills\u002Fverification-before-completion\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M7EW4BA2QP88VBFVXDVJM7XQ","using-superpowers","Use when starting any conversation - establishes how to find and use skills, requiring skill invocation before ANY response including clarifying questions","https:\u002F\u002Fgithub.com\u002Ftdupu\u002Fagent-skills-public\u002Fblob\u002Fmain\u002Fsuperpowers\u002Fskills\u002Fusing-superpowers\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M7EW47F2JG5FBESDJNP3PKMV","using-git-worktrees","Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback","https:\u002F\u002Fgithub.com\u002Ftdupu\u002Fagent-skills-public\u002Fblob\u002Fmain\u002Fsuperpowers\u002Fskills\u002Fusing-git-worktrees\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M7EW44N8556Y556NX9HJT4KP","test-driven-development","Use when implementing any feature or bugfix, before writing implementation code","https:\u002F\u002Fgithub.com\u002Ftdupu\u002Fagent-skills-public\u002Fblob\u002Fmain\u002Fsuperpowers\u002Fskills\u002Ftest-driven-development\u002FSKILL.md",[],[]]