Skip to content

Commit d7f51f3

Browse files
committed
Replace template1 with postgres:///template1
1 parent 20db840 commit d7f51f3

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

__tests__/__snapshots__/settings.test.ts.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ exports[`actions is backwards-compatible with untagged command specs 1`] = `
3838
"manageGraphileMigrateSchema": true,
3939
"migrationsFolder": "./migrations",
4040
"placeholders": undefined,
41-
"rootConnectionString": "template1",
41+
"rootConnectionString": "postgres:///template1",
4242
"shadowConnectionString": undefined,
4343
"shadowDatabaseName": undefined,
4444
}
@@ -79,7 +79,7 @@ exports[`actions parses SQL actions 1`] = `
7979
"manageGraphileMigrateSchema": true,
8080
"migrationsFolder": "./migrations",
8181
"placeholders": undefined,
82-
"rootConnectionString": "template1",
82+
"rootConnectionString": "postgres:///template1",
8383
"shadowConnectionString": undefined,
8484
"shadowDatabaseName": undefined,
8585
}
@@ -115,7 +115,7 @@ exports[`actions parses command actions 1`] = `
115115
"manageGraphileMigrateSchema": true,
116116
"migrationsFolder": "./migrations",
117117
"placeholders": undefined,
118-
"rootConnectionString": "template1",
118+
"rootConnectionString": "postgres:///template1",
119119
"shadowConnectionString": undefined,
120120
"shadowDatabaseName": undefined,
121121
}
@@ -159,7 +159,7 @@ exports[`actions parses mixed actions 1`] = `
159159
"manageGraphileMigrateSchema": true,
160160
"migrationsFolder": "./migrations",
161161
"placeholders": undefined,
162-
"rootConnectionString": "template1",
162+
"rootConnectionString": "postgres:///template1",
163163
"shadowConnectionString": undefined,
164164
"shadowDatabaseName": undefined,
165165
}
@@ -200,7 +200,7 @@ exports[`actions parses string values into SQL actions 1`] = `
200200
"manageGraphileMigrateSchema": true,
201201
"migrationsFolder": "./migrations",
202202
"placeholders": undefined,
203-
"rootConnectionString": "template1",
203+
"rootConnectionString": "postgres:///template1",
204204
"shadowConnectionString": undefined,
205205
"shadowDatabaseName": undefined,
206206
}

__tests__/actions.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ it("runs sql afterReset action with correct connection string when root", async
9393
mockedWithClient.mockClear();
9494
await executeActions(parsedSettings, false, parsedSettings.afterReset);
9595
expect(mockedWithClient).toHaveBeenCalledTimes(1);
96-
expect(mockedWithClient.mock.calls[0][0]).toBe(TEST_DATABASE_NAME);
96+
expect(mockedWithClient.mock.calls[0][0]).toBe(
97+
`postgres:///${TEST_DATABASE_NAME}`,
98+
);
9799
});
98100

99101
it("runs command afterReset action with correct env vars when root", async () => {

__tests__/settings.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,12 @@ describe("gmrc from JS", () => {
362362
mockFs({
363363
[DEFAULT_GMRCJS_PATH]: /* JavaScript */ `\
364364
module.exports = {
365-
connectionString: "postgres://dbowner:password@host:5432/gmrcjs_test",
365+
connectionString: "postgres:///dbowner:password@host:5432/gmrcjs_test",
366366
};`,
367367
});
368368
const settings = await getSettings();
369369
expect(settings.connectionString).toEqual(
370-
"postgres://dbowner:password@host:5432/gmrcjs_test",
370+
"postgres:///dbowner:password@host:5432/gmrcjs_test",
371371
);
372372
mockFs.restore();
373373
});

src/settings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ export async function parseSettings(
157157
const rootConnectionString = await check(
158158
"rootConnectionString",
159159
(
160-
rawRootConnectionString = process.env.ROOT_DATABASE_URL || "template1",
160+
rawRootConnectionString = process.env.ROOT_DATABASE_URL ||
161+
"postgres:///template1",
161162
): string => {
162163
if (typeof rawRootConnectionString !== "string") {
163164
throw new Error(

0 commit comments

Comments
 (0)