-
Notifications
You must be signed in to change notification settings - Fork 507
fix(cli): port db reset --experimental remote schema-files path to native TS (CLI-1958) #6062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Coly010
merged 52 commits into
develop
from
columferry/cli-1958-port-db-reset-experimental-remote-schema-files-path-natively
Aug 10, 2026
Merged
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
b70255d
fix(cli): port db reset --experimental remote schema-files path to na…
Coly010 7d33278
docs(cli): reformat go-cli-porting-status.md table (oxfmt column widths)
Coly010 873c3d3
fix(cli): address review findings on db reset --experimental native p…
Coly010 93617dc
Merge remote-tracking branch 'origin/develop' into columferry/cli-195…
Coly010 8ff4485
docs(cli): reformat go-cli-porting-status.md table (oxfmt column widths)
Coly010 4bdb3bd
fix(cli): match Go's Glob.SQLFiles symlink and empty-pattern handling…
Coly010 7020d74
fix(cli): weakly coerce non-string schema_paths/sql_paths entries (CL…
Coly010 4024640
fix(cli): propagate SQL-glob walk failures and gate schema-file sugge…
Coly010 1fa1508
fix(cli): abort config load on non-scalar schema_paths/sql_paths entr…
Coly010 e781d2e
fix(cli): weakly coerce top-level scalar schema_paths/sql_paths (CLI-…
Coly010 efbc9a0
fix(cli): stop misreading stat failures and absolute glob roots (CLI-…
Coly010 971b666
fix(cli): normalize doubled slash under trailing-slash matched dirs (…
Coly010 1dabdb6
docs(cli): document SUPABASE_DB_MIGRATIONS_SCHEMA_PATHS in db reset S…
Coly010 2502f35
fix(cli): drop './' prefix when a walked SQL directory cleans to '.' …
Coly010 f0fc52c
fix(cli): clean walked SQL child paths like Go's path.Join (review: C…
Coly010 95f3108
fix(cli): keep a raced '.sql' child declared when its stat fails (rev…
Coly010 40f597f
fix(cli): clean direct SQL glob matches like Go's afero.Glob (review:…
Coly010 a3a846c
fix(cli): preserve Windows drive roots when splitting SQL glob patter…
Coly010 35204d5
fix(cli): wrap migration read failures with Go's parse-file error tex…
Coly010 5331b1b
docs(cli): correct db reset SIDE_EFFECTS on encrypted vault secrets (…
Coly010 f37fe32
fix(cli): format large numeric schema_paths entries as fixed decimal …
Coly010 3da79a8
fix(cli): report workdir-relative path in schema-file read errors (re…
Coly010 17f2960
docs(cli): document SUPABASE_EXPERIMENTAL_PGDELTA_ENABLED reset gate …
Coly010 e37fc5c
fix(cli): sort SQL glob matches by UTF-8 byte order like Go (review: …
Coly010 cf49af6
fix(cli): fail walk on a raced disappearing subdirectory like Go's Wa…
Coly010 08b4dd8
fix(cli): preserve raw Windows glob pattern in "no files matched" war…
Coly010 873f12a
fix(cli): report workdir-relative path in SQL glob stat-failure warni…
Coly010 95072d7
fix(cli): keep SQL glob walk/stat errors and Windows match order Go-f…
Coly010 e61a58c
fix(cli): match Go's filepath.IsAbs for Windows-rooted schema/seed pa…
Coly010 30bf58a
fix(cli): match Go's Lstat glob fast path, scanner buffer limit, and …
Coly010 525d855
fix(cli): strictly parse SUPABASE_SCANNER_BUFFER_SIZE and honor proje…
Coly010 c405fc9
fix(cli): format TOML inf/-inf/nan glob entries as Go's strconv.Forma…
Coly010 f8a544d
fix(cli): reject an unterminated scanner token exactly at the buffer …
Coly010 3fce530
fix(cli): preserve negative zero when weakly formatting glob entries …
Coly010 2b232d0
fix(cli): cache the pg-delta migrations catalog after a remote reset …
Coly010 c06bc55
fix(cli): parse SUPABASE_SCANNER_BUFFER_SIZE with Go's base-0 int gra…
Coly010 560ff8a
docs(cli): document the ported pg-delta catalog cache in db reset (re…
Coly010 8e8393d
fix(cli): aggregate glob decode issues across sql_paths and schema_pa…
Coly010 8e886ce
fix(cli): provide pg-delta runtime services to db reset (review: CLI-…
Coly010 c9ecd15
fix(cli): accept Go's underscore digit separators in scanner-size int…
Coly010 f119a1c
fix(cli): read the pg-delta catalog timestamp after the export, not b…
Coly010 319e84e
docs(cli): document the local reset path's pg-delta catalog write (re…
Coly010 89acd6c
fix(cli): sort directory entries before walking to match Go's fs.Walk…
Coly010 ed712c6
fix(cli): scope project-env registry overrides around db reset's cata…
Coly010 1ac6609
fix(cli): match Go's scanner-size range rejection and last-token erro…
Coly010 da39dd0
fix(cli): reject bare TOML datetime schema_paths/sql_paths instead of…
Coly010 f0b0a42
Merge remote-tracking branch 'origin/develop' into columferry/cli-195…
Coly010 6d7e1f8
chore(cli): fix markdown table formatting after develop merge
Coly010 96f55b9
Merge remote-tracking branch 'origin/develop' into columferry/cli-195…
Coly010 9d1eb7a
fix(cli): close 3 db reset --experimental Go-parity gaps found in review
Coly010 2e55868
Merge branch 'develop' into columferry/cli-1958-port-db-reset-experim…
Coly010 fe3c34f
Merge branch 'develop' into columferry/cli-1958-port-db-reset-experim…
Coly010 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
241 changes: 116 additions & 125 deletions
241
apps/cli/src/legacy/commands/db/reset/reset.handler.ts
Large diffs are not rendered by default.
Oops, something went wrong.
735 changes: 536 additions & 199 deletions
735
apps/cli/src/legacy/commands/db/reset/reset.integration.test.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
apps/cli/src/legacy/commands/db/reset/reset.layers.unit.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| /** | ||
| * Layer-exposure test for `legacyDbResetRuntimeLayer`. | ||
| * | ||
| * Regression guard (review CLI-1958): the post-reset best-effort pg-delta | ||
| * catalog cache (`legacyTryCacheMigrationsCatalog` in `reset.handler.ts`, gated | ||
| * on `[experimental.pgdelta].enabled` / `SUPABASE_EXPERIMENTAL_PG_DELTA`) reaches | ||
| * `LegacyEdgeRuntimeScript` and `LegacyPgDeltaSslProbe` via | ||
| * `legacyExportCatalogPgDelta` (`legacy-pgdelta.ts`). `legacyDbResetRuntimeLayer` | ||
| * previously omitted both services (and the `LegacyDockerRun` layer the real | ||
| * edge-runtime implementation needs) — unlike `legacyDbPushRuntimeLayer`, which | ||
| * already composes all three. That gap was invisible to `reset.integration.test.ts` | ||
| * because that suite drives `legacyDbReset` directly with its own hand-built layer | ||
| * (which mocks `LegacyEdgeRuntimeScript`/`LegacyPgDeltaSslProbe` in), bypassing | ||
| * `reset.layers.ts` entirely — so a versionless remote reset with pg-delta enabled | ||
| * would crash on a missing-service defect (uncaught by the handler's typed | ||
| * `Effect.catch`) AFTER the remote database was already reset. This test builds | ||
| * the REAL `legacyDbResetRuntimeLayer` (not a mock of the pg-delta services) and | ||
| * asserts both are actually present in its context. | ||
| * | ||
| * See `db/lint/lint.layers.unit.test.ts` for the canonical ambient-stub pattern. | ||
| */ | ||
|
|
||
| import { describe, expect, it } from "@effect/vitest"; | ||
| import { BunServices } from "@effect/platform-bun"; | ||
| import { Effect, Layer, Option } from "effect"; | ||
|
|
||
| import { | ||
| mockAnalytics, | ||
| mockOutput, | ||
| mockProcessControl, | ||
| mockRuntimeInfo, | ||
| mockStdin, | ||
| mockTelemetryRuntime, | ||
| mockTty, | ||
| } from "../../../../../tests/helpers/mocks.ts"; | ||
| import { | ||
| mockLegacyCliConfig, | ||
| mockLegacyCredentialsLayer, | ||
| mockLegacyLinkedProjectCacheLayer, | ||
| mockLegacyTelemetryStateLayer, | ||
| } from "../../../../../tests/helpers/legacy-mocks.ts"; | ||
|
|
||
| import { CliArgs } from "../../../../shared/cli/cli-args.service.ts"; | ||
| import { | ||
| LegacyDebugFlag, | ||
| LegacyDnsResolverFlag, | ||
| LegacyExperimentalFlag, | ||
| LegacyNetworkIdFlag, | ||
| LegacyOutputFlag, | ||
| LegacyProfileFlag, | ||
| LegacyWorkdirFlag, | ||
| } from "../../../../shared/legacy/global-flags.ts"; | ||
|
|
||
| import { LegacyPlatformApiFactory } from "../../../auth/legacy-platform-api-factory.service.ts"; | ||
| import { LegacyProjectRefResolver } from "../../../config/legacy-project-ref.service.ts"; | ||
| import { LegacyDbConfigResolver } from "../../../shared/legacy-db-config.service.ts"; | ||
| import { LegacyDbConnection } from "../../../shared/legacy-db-connection.service.ts"; | ||
| import { LegacyEdgeRuntimeScript } from "../../../shared/legacy-edge-runtime-script.service.ts"; | ||
| import { LegacyPgDeltaSslProbe } from "../../../shared/legacy-pgdelta-ssl-probe.service.ts"; | ||
|
|
||
| import { legacyDbResetRuntimeLayer } from "./reset.layers.ts"; | ||
|
|
||
| /** | ||
| * Builds a stub ambient layer that satisfies every external service required by | ||
| * `legacyDbResetRuntimeLayer` from the root runtime. Services whose logic is not | ||
| * under test are no-op stubs; `LegacyEdgeRuntimeScript` and `LegacyPgDeltaSslProbe` | ||
| * are deliberately NOT stubbed here — the point of this test is to prove the real | ||
| * `legacyDbResetRuntimeLayer` provides them itself. | ||
| */ | ||
| function ambientStubs() { | ||
| const analytics = mockAnalytics(); | ||
| const out = mockOutput(); | ||
|
|
||
| const flagLayers = Layer.mergeAll( | ||
| Layer.succeed(LegacyDebugFlag, false), | ||
| Layer.succeed(LegacyProfileFlag, "supabase"), | ||
| Layer.succeed(LegacyWorkdirFlag, Option.none()), | ||
| Layer.succeed(LegacyOutputFlag, Option.none()), | ||
| Layer.succeed(LegacyDnsResolverFlag, "native"), | ||
| Layer.succeed(LegacyNetworkIdFlag, Option.none()), | ||
| Layer.succeed(LegacyExperimentalFlag, false), | ||
| Layer.succeed(CliArgs, { args: ["db", "reset"] }), | ||
| ); | ||
|
|
||
| // Stub out the heavy service layers so layer construction doesn't require a | ||
| // real DB, real API, or real credentials. | ||
| const heavyServiceStubs = Layer.mergeAll( | ||
| Layer.succeed(LegacyDbConnection, { | ||
| connect: () => Effect.die("db-connection not needed for layer-exposure test"), | ||
| }), | ||
| Layer.succeed(LegacyDbConfigResolver, { | ||
| resolve: () => Effect.die("db-config-resolver not needed for layer-exposure test"), | ||
| resolvePoolerFallback: () => | ||
| Effect.die("db-config-resolver not needed for layer-exposure test"), | ||
| }), | ||
| Layer.succeed(LegacyProjectRefResolver, { | ||
| resolve: () => Effect.die("project-ref-resolver not needed for layer-exposure test"), | ||
| resolveForLink: () => Effect.die("project-ref-resolver not needed for layer-exposure test"), | ||
| resolveOptional: () => Effect.die("project-ref-resolver not needed for layer-exposure test"), | ||
| loadProjectRef: () => Effect.die("project-ref-resolver not needed for layer-exposure test"), | ||
| promptProjectRef: () => Effect.die("project-ref-resolver not needed for layer-exposure test"), | ||
| }), | ||
| Layer.succeed(LegacyPlatformApiFactory, { | ||
| make: Effect.die("platform-api-factory not needed for layer-exposure test"), | ||
| }), | ||
| ); | ||
|
|
||
| return Layer.mergeAll( | ||
| BunServices.layer, | ||
| mockRuntimeInfo(), | ||
| mockTty(), | ||
| mockProcessControl().layer, | ||
| mockStdin(false), | ||
| analytics.layer, | ||
| mockTelemetryRuntime(), | ||
| out.layer, | ||
| flagLayers, | ||
| mockLegacyCliConfig({ workdir: "/tmp/reset-layers-test" }), | ||
| mockLegacyCredentialsLayer, | ||
| mockLegacyLinkedProjectCacheLayer, | ||
| mockLegacyTelemetryStateLayer, | ||
| heavyServiceStubs, | ||
| ); | ||
| } | ||
|
|
||
| describe("legacyDbResetRuntimeLayer — pg-delta service exposure (regression guard, review CLI-1958)", () => { | ||
| it.live( | ||
| "exposes LegacyEdgeRuntimeScript so the post-reset pg-delta catalog cache does not crash on a missing-service defect", | ||
| () => { | ||
| return Effect.gen(function* () { | ||
| const edgeRuntime = yield* Effect.serviceOption(LegacyEdgeRuntimeScript); | ||
| expect(Option.isSome(edgeRuntime)).toBe(true); | ||
| }).pipe(Effect.provide(legacyDbResetRuntimeLayer), Effect.provide(ambientStubs())); | ||
| }, | ||
| ); | ||
|
|
||
| it.live( | ||
| "exposes LegacyPgDeltaSslProbe so the post-reset pg-delta catalog cache does not crash on a missing-service defect", | ||
| () => { | ||
| return Effect.gen(function* () { | ||
| const sslProbe = yield* Effect.serviceOption(LegacyPgDeltaSslProbe); | ||
| expect(Option.isSome(sslProbe)).toBe(true); | ||
| }).pipe(Effect.provide(legacyDbResetRuntimeLayer), Effect.provide(ambientStubs())); | ||
| }, | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.