Skip to content

Phase 6: Migrate D1 database data #327

Closed

Description

@neuromechanist

Parent Epic

#314

Goal

Migrate all data from the personal D1 database to the SCCN D1 database.

Tables to Migrate

  • users (accounts, hashed passwords, roles, status)
  • datasets (metadata, sync status, DOI info)
  • dataset_versions (version history)
  • dataset_collaborators (access control)
  • publication_requests (publication workflow state)
  • email_verification_tokens
  • Any other tables from migrations 0001-0014+

Tasks

  • Export all data from personal D1 (wrangler d1 execute --command "SELECT * FROM ...")
  • Verify schema matches on SCCN D1 (migrations already applied in Phase 3)
  • Import data into SCCN D1
  • Verify row counts match
  • Verify encrypted fields are readable (depends on identical ENCRYPTION_KEY)
  • Re-index Vectorize with dataset data from new D1
  • Validate a sample of records end-to-end

Depends On

Notes

  • D1 export/import may need custom scripting (no native D1 dump tool)
  • Consider using wrangler d1 execute with INSERT statements
  • Encrypted per-user AWS credentials must remain byte-identical
  • Vectorize index needs full rebuild after data migration

Activity

  1. added
    infrastructure
    on Mar 21, 2026
  2. neuromechanist commented on Mar 22, 2026

    @neuromechanist
    ContributorAuthor

    Status: Done

    All data migrated from personal D1 to SCCN D1. Row counts verified:

    Table Rows Status
    users 13 Match
    tokens 21 Match
    datasets 77 Match
    dataset_versions 22 Match
    dataset_collaborators 2 Match
    publication_requests 47 Match
    id_sequence 2 Match
    nemar_catalog 489 Match

    Verified:

    • Auth works with migrated API keys on SCCN prod worker
    • Admin endpoints return correct user data
    • Datasets endpoint returns all 510 datasets (77 D1 + catalog)
    • Encrypted AWS credentials are decryptable (ENCRYPTION_KEY is byte-identical)
    • One row with Unicode smart quotes required parameterized query (fixed)

    Migration method: Cloudflare D1 REST API (direct JSON export/import). Used parameterized queries for rows with special characters.

  3. neuromechanist commented on Apr 18, 2026

    @neuromechanist
    ContributorAuthor

    Done (pre-existing). SCCN D1 already holds full production data: 198 datasets, 14 users, 36 versions (dump/restore landed ~Apr 14). Safety audit 2026-04-18: 27 nm* + 21 on* + 0 xx* user-managed datasets match exactly on both sides. Only drift is 1 ds* catalog row (ds006963) which self-heals via catalog-sync. Schema aligned (0019_user_description tracking fixed today).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    infrastructure

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions