-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gmrc.cjs
166 lines (150 loc) · 6.29 KB
/
.gmrc.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
const { error, parsed: config } = require("dotenv").config()
if (error) {
console.error(error.message)
console.error("Failed to parse file .env. Please run `bun setup.mjs`.")
process.exit(1)
}
/*
* Graphile Migrate configuration.
*
* If you decide to commit this file (recommended) please ensure that it does
* not contain any secrets (passwords, etc) - we recommend you manage these
* with environmental variables instead.
*
* This file is in JSON5 format, in VSCode you can use "JSON with comments" as
* the file format.
*/
module.exports = {
/*
* connectionString: this tells Graphile Migrate where to find the database
* to run the migrations against.
*
* RECOMMENDATION: use `DATABASE_URL` envvar instead.
*/
"connectionString": `postgres://${config.DATABASE_OWNER}:${config.DATABASE_OWNER_PASSWORD}@${config.DATABASE_HOST}:${config.DATABASE_PORT}/${config.DATABASE_NAME}`,
/*
* 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://${config.DATABASE_OWNER}:${config.DATABASE_OWNER_PASSWORD}@${config.DATABASE_HOST}:${config.DATABASE_PORT}/${config.DATABASE_NAME}_shadow`,
/*
* rootConnectionString: like connectionString, but this is used for
* dropping/creating the database in `graphile-migrate reset`. This isn't
* necessary, shouldn't be used in production, but helps during development.
*
* RECOMMENDATION: use `ROOT_DATABASE_URL` envvar instead.
*/
// "rootConnectionString": "postgres://adminuser:adminpassword@host:5432/postgres",
/*
* pgSettings: key-value settings to be automatically loaded into PostgreSQL
* before running migrations, using an equivalent of `SET LOCAL <key> TO
* <value>`
*/
"pgSettings": {
search_path: "app_public,app_private,app_hidden,public",
},
/*
* placeholders: substituted in SQL files when compiled/executed. Placeholder
* keys should be prefixed with a colon and in all caps, like
* `:COLON_PREFIXED_ALL_CAPS`. Placeholder values should be strings. They
* will be replaced verbatim with NO ESCAPING AT ALL (this differs from how
* psql handles placeholders) so should only be used with "safe" values. This
* is useful for committing migrations where certain parameters can change
* between environments (development, staging, production) but you wish to
* use the same signed migration files for all.
*
* The special value "!ENV" can be used to indicate an environmental variable
* of the same name should be used.
*
* Graphile Migrate automatically sets the `:DATABASE_NAME` and
* `:DATABASE_OWNER` placeholders, and you should not attempt to override
* these.
*/
"placeholders": {
":DATABASE_AUTHENTICATOR": "!ENV",
":DATABASE_VISITOR": "!ENV"
},
/*
* Actions allow you to run scripts or commands at certain points in the
* migration lifecycle. SQL files are ran against the database directly.
* "command" actions are ran with the following environmental variables set:
*
* - GM_DBURL: the PostgreSQL URL of the database being migrated
* - GM_DBNAME: the name of the database from GM_DBURL
* - GM_DBUSER: the user from GM_DBURL
* - GM_SHADOW: set to 1 if the shadow database is being migrated, left unset
* otherwise
*
* If "shadow" is unspecified, the actions will run on events to both shadow
* and normal databases. If "shadow" is true the action will only run on
* actions to the shadow DB, and if false only on actions to the main DB.
*/
/*
* afterReset: actions executed after a `graphile-migrate reset` command.
*/
"afterReset": [
"!afterReset.sql",
// { "_": "command", "command": "echo $GM_DBURL" },
{ _: "command", command: "graphile-worker --connection $GM_DBURL --schema-only" },
],
/*
* afterAllMigrations: actions executed once all migrations are complete.
*/
"afterAllMigrations": [
{
_: "command",
shadow: true,
command: "if [[ \"$IN_TESTS\" != \"1\" && \"$GM_SHADOW\" == \"1\" ]]; then pg_dump --no-sync --schema-only --no-owner --exclude-schema=graphile_migrate --exclude-schema=graphile_worker --file schema.sql $GM_DBURL; fi",
},
],
"beforeCurrent": [
{
_: "command",
command: "if [[ \"$IN_TESTS\" != \"1\" && \"$GM_SHADOW\" != \"1\" ]]; then pg_dump \"$GM_DBURL\" --data-only --schema app_public -T app_public.users -T app_public.user_emails -T app_public.user_authentications -T app_public.organizations -T app_public.organization_memberships -T app_public.organization_invitations --column-inserts --no-comments --rows-per-insert=1000 --file migrations/restoreCurrentData.sql; fi"
}
],
/*
* afterCurrent: actions executed once the current migration has been
* evaluated (i.e. in watch mode).
*/
"afterCurrent": [
{
_: "sql",
file: "restoreCurrentData.sql",
shadow: false
},
{
_: "command",
shadow: false,
command: "pg_dump --no-sync --schema-only --no-owner --exclude-schema=graphile_migrate --exclude-schema=graphile_worker --file schema.sql $GM_DBURL",
},
// {
// "_": "command",
// "shadow": true,
// "command": "if [ \"$IN_TESTS\" = \"1\" ]; then ./scripts/test-seed; fi",
// },
],
/*
* blankMigrationContent: content to be written to the current migration
* after commit. NOTE: this should only contain comments.
*/
// "blankMigrationContent": "-- Write your migration here\n",
/** **************************************************************************\
*** ***
*** You probably don't want to edit anything below here. ***
*** ***
\****************************************************************************/
/*
* manageGraphileMigrateSchema: if you set this false, you must be sure to
* keep the graphile_migrate schema up to date yourself. We recommend you
* leave it at its default.
*/
// "manageGraphileMigrateSchema": true,
/*
* migrationsFolder: path to the folder in which to store your migrations.
*/
// migrationsFolder: "./migrations",
"//generatedWith": "1.4.1"
}