Skip to content

docs(migrate): finalize in-store migration with dry_run=False - #319

Open
dimitri-yatsenko wants to merge 5 commits into
mainfrom
docs/1698-migrate-014-external
Open

dimitri-yatsenko wants to merge 5 commits into
mainfrom
docs/1698-migrate-014-external

Conversation

@dimitri-yatsenko

@dimitri-yatsenko dimitri-yatsenko commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Summary

The migration guide's in-store steps did not lead to columns that DataJoint 2.0 reads. Option B finalized with migrate_external(schema, finalize=True), which runs with the default dry_run=True and changes nothing. Option A told readers to run migrate_external_pointers_v2 on a column declared by 2.0, which holds no pre-2.0 pointers. This PR describes both options as the fix in datajoint/datajoint-python#1753 runs them.

Related issue: datajoint/datajoint-python#1698

Changes

  • Option A, step 2: copy_table_data converts blob@store, attach@store, and filepath@store columns as it copies.

    • Each must be declared with the same codec in 2.0, for example <blob@raw>.
    • That store must point to the pre-2.0 location, with the same subfolding if one was set. Leaving subfolding out, or setting it to null as the configuration template does, means the pre-2.0 default [2, 2].
    • Every file is looked up first. A missing file stops the copy with nothing copied.
    • Files are under the name of the database pre-2.0 DataJoint wrote them from. If the source is itself a copy, pass the original name as legacy_database.
    • Keep the default schema_prefix on that store. With schema_prefix: "", the schema-addressed section is the folder that also holds the pre-2.0 files. The guide lists what garbage collection then keeps, the case it does not cover, and says to preview with dry_run=True.
  • Option A, step 4: tables copied in step 2 need no further step. migrate_external_pointers_v2 converts one column of a table still in the pre-2.0 layout. It swaps in a JSON column and keeps the original as <name>_v1. A column already declared by 2.0 is refused.

    • The copied-schema route is spelled out: create_parallel_schema('my_pipeline', 'my_pipeline_copy', copy_data=True), then migrate_external_pointers_v2(..., legacy_database='my_pipeline'), or Option B on the copy with migrate_external(..., legacy_database='my_pipeline').
  • Option B, step 4:

    • Finalize with dry_run=False.
    • Configure each store under its pre-2.0 name and location, with the default schema_prefix and the same subfolding if one was set (null means the default).
    • On a copy of the schema, pass legacy_database to migrate_external.
    • The previews for migrate_external and migrate_filepath both print the files that cannot be found.
    • A preview looks the files up, so the stores must be configured and reachable. This is one request per file on S3.
    • A failure drops the _v2 columns the run added. Finalize checks the _v2 columns first and keeps required columns required.
    • Recovery: readers who ran this step with an earlier 2.x release rerun it with the current release. It rewrites _v2 columns that do not read, and repairs columns already finalized.
    • Repair cannot restore NOT NULL, which the earlier release's finalize dropped. The guide gives the SQL statement that restores it, and says why alter() cannot do it while the <name>_v1 columns remain.
  • Garbage collection guide: a new "Root-Level Layout" section. Both pages state the same behavior, which matches the gc.py docstring in fix(migrate): 0.14 blob@, attach@ and filepath@ columns read in 2.x after migration datajoint-python#1753. With schema_prefix: "" only, garbage collection keeps:

    • files that a hash reference (such as a migrated <blob@> or <attach@> value) or a <filepath@> reference points to;
    • files named as pre-2.0 DataJoint named blobs and attachments;
    • files directly under {schema}/, with no subfolder;
    • the whole section of a schema that still has pre-2.0 ~external_* tables, reported under skipped_schemas.

    It reads references only from the schemas it collects, in the store it collects. A file in a subfolder of {schema}/, not named as pre-2.0 DataJoint named its files, that only rows of other schemas reference (for example a <filepath@> file) is still listed as an orphan. The pages say to pass every schema whose rows reference files in the store, such as a copy migrated with legacy_database, to the same collector, and to preview with dry_run=True.

    The "Multiple Schemas" section, which says any subset of the schemas sharing a store may be collected, and its code comment now name the root-level layout as the exception and point to "Root-Level Layout".

Tests

Merge together with, or after, datajoint/datajoint-python#1753 is released, since the guide describes its behavior.

The guide finalized with migrate_external(schema, finalize=True), which runs
with the default dry_run=True and changes nothing. Describe the in-store steps
as the migration now runs them: store configuration, the up-front file check,
verifying the _v2 columns, and what migrate_external_pointers_v2 refuses.
…arlier releases

- Option A, step 2: copy_table_data converts in-store columns as it copies,
  with the declaration and store requirements.
- Option A, step 4: tables copied in step 2 need no further step;
  migrate_external_pointers_v2 converts one column of a table still in the
  pre-2.0 layout and swaps it in.
- Option B, step 4: show the filepath preview's problems; a preview needs the
  stores configured and reachable; failure, finalize checks, and nullability;
  how to recover after running this step with an earlier 2.x release.
…LL after repair

- Pre-2.0 blob and attachment files are under the original database name:
  pass legacy_database when migrating or copying from a copy, with the
  create_parallel_schema route spelled out in Option A step 4 and Option B.
- Keep the default schema_prefix on a store that points to the pre-2.0
  location, and what garbage collection does with schema_prefix "".
- "subfolding": null means the pre-2.0 default [2, 2].
- Repair cannot restore NOT NULL lost by an earlier release's finalize;
  restore it in SQL.
- The garbage collection guide says how migrated pre-2.0 files are kept.
…ilepath@> references

State in both pages the files garbage collection keeps in the root-level
layout, the case it does not cover (files in a subfolder that only other
schemas reference), and to preview with dry_run=True.
Passing a subset of the schemas that share a store is safe except with
schema_prefix "", where a file in a subfolder of {schema}/ that only
other schemas reference is listed as an orphan. Point to the Root-Level
Layout section from the paragraph and the code comment.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant