Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
fix(db): apply infra before clone so RLS policies/grants survive#47
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
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
838bcfb
feat(db): enhance infrastructure management and cloning process
supunappri99 dde8574
feat(db): implement line sanitization for database cloning and update…
supunappri99 820c0ed
fix: update version to 1.3.1 in package.json
supunappri99 b2eb272
test: remove unnecessary variable assignment in startSessionContainer…
supunappri99 aa2a65e
Merge branch 'development' of supunappri.github.com:appritechnologies…
supunappri99 5023f63
Merge pull request #46 from appritechnologies/fix/db-start-rls-clone-…
supunappri99 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
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 |
|---|---|---|
| @@ -152,8 +152,8 @@ export async function deployCommand(options: DeployOptions): Promise<void> { | ||
| logger.blank(); | ||
| } | ||
| // 3 fixed steps (test, status, clone) + 3 runSteps × 2 passes (dry-run + target) + 1 fixed step (cleanup) | ||
| const totalSteps = 3 + 3 * 2 + 1; // = 10 | ||
| // 4 fixed steps (test, status, infra-apply, clone) + 3 runSteps × 2 passes (dry-run + target) + 1 fixed step (cleanup) | ||
| const totalSteps = 4 + 3 * 2 + 1; // = 11 | ||
| const migrationNames = pendingMigrations.map(m => m.migrationFile.name); | ||
| // Step 1: Test target DB connection | ||
| @@ -216,7 +216,15 @@ export async function deployCommand(options: DeployOptions): Promise<void> { | ||
| deregisterSignal = onContainerInterrupt(tempContainerID); | ||
| } | ||
| logger.step(3, totalSteps, "Cloning target database to local..."); | ||
| // Step 3: Apply infra (roles, schemas, extensions) to the local/temp DB BEFORE | ||
| // cloning. target's dump includes CREATE POLICY / GRANT / ALTER DEFAULT | ||
| // PRIVILEGES statements naming custom roles (e.g. app_admin, employee) — those | ||
| // fail with "role does not exist" if replayed before the roles exist, and since | ||
| // the clone's psql now runs with ON_ERROR_STOP, that failure is no longer silent. | ||
| logger.step(3, totalSteps, "Applying infrastructure to local database..."); | ||
| await applyInfraStep(spinner, localDbUrl, "local clone"); | ||
| logger.step(4, totalSteps, "Cloning target database to local..."); | ||
| spinner.start("Cloning target database to local for dry-run verification..."); | ||
| if (tempContainerID) { | ||
| await cloneDatabaseViaContainer(tempContainerID, targetUrl, localDbUrl); | ||
| @@ -226,12 +234,12 @@ export async function deployCommand(options: DeployOptions): Promise<void> { | ||
| const localTableCount = await getTableCount(localDbUrl); | ||
| spinner.succeed(`Target cloned to local (${localTableCount} tables)`); | ||
| // Steps 4-6: Dry run on local clone | ||
| // Steps 5-7: Dry run on local clone | ||
| logger.blank(); | ||
| logger.heading("Dry Run (local verification)"); | ||
| try { | ||
| await runSteps(localDbUrl, "local clone", spinner, 4, totalSteps, migrationNames); | ||
| await runSteps(localDbUrl, "local clone", spinner, 5, totalSteps, migrationNames); | ||
| } catch (error) { | ||
| spinner.fail("Dry run failed on local clone"); | ||
| logger.error(error instanceof Error ? error.message : String(error)); | ||
| @@ -269,12 +277,12 @@ export async function deployCommand(options: DeployOptions): Promise<void> { | ||
| return; | ||
| } | ||
| // Steps 7-9: Apply to target | ||
| // Steps 8-10: Apply to target | ||
| logger.blank(); | ||
| logger.heading("Deploying to Target"); | ||
| try { | ||
| await runSteps(targetUrl, targetLabel, spinner, 7, totalSteps, migrationNames); | ||
| await runSteps(targetUrl, targetLabel, spinner, 8, totalSteps, migrationNames); | ||
| } catch (error) { | ||
| logger.error(error instanceof Error ? error.message : String(error)); | ||
| logger.blank(); | ||
| @@ -288,7 +296,7 @@ export async function deployCommand(options: DeployOptions): Promise<void> { | ||
| // Step 10: Drop local clone and stop temp container | ||
supunappri99 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| logger.blank(); | ||
| logger.step(10, totalSteps, "Cleaning up local clone..."); | ||
| logger.step(11, totalSteps, "Cleaning up local clone..."); | ||
| spinner.start("Dropping local clone database..."); | ||
| try { | ||
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.
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.