mirror of
https://github.com/directus/directus.git
synced 2026-01-22 16:38:03 -05:00
Add environment variable to force-exclude tables from Directus (#7789)
This commit is contained in:
@@ -22,6 +22,7 @@ export default function getDatabase(): Knex {
|
||||
'DB_SEARCH_PATH',
|
||||
'DB_CONNECTION_STRING',
|
||||
'DB_POOL',
|
||||
'DB_EXCLUDE_TABLES',
|
||||
]);
|
||||
|
||||
const poolConfig = getConfigFromEnv('DB_POOL');
|
||||
|
||||
@@ -19,6 +19,8 @@ const defaults: Record<string, any> = {
|
||||
PUBLIC_URL: '/',
|
||||
MAX_PAYLOAD_SIZE: '100kb',
|
||||
|
||||
DB_EXCLUDE_TABLES: [],
|
||||
|
||||
STORAGE_LOCATIONS: 'local',
|
||||
STORAGE_LOCAL_DRIVER: 'local',
|
||||
STORAGE_LOCAL_ROOT: './uploads',
|
||||
|
||||
@@ -116,6 +116,11 @@ async function getDatabaseSchema(
|
||||
];
|
||||
|
||||
for (const [collection, info] of Object.entries(schemaOverview)) {
|
||||
if (toArray(env.DB_EXCLUDE_TABLES).includes(collection)) {
|
||||
logger.trace(`Collection "${collection}" is configured to be excluded and will be ignored`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!info.primary) {
|
||||
logger.warn(`Collection "${collection}" doesn't have a primary key column and will be ignored`);
|
||||
continue;
|
||||
|
||||
@@ -34,6 +34,7 @@ needs to be publicly available on the internet.
|
||||
| `DB_FILENAME` | Where to read/write the SQLite database. **Required** when using `sqlite3`. | -- |
|
||||
| `DB_CONNECTION_STRING` | When using `pg`, you can submit a connection string instead of individual properties. Using this will ignore any of the other connection settings. | -- |
|
||||
| `DB_POOL_*` | Pooling settings. Passed on to [the `tarn.js`](https://github.com/vincit/tarn.js#usage) library. | -- |
|
||||
| `DB_IGNORE_TABLES` | CSV of tables you want Directus to ignore completely | -- |
|
||||
|
||||
::: tip Additional Database Variables
|
||||
|
||||
|
||||
Reference in New Issue
Block a user