drizzle-team / drizzle-kit-mirror

Docs and issues repository for drizzle-kit
291 stars 17 forks source link

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

Open brogeby opened 3 months ago

brogeby commented 3 months ago

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

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

Heres my config:

// 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

LeonardJSM commented 2 months ago

Issue with the pg_statements extension also, since the extension automatically creates 2 tables in Views. When pushing the changes to the DB, it prompts me to delete those 2 tables. Haven't found a easy workaround yet.

Have seen that the config allows the "Extenstion filter", but currently, only postgis is available as an option since it creates tables straight into the public schema.