-
Notifications
You must be signed in to change notification settings - Fork 486
fix(cli): port db pull initial pull to native pg_dump; fix non-interactive confirm hangs #5725
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
Open
Coly010
wants to merge
7
commits into
develop
Choose a base branch
from
cli/db-pull-native-initial-migra
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
adf4cd6
fix(cli): port db pull initial pull to native pg_dump; fix non-intera…
Coly010 af5e58e
fix(db): reset dump byte tracking per attempt (Go resetOutput parity)
Coly010 2bfb3f8
fix(cli): honor piped stdin in legacy yes/no prompts (Go console parity)
Coly010 90f04f6
fix(cli): read legacy prompt stdin lazily, one line at a time (Go Rea…
Coly010 a71f30c
fix(cli): honor piped logout confirmations (Go console parity)
Coly010 af190ce
Merge remote-tracking branch 'origin/develop' into cli/db-pull-native…
Coly010 acc9614
fix(db): honor SUPABASE_YES and drop `as` casts on the native db pull…
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.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { existsSync, mkdtempSync, rmSync } from "node:fs"; | ||
| import { tmpdir } from "node:os"; | ||
| import { join } from "node:path"; | ||
| import { expect, test } from "vitest"; | ||
|
|
||
| import { | ||
| describeLiveProject, | ||
| requireLiveProjectRef, | ||
| runSupabaseLive, | ||
| } from "../../../../../tests/helpers/live.ts"; | ||
|
|
||
| const LIVE_TIMEOUT_MS = 300_000; | ||
|
|
||
| // A fresh, isolated temp workdir so the CLI writes the dump there and never touches | ||
| // the repo tree. The provisioned project ref is supplied to `--linked` via the | ||
| // `SUPABASE_PROJECT_ID` env var — that is the `--linked` resolver chain in both Go | ||
| // and the legacy port (flag → `SUPABASE_PROJECT_ID` → `supabase/.temp/project-ref`); | ||
| // `config.toml`'s `project_id` is NOT consulted for `--linked`. | ||
| function tempWorkdir(): string { | ||
| return mkdtempSync(join(tmpdir(), "sb-db-dump-live-")); | ||
| } | ||
|
|
||
| // Project-scoped + data-plane: needs a provisioned project whose database is | ||
| // routable (the cli-e2e-ci Linux runner). Skipped on a control-plane-only stack | ||
| // (`SUPABASE_LIVE_PROJECT_REF` unset), e.g. local macOS. | ||
| describeLiveProject("supabase db dump (live)", () => { | ||
| test("dumps the linked project's schema to a file", { timeout: LIVE_TIMEOUT_MS }, async () => { | ||
| const ref = requireLiveProjectRef(); | ||
| const dir = tempWorkdir(); | ||
| try { | ||
| const outFile = join(dir, "schema.sql"); | ||
| const { exitCode, stdout, stderr } = await runSupabaseLive( | ||
| ["db", "dump", "--linked", "-f", outFile], | ||
| { cwd: dir, env: { SUPABASE_PROJECT_ID: ref }, exitTimeoutMs: LIVE_TIMEOUT_MS - 20_000 }, | ||
| ); | ||
| expect(`${stdout}${stderr}`).not.toContain("Unauthorized"); | ||
| expect(exitCode).toBe(0); | ||
| // The native pg_dump container (shared `legacyStreamPgDump`) opened + wrote | ||
| // the dump file. A fresh project's public schema may be near-empty, so assert | ||
| // the file was created rather than its size. | ||
| expect(existsSync(outFile)).toBe(true); | ||
| } finally { | ||
| rmSync(dir, { recursive: true, force: true }); | ||
| } | ||
| }); | ||
| }); | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a live environment that sets
SUPABASE_LIVE_PROJECT_REFbut the project's Postgres instance is notACTIVE_HEALTHY,describeLiveProjectstill runs this suite;tests/helpers/live-env.tsdocuments that this is the current cli-e2e-ci control-plane-only case and that db/migration/storage suites should skip viadescribeLiveDataPlane. As written, this newdb dumplive test (and the matchingdb pulllive test) will attempt pg_dump/db connections against an unreachable project database and fail or time out instead of being skipped.Useful? React with 👍 / 👎.