Issue with Drizzle ORM and drizzle-kit push with Tembo Cloud PostgreSQL

Hello everyone, I'm currently working on a project using Drizzle ORM with PostgreSQL hosted on Tembo Cloud. My PostgreSQL database has the pg_stat_statements extension installed by default. I'm encountering an issue when trying to push my schema changes using drizzle-kit. Issue: When I attempt to push my schema changes using drizzle-kit, I receive a warning about dropping pg_stat_statements and pg_stat_statements_info tables, which would cause data loss. Here are the relevant outputs:
Warning You are about to execute current statements:

DROP TABLE "pg_stat_statements_info" CASCADE;
DROP TABLE "pg_stat_statements" CASCADE;
ALTER TABLE "tbl_users" ADD CONSTRAINT "tbl_users_id_unique" UNIQUE("id");

Warning Found data-loss statements:
· You're about to delete pg_stat_statements_info table with 1 items
· You're about to delete pg_stat_statements table with 109 items

THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED

Do you still want to push changes?
❯ No, abort
Yes, I want to remove 2 tables,
Warning You are about to execute current statements:

DROP TABLE "pg_stat_statements_info" CASCADE;
DROP TABLE "pg_stat_statements" CASCADE;
ALTER TABLE "tbl_users" ADD CONSTRAINT "tbl_users_id_unique" UNIQUE("id");

Warning Found data-loss statements:
· You're about to delete pg_stat_statements_info table with 1 items
· You're about to delete pg_stat_statements table with 109 items

THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED

Do you still want to push changes?
❯ No, abort
Yes, I want to remove 2 tables,
Question: How can I prevent Drizzle ORM from attempting to drop these pg_stat_statements tables? I've tried using the tablesFilter and extensionsFilters settings, but it doesn't seem to work as expected. Any guidance or suggestions would be greatly appreciated! Repository: You can find the project repository here: next-graphlq-clerk-drizzle-all-in-one Thank you in advance for your help!
GitHub
apollo-graphql-clerk-drizzle-psql/next-graphlq-clerk-drizzle-all-in...
Contribute to jacksonkasi1/apollo-graphql-clerk-drizzle-psql development by creating an account on GitHub.
No description
No description
2 Replies
Jackson Kasi
Jackson Kasi4mo ago
Details: - Database: PostgreSQL on Tembo Cloud (OLTP stack) - Extension Installed: pg_stat_statements Schema Definition:
// db/user.ts
import { integer, pgTable, text, timestamp } from "drizzle-orm/pg-core";

export const tbl_users = pgTable("tbl_users", {
id: integer("id").notNull().primaryKey().unique(),
name: text("name").notNull(),
email: text("email").notNull(),
profile: text("profile"), // profile image link
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
});
// db/user.ts
import { integer, pgTable, text, timestamp } from "drizzle-orm/pg-core";

export const tbl_users = pgTable("tbl_users", {
id: integer("id").notNull().primaryKey().unique(),
name: text("name").notNull(),
email: text("email").notNull(),
profile: text("profile"), // profile image link
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at").notNull().defaultNow(),
});
Drizzle Configuration:
// drizzle.config.ts
import { defineConfig } from "drizzle-kit";
import { env } from "@/config";

export default defineConfig({
schema: "./src/db",
dialect: "postgresql",
dbCredentials: {
url: env.DATABASE_URL!,
},
verbose: true,
strict: true,
out: "./drizzle",
migrations: {
table: 'drizzle_migrations',
schema: 'public',
},
tablesFilter: ['pg_stat_*'],
extensionsFilters: ["postgis"],
schemaFilter: ["public"],
});
// drizzle.config.ts
import { defineConfig } from "drizzle-kit";
import { env } from "@/config";

export default defineConfig({
schema: "./src/db",
dialect: "postgresql",
dbCredentials: {
url: env.DATABASE_URL!,
},
verbose: true,
strict: true,
out: "./drizzle",
migrations: {
table: 'drizzle_migrations',
schema: 'public',
},
tablesFilter: ['pg_stat_*'],
extensionsFilters: ["postgis"],
schemaFilter: ["public"],
});
Jackson Kasi
Jackson Kasi4mo ago
THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED

Do you still want to push changes?
error: "pg_stat_statements_info" is not a table
at D:\WORK\POC\Graphql\apollo-graphql-clerk-drizzle-psql\next-graphlq-clerk-drizzle-all-in-one\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\bin.cjs:77696:15
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.query (D:\WORK\POC\Graphql\apollo-graphql-clerk-drizzle-psql\next-graphlq-clerk-drizzle-all-in-one\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\bin.cjs:119635:26)
at async pgPush (D:\WORK\POC\Graphql\apollo-graphql-clerk-drizzle-psql\next-graphlq-clerk-drizzle-all-in-one\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\bin.cjs:122560:13)
at async _Command.<anonymous> (D:\WORK\POC\Graphql\apollo-graphql-clerk-drizzle-psql\next-graphlq-clerk-drizzle-all-in-one\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\bin.cjs:129681:7) {
length: 143,
severity: 'ERROR',
code: '42809',
detail: undefined,
hint: 'Use DROP VIEW to remove a view.',
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'tablecmds.c',
line: '1328',
routine: 'DropErrorMsgWrongType'
}
THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED

Do you still want to push changes?
error: "pg_stat_statements_info" is not a table
at D:\WORK\POC\Graphql\apollo-graphql-clerk-drizzle-psql\next-graphlq-clerk-drizzle-all-in-one\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\bin.cjs:77696:15
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.query (D:\WORK\POC\Graphql\apollo-graphql-clerk-drizzle-psql\next-graphlq-clerk-drizzle-all-in-one\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\bin.cjs:119635:26)
at async pgPush (D:\WORK\POC\Graphql\apollo-graphql-clerk-drizzle-psql\next-graphlq-clerk-drizzle-all-in-one\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\bin.cjs:122560:13)
at async _Command.<anonymous> (D:\WORK\POC\Graphql\apollo-graphql-clerk-drizzle-psql\next-graphlq-clerk-drizzle-all-in-one\node_modules\.pnpm\[email protected]\node_modules\drizzle-kit\bin.cjs:129681:7) {
length: 143,
severity: 'ERROR',
code: '42809',
detail: undefined,
hint: 'Use DROP VIEW to remove a view.',
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'tablecmds.c',
line: '1328',
routine: 'DropErrorMsgWrongType'
}
No description
Want results from more Discord servers?
Add your server