Skip to content
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

Rename appuser -> dbowner and link to discussion in issue #215 #216

Merged
merged 3 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,23 @@ 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
```

> For an in depth-discussion on the different users and roles typically
> involved in database and migration management, please see issue
> [#215](https://github.com/graphile/migrate/issues/215).

Export your database URL, shadow database URL, and a "root" database URL which
should be a superuser account connection to any **other** database (most
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
Loading