drizzle-team / drizzle-team/drizzle-orm

[BUG]: tablesFilter doesn't work when using views

Open
#3,309 4 comments 4 reactions 0 assignees View on GitHub
bug bug/fixed-in-beta drizzle/kit priority
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

I have a Postgres DB with a couple of tables and views autogenerated from my hosting service. I wish to ignore these all together. However, when I run generate and push, I get prompted "Is table created or renamed from another table?" and then a list of the views and tables.
drizzle-kit: 0.21.1
drizzle-orm: 0.30.10

Example:
![image](https://github.com/drizzle-team/drizzle-orm/assets/49376982/81abdd5f-0297-4a0b-bd6e-4dd77e65d094)

In the example, spatial_ref_sys is a table and the rest is views.

Heres my config:
```JavaScript
// config.drizzle.js
import 'dotenv/config'

import { defineConfig } from 'drizzle-kit'

const DATABASE_URL =
process.env.DATABASE_URL || process.env.POSTGRESQL_ADDON_URI

export default defineConfig({
schema: 'src/db/schema.*',
out: 'src/db/migrations',
dialect: 'postgresql',
dbCredentials: {
url: DATABASE_URL,
},
verbose: true,
strict: false,
tablesFilter: [
'!geography_columns',
'!geometry_columns',
'!raster_columns',
'!spatial_ref_sys',
'!pg_stat_statements',
'!raster_overviews',
'!pg_stat_statements_info',
],
schemaFilter: ['public'],
})
```

Current workaround is to declare the autogenerated views + tables in schema as pgTable's in my schemas and manually create them in my local DB

Contributor guide

Open the contributing guide

Research direction

Start with config.drizzle.js and the tablesFilter configuration used by the generate and push commands, reproducing the behavior against PostgreSQL views and tables. Verify that the listed autogenerated objects are ignored without declaring them as pgTable entries, and that the rename/create prompts no longer include them.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, typescript
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.