Skip to content

The data copy preflight misses extension arrays, extensions in other schemas, and some auth references #173

Closed

Description

@shipmill-romamo

Found in the review of #171 (spec S-007 preflight, #125).

The data copy preflight refuses what it can see, but three common Supabase shapes get past it. Each still fails safe: pg_restore --single-transaction rolls back and the copy exits ENGINE_STEP_FAILED. But the preflight's point is to say why before dumping, and the operator gets a raw restore error instead.

  1. Array types of an extension type. The pg_depend walk in engine/ansible/roles/cloudfall_data_migration/defaults/main.yml misses a citext[] column: the array type isn't a direct member of the extension, so citext is neither reported under extensions nor passed to pg_dump --extension.
  2. An extension installed in an unselected schema. Supabase installs extensions in schema extensions. Copying --source-schema public dumps CREATE EXTENSION ... WITH SCHEMA extensions, which fails on a target without that schema. The preflight doesn't detect it.
  3. auth. references beyond functions and policies. A foreign key to auth.users, a column DEFAULT auth.uid(), and a view calling auth. aren't named under authReferences.

Not reproduced on a live server (no PostgreSQL in the review environment); read from the queries and PostgreSQL's catalog rules.

Items 1 and 2 are bugs in the preflight S-007-7 describes. Item 3 widens authReferences beyond what S-007 names, so it needs a spec change first.

Related: #82, #125, spec docs/specs/007-data-copy-schemas.md.

Activity

  1. shipmill-romamo commented on Oct 30, 2026

    @shipmill-romamo
    ContributorAuthor

    Triage: implement, item 1 only.

    Item 1 is a bug in what S-007-7 already specifies: "need" means an object in a selected schema depends on the extension in pg_depend, and a citext[] column does, one step removed (column → array type → citext type → extension). Checked on main (745c129): the query in engine/ansible/roles/cloudfall_data_migration/defaults/main.yml reads only direct members of the extension.

    The plan:

    • Follow array types to their element type (pg_type.typelem for a typcategory = 'A' type) before matching the extension's members, in both the extensions finding and the list passed to pg_dump --extension
    • A domain over an extension type (typbasetype) is the same shape; cover it in the same walk
    • A rendered-query test proving a citext[] column names citext, as the S-007-7 tests do (no live PostgreSQL in CI)

    Items 2 and 3 change what S-007 specifies (a new kind of finding, and authReferences beyond functions and policies), so they moved to #175, which goes to product intake. I'll link the PR here.

  2. shipmill-romamo commented on Oct 30, 2026

    @shipmill-romamo
    ContributorAuthor

    The fix is in #176: the preflight follows each type a selected object uses through array element types and domain base types (chains included) before matching the extension that owns it, in the one query that feeds both extensions and pg_dump --extension. A citext[] column, or a domain over citext, now names citext.

    Checked on a throwaway PostgreSQL 16.2 with vector standing in for citext (the build had no contrib): main returned no extension for array, domain, domain-of-domain and array-of-domain columns, the branch named it for all four. citext itself and other PostgreSQL versions are unverified. This issue closes when #176 merges.

  3. shipmill-romamo commented on Oct 30, 2026

    @shipmill-romamo
    ContributorAuthor

    Released in v0.8.0rc12 (pre-release).
    A plain install gets it with the next stable release.
    If you filed this: react 👍 on this comment once it works for you, or reply if it doesn't.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions