Skip to content

Commit

Permalink
Rename appuser to dbowner
Browse files Browse the repository at this point in the history
As noted in graphile#215, the naming `appuser` may confuse users into
thinking the account to use for DATABASE_URL is the same as the
account that should be used by the application to connect to the
database. While this may be true in some setups, it is not a hard
requirement (see the discussion in graphile#215 for further details).

resolves graphile#215
  • Loading branch information
FelixZY committed Jun 10, 2024
1 parent d41358a commit dc73beb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ unaffected by the iteration you've been applying to your development database
Create your database role (if desired), database and shadow database:

```bash
createuser --pwprompt appuser
createdb myapp --owner=appuser
createdb myapp_shadow --owner=appuser
createuser --pwprompt dbowner
createdb myapp --owner=dbowner
createdb myapp_shadow --owner=dbowner
```

Export your database URL, shadow database URL, and a "root" database URL which
Expand All @@ -119,8 +119,8 @@ PostgreSQL servers have a default database called `postgres` which is a good
choice for this).

```bash
export DATABASE_URL="postgres://appuser:password@localhost/myapp"
export SHADOW_DATABASE_URL="postgres://appuser:password@localhost/myapp_shadow"
export DATABASE_URL="postgres://dbowner:password@localhost/myapp"
export SHADOW_DATABASE_URL="postgres://dbowner:password@localhost/myapp_shadow"

export ROOT_DATABASE_URL="postgres://postgres:postgres@localhost/postgres"
```
Expand Down
18 changes: 9 additions & 9 deletions __tests__/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,12 @@ describe("gmrc path", () => {
mockFs.restore();
mockFs({
[DEFAULT_GMRC_PATH]: `
{ "connectionString": "postgres://appuser:apppassword@host:5432/defaultdb" }
{ "connectionString": "postgres://dbowner:password@host:5432/defaultdb" }
`,
});
const settings = await getSettings();
expect(settings.connectionString).toEqual(
"postgres://appuser:apppassword@host:5432/defaultdb",
"postgres://dbowner:password@host:5432/defaultdb",
);
mockFs.restore();
});
Expand All @@ -334,15 +334,15 @@ describe("gmrc path", () => {
mockFs.restore();
mockFs({
[DEFAULT_GMRC_PATH]: `
{ "connectionString": "postgres://appuser:apppassword@host:5432/defaultdb" }
{ "connectionString": "postgres://dbowner:password@host:5432/defaultdb" }
`,
".other-gmrc": `
{ "connectionString": "postgres://appuser:apppassword@host:5432/otherdb" }
{ "connectionString": "postgres://dbowner:password@host:5432/otherdb" }
`,
});
const settings = await getSettings({ configFile: ".other-gmrc" });
expect(settings.connectionString).toEqual(
"postgres://appuser:apppassword@host:5432/otherdb",
"postgres://dbowner:password@host:5432/otherdb",
);
mockFs.restore();
});
Expand All @@ -362,12 +362,12 @@ describe("gmrc from JS", () => {
mockFs({
[DEFAULT_GMRCJS_PATH]: /* JavaScript */ `\
module.exports = {
connectionString: "postgres://appuser:apppassword@host:5432/gmrcjs_test",
connectionString: "postgres://dbowner:password@host:5432/gmrcjs_test",
};`,
});
const settings = await getSettings();
expect(settings.connectionString).toEqual(
"postgres://appuser:apppassword@host:5432/gmrcjs_test",
"postgres://dbowner:password@host:5432/gmrcjs_test",
);
mockFs.restore();
});
Expand All @@ -382,12 +382,12 @@ module.exports = {
mockFs({
[DEFAULT_GMRC_COMMONJS_PATH]: /* JavaScript */ `\
module.exports = {
connectionString: "postgres://appuser:apppassword@host:5432/gmrc_commonjs_test",
connectionString: "postgres://dbowner:password@host:5432/gmrc_commonjs_test",
};`,
});
const settings = await getSettings();
expect(settings.connectionString).toEqual(
"postgres://appuser:apppassword@host:5432/gmrc_commonjs_test",
"postgres://dbowner:password@host:5432/gmrc_commonjs_test",
);
mockFs.restore();
});
Expand Down
4 changes: 2 additions & 2 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export async function init(options: InitArgv = {}): Promise<void> {
*
* RECOMMENDATION: use \`DATABASE_URL\` envvar instead.
*/
// "connectionString": "postgres://appuser:apppassword@host:5432/appdb",
// "connectionString": "postgres://dbowner:password@host:5432/appdb",
/*
* shadowConnectionString: like connectionString, but this is used for the
* shadow database (which will be reset frequently).
*
* RECOMMENDATION: use \`SHADOW_DATABASE_URL\` envvar instead.
*/
// "shadowConnectionString": "postgres://appuser:apppassword@host:5432/appdb_shadow",
// "shadowConnectionString": "postgres://dbowner:password@host:5432/appdb_shadow",
/*
* rootConnectionString: like connectionString, but this is used for
Expand Down

0 comments on commit dc73beb

Please sign in to comment.