Open loicleray opened 5 months ago
drizzle-orm
0.31.0
drizzle-kit
0.22.1
When using "npx drizzle-kit introspect" the command runs, but does not complete. Throws the following error.
$ npx drizzle-kit introspect drizzle-kit: v0.22.1 drizzle-orm: v0.31.0 No config path provided, using default path Reading config file '...PATH_TO_PROJECT_ROOT/drizzle.config.ts' Pulling from ['public'] list of schemas Using 'postgres' driver for database querying [✓] 18 tables fetched [⢿] 89 columns fetching [✓] 9 enums fetched [⢿] 0 indexes fetching [⢿] 5 foreign keys fetching .../node_modules/drizzle-kit/bin.cjs:21699 const onUpdate = fk4.update_rule.toLowerCase(); ^ TypeError: Cannot read properties of undefined (reading 'toLowerCase') at ..PATH_TO_PROJECT_ROOT/node_modules/drizzle-kit/bin.cjs:21699:48 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Node.js v22.1.0
// config.drizzle.ts import { config } from 'dotenv'; import { defineConfig } from 'drizzle-kit'; import { resolve } from 'path'; // Load environment variables from .env.local // Next JS uses .env.local instead of .env see: https://nextjs.org/docs/basic-features/environment-variables config({ path: [resolve(__dirname, '.env.local'), resolve(__dirname, '.env')], }); // Drizzle-Kit Specific Configuration export default defineConfig({ schema: './src/db/schema.ts', out: './supabase/migrations', dialect: 'postgresql', dbCredentials: { url: process.env.DATABASE_URL!, }, });
Tried trouble shooting. Error replicates with new project using an example schema given in the Supabase/Drizzle docs.
The example schema used:
// dasdf import { pgTable, serial, text, timestamp, integer, varchar, boolean, } from 'drizzle-orm/pg-core'; export const usersTable = pgTable('users_table', { id: serial('id').primaryKey(), name: text('name').notNull(), age: integer('age').notNull(), email: text('email').notNull().unique(), }); export const postsTable = pgTable('posts_table', { id: serial('id').primaryKey(), title: text('title').notNull(), content: text('content').notNull(), userId: integer('user_id') .notNull() .references(() => usersTable.id, { onDelete: 'cascade' }), createdAt: timestamp('created_at').notNull().defaultNow(), updatedAt: timestamp('updated_at') .notNull() .$onUpdate(() => new Date()), }); export type InsertUser = typeof usersTable.$inferInsert; export type SelectUser = typeof usersTable.$inferSelect; export type InsertPost = typeof postsTable.$inferInsert; export type SelectPost = typeof postsTable.$inferSelect;
Run the following commands:
npx drizzle-kit generate npx drizzle-kit migrate npx drizzle-kit pull npx drizzle-kit introspect
Getting same error in shell:
$ npx drizzle-kit introspect drizzle-kit: v0.22.1 drizzle-orm: v0.31.0 No config path provided, using default path Reading config file '..PATH_TO_PROJECT_ROOT/drizzle.config.ts' Pulling from ['public'] list of schemas Using 'postgres' driver for database querying [✓] 2 tables fetched [⣽] 6 columns fetching [✓] 9 enums fetched [⣽] 0 indexes fetching [⣽] 3 foreign keys fetching ..PATH_TO_PROJECT_ROOT/node_modules/drizzle-kit/bin.cjs:21699 const onUpdate = fk4.update_rule.toLowerCase(); ^ TypeError: Cannot read properties of undefined (reading 'toLowerCase') at ..PATH_TO_PROJECT_ROOT/node_modules/drizzle-kit/bin.cjs:21699:48 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Node.js v22.1.0
Would expect it to complete introspection and generate the schema.ts file in the location specified in the config.drizzle.ts file.
Using Supabase and Next JS. Taking database and contents from an existing Django projects.
had the same issue.
changing port per this comment helped: https://github.com/drizzle-team/drizzle-orm/issues/2338#issuecomment-2117496180
Can't understand why a port change would be the fix?
What version of
drizzle-orm
are you using?0.31.0
What version of
drizzle-kit
are you using?0.22.1
Describe the Bug
When using "npx drizzle-kit introspect" the command runs, but does not complete. Throws the following error.
Tried trouble shooting. Error replicates with new project using an example schema given in the Supabase/Drizzle docs.
The example schema used:
Run the following commands:
Getting same error in shell:
Expected behavior
Would expect it to complete introspection and generate the schema.ts file in the location specified in the config.drizzle.ts file.
Environment & setup
Using Supabase and Next JS. Taking database and contents from an existing Django projects.