Skip to content

Commit

Permalink
feat: Make disableMigration option handled by environment variable (#…
Browse files Browse the repository at this point in the history
…8634)

In some cases, people want to disable database migration. For example,
some people or companies want to grant whole permissions to handle the
schema by DBAs, not by application level hence I use
`parseEnvVarBoolean` to handle `disableMigration` option by environment
variable. I set the default value as `false` for the backward
compatibility.
  • Loading branch information
0417taehyun authored Nov 5, 2024
1 parent b5a2bef commit ef8417a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/create-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ const defaultDbOptions: WithOptional<IDBOption, 'user' | 'password' | 'host'> =
propagateCreateError: false,
},
schema: process.env.DATABASE_SCHEMA || 'public',
disableMigration: false,
disableMigration: parseEnvVarBoolean(
process.env.DATABASE_DISABLE_MIGRATION,
false,
),
applicationName: process.env.DATABASE_APPLICATION_NAME || 'unleash',
};

Expand Down
1 change: 1 addition & 0 deletions website/docs/using-unleash/deploy/configuring-unleash.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ Unleash options' `db` object.
| `pool.idleTimeoutMillis` | `DATABASE_POOL_IDLE_TIMEOUT_MS` | 30000 | The amount of time (in milliseconds) that a connection must be idle for before it is marked as a candidate for eviction. |
| `applicationName` | `DATABASE_APPLICATION_NAME` | `unleash` | The name of the application that created this Client instance. |
| `schema` | `DATABASE_SCHEMA` | `public` | The schema to use in the database. |
| `disableMigration` | `DATABASE_DISABLE_MIGRATION` | false | The option not to use database migration. |
Alternatively, you can use a
single-host [libpq connection string](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING) to
Expand Down

0 comments on commit ef8417a

Please sign in to comment.