Skip to content

Commit 58d5662

Browse files
authored
Replace template1 with postgres:///template1 (#227)
2 parents 20db840 + f5c1e20 commit 58d5662

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

__tests__/__snapshots__/settings.test.ts.snap

+5-5
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

+3-1
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 () => {

src/settings.ts

+2-1
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)