How to fix, issue while pushing the migration, drizzle is treating view as table and trying to drop
pgPush fails with “pg_stat_statements_info is not a table” error
While applying the migration and pushing the migration using
drizzle-kit push
facing below issue, drizzle is trying to
It looks like Drizzle is trying to drop pg_stat_statements_info as if it were a table, but it’s actually a view provided by the pg_stat_statements extension. I haven’t configured anything special in drizzle.config.ts, so I expected introspection to skip system views or at least use the proper DROP VIEW syntax.
What I’ve tried so far
- Manually disabling or ignoring system schemas/tables in drizzle.config.ts (no effect)
- Tried by adding view in schema witht he existing()
but no effect.
- Confirming that the view exists by running \dv pg_stat_statements_info in psql
Questions
- Is there a recommended way to tell Drizzle to ignore Postgres system views (like anything in pg_catalog or provided by an extension)?
- If not, is there a workaround so that drizzle-kit push uses DROP VIEW instead of DROP TABLE for views?
- Would it make sense for Drizzle to automatically detect views vs. tables during introspection?
Thanks in advance for any guidance! Happy to share more config or logs if helpful.
10 Replies
I have this exact same issue, did you find a solution @Rajat ?
in fact my issue is different as it tries to drop the view:
Yes did find the solution for this will drop in sometime.
my solution seems to be this:
https://github.com/drizzle-team/drizzle-orm/discussions/2410#discussioncomment-10815100
(the
tablesFilter
)Yes I tried this way also but it’s not supporting “!” annotation in tablesFilter.
Summarise my solution here: https://vanilla-stop-19c.notion.site/Here-s-how-I-resolved-it-240c4f5e1bc5809db302d9723d75e9b0?source=copy_link
@veksen ^^
Thank you!
So you did the opposite, whitelisted, seems like the blacklist is a new feature? Because it worked for me
Ah so the “!” Works for you, nice. Btw just to confirm do you using same version or different?
And also i visited querydoctor tools seems interesting at first glance, will explore more on later.
I'm on 0.44.1
sure thing 😄 we are shipping a pretty big upgrade this week
Thanks will give it a try
Oh cool, will checkout on weekend