Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 516
fix(cli): stop skipping colliding schemas (CLI-2272)#6394
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
Draft
7ttp
wants to merge
2
commits into
developChoose a base branch
from
7ttp/drop-schemas-oid-collision
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.
Uh oh!
There was an error while loading. Please reload this page.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
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
4 changes: 2 additions & 2 deletions
4 apps/cli/src/legacy/commands/db/shared/legacy-drop-schemas.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
67 changes: 67 additions & 0 deletions
67 apps/cli/src/legacy/commands/db/shared/legacy-migra.deno-templates.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 |
|---|---|---|
| @@ -25,3 +25,70 @@ describe("embedded migra templates", () => { | ||
| expect(legacyMigraDiffScript).toContain(LEGACY_EDGE_RUNTIME_SCRIPT_ERROR_SENTINEL); | ||
| }); | ||
| }); | ||
| // The user-schema listing predicate is hand-copied across four modules — | ||
| // drift between the copies caused supabase/cli#6375. | ||
| const CLASSID_CONSTRAINT = | ||
| "left join pg_catalog.pg_depend pd on pd.objid = pn.oid and pd.classid = 'pg_catalog.pg_namespace'::regclass"; | ||
| const SCHEMA_LISTING_SOURCES: ReadonlyArray<[label: string, relPath: string]> = [ | ||
| ["legacy-drop-schemas.ts", "./legacy-drop-schemas.ts"], | ||
| ["legacy-drop-objects.ts", "../../../shared/legacy-drop-objects.ts"], | ||
| ["lint.lint-sql.ts", "../lint/lint.lint-sql.ts"], | ||
| ["legacy-migra.ts", "./legacy-migra.ts"], | ||
| ]; | ||
| const readSchemaListingSource = (relPath: string) => | ||
| readFileSync(fileURLToPath(new URL(relPath, import.meta.url)), "utf8"); | ||
| // Both copies in each compared pair use identical template-literal escaping, | ||
| // so the raw captured source is compared without decoding. | ||
| function extractSqlLiteral(source: string, name: string): string { | ||
| const match = new RegExp(`${name} = \`([\\s\\S]*?)\`;`).exec(source); | ||
| if (match?.[1] === undefined) { | ||
| throw new Error(`missing template literal '${name}'`); | ||
| } | ||
| return match[1].trimEnd(); | ||
| } | ||
| describe("embedded user-schema listing queries", () => { | ||
| it.each(SCHEMA_LISTING_SOURCES)( | ||
| "%s constrains the pg_depend anti-join to pg_namespace rows (supabase/cli#6375)", | ||
| (_label, relPath) => { | ||
| const source = readSchemaListingSource(relPath); | ||
| expect(source).toContain(CLASSID_CONSTRAINT); | ||
| // every join occurrence must carry the classid constraint, regardless of | ||
| // line wrapping or trailing same-line text | ||
| const normalized = source.replaceAll(/\s+/gu, " "); | ||
| const joins = normalized.match(/pd\.objid = pn\.oid/gu) ?? []; | ||
| const constrained = | ||
| normalized.match( | ||
| /pd\.objid = pn\.oid and pd\.classid = 'pg_catalog\.pg_namespace'::regclass/gu, | ||
| ) ?? []; | ||
| expect(joins.length).toBeGreaterThan(0); | ||
| expect(constrained.length).toBe(joins.length); | ||
| }, | ||
| ); | ||
| it("keeps the two drop DO blocks identical to each other", () => { | ||
| expect( | ||
| extractSqlLiteral(readSchemaListingSource("./legacy-drop-schemas.ts"), "DROP_OBJECTS"), | ||
| ).toBe( | ||
| extractSqlLiteral( | ||
| readSchemaListingSource("../../../shared/legacy-drop-objects.ts"), | ||
| "LEGACY_DROP_OBJECTS_SQL", | ||
| ), | ||
| ); | ||
| }); | ||
| it("keeps the two list queries identical to each other", () => { | ||
| expect( | ||
| extractSqlLiteral( | ||
| readSchemaListingSource("../lint/lint.lint-sql.ts"), | ||
| "LEGACY_LIST_SCHEMAS_SQL", | ||
| ), | ||
| ).toBe( | ||
| extractSqlLiteral(readSchemaListingSource("./legacy-migra.ts"), "LEGACY_LIST_SCHEMAS_SQL"), | ||
| ); | ||
| }); | ||
7ttp marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| }); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.
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.