Skip to content

Commit

Permalink
Replace template1 with postgres:///template1 (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie authored Oct 16, 2024
2 parents 20db840 + f5c1e20 commit 58d5662
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions __tests__/__snapshots__/settings.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ exports[`actions is backwards-compatible with untagged command specs 1`] = `
"manageGraphileMigrateSchema": true,
"migrationsFolder": "./migrations",
"placeholders": undefined,
"rootConnectionString": "template1",
"rootConnectionString": "postgres:///template1",
"shadowConnectionString": undefined,
"shadowDatabaseName": undefined,
}
Expand Down Expand Up @@ -79,7 +79,7 @@ exports[`actions parses SQL actions 1`] = `
"manageGraphileMigrateSchema": true,
"migrationsFolder": "./migrations",
"placeholders": undefined,
"rootConnectionString": "template1",
"rootConnectionString": "postgres:///template1",
"shadowConnectionString": undefined,
"shadowDatabaseName": undefined,
}
Expand Down Expand Up @@ -115,7 +115,7 @@ exports[`actions parses command actions 1`] = `
"manageGraphileMigrateSchema": true,
"migrationsFolder": "./migrations",
"placeholders": undefined,
"rootConnectionString": "template1",
"rootConnectionString": "postgres:///template1",
"shadowConnectionString": undefined,
"shadowDatabaseName": undefined,
}
Expand Down Expand Up @@ -159,7 +159,7 @@ exports[`actions parses mixed actions 1`] = `
"manageGraphileMigrateSchema": true,
"migrationsFolder": "./migrations",
"placeholders": undefined,
"rootConnectionString": "template1",
"rootConnectionString": "postgres:///template1",
"shadowConnectionString": undefined,
"shadowDatabaseName": undefined,
}
Expand Down Expand Up @@ -200,7 +200,7 @@ exports[`actions parses string values into SQL actions 1`] = `
"manageGraphileMigrateSchema": true,
"migrationsFolder": "./migrations",
"placeholders": undefined,
"rootConnectionString": "template1",
"rootConnectionString": "postgres:///template1",
"shadowConnectionString": undefined,
"shadowDatabaseName": undefined,
}
Expand Down
4 changes: 3 additions & 1 deletion __tests__/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ it("runs sql afterReset action with correct connection string when root", async
mockedWithClient.mockClear();
await executeActions(parsedSettings, false, parsedSettings.afterReset);
expect(mockedWithClient).toHaveBeenCalledTimes(1);
expect(mockedWithClient.mock.calls[0][0]).toBe(TEST_DATABASE_NAME);
expect(mockedWithClient.mock.calls[0][0]).toBe(
`postgres:///${TEST_DATABASE_NAME}`,
);
});

it("runs command afterReset action with correct env vars when root", async () => {
Expand Down
3 changes: 2 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ export async function parseSettings(
const rootConnectionString = await check(
"rootConnectionString",
(
rawRootConnectionString = process.env.ROOT_DATABASE_URL || "template1",
rawRootConnectionString = process.env.ROOT_DATABASE_URL ||
"postgres:///template1",
): string => {
if (typeof rawRootConnectionString !== "string") {
throw new Error(
Expand Down

0 comments on commit 58d5662

Please sign in to comment.