drizzle-kit not detecting tsconfig and getting path alias '~/'

When I try to default to a TS enum, drizzle-kit push fails when i run drizzle-kit push:pg --config=drizzle.config.ts If I just remove the .default(PDF_PARSE_STATUS.PENDING) in my schema (but keep the import import { PDF_PARSE_STATUS } from '~/types';), it will succeed Here's my code: schema.ts
import {
pgTable,
text,
timestamp,
uuid,
varchar,
} from 'drizzle-orm/pg-core';

import { PDF_PARSE_STATUS } from '~/types';

export const UserResumeTable = pgTable('user_resumes', {
id: uuid('id').primaryKey().defaultRandom(),
filename: text('filename').notNull().unique(),
content: text('content'),
status: varchar('status')
.$type<PDF_PARSE_STATUS>()
.default(PDF_PARSE_STATUS.PENDING),
notes: text('notes'),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow(),
});
export const UserResume = UserResumeTable;

export type UserResume = typeof UserResumeTable.$inferSelect;
export type NewUserResume = typeof UserResumeTable.$inferInsert;
import {
pgTable,
text,
timestamp,
uuid,
varchar,
} from 'drizzle-orm/pg-core';

import { PDF_PARSE_STATUS } from '~/types';

export const UserResumeTable = pgTable('user_resumes', {
id: uuid('id').primaryKey().defaultRandom(),
filename: text('filename').notNull().unique(),
content: text('content'),
status: varchar('status')
.$type<PDF_PARSE_STATUS>()
.default(PDF_PARSE_STATUS.PENDING),
notes: text('notes'),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow(),
});
export const UserResume = UserResumeTable;

export type UserResume = typeof UserResumeTable.$inferSelect;
export type NewUserResume = typeof UserResumeTable.$inferInsert;
types.ts
export enum PDF_PARSE_STATUS {
SUCCESS = 'SUCCESS',
FAILED = 'FAILED',
PENDING = 'PENDING',
}
export enum PDF_PARSE_STATUS {
SUCCESS = 'SUCCESS',
FAILED = 'FAILED',
PENDING = 'PENDING',
}
drizzle.config.ts
import 'dotenv/config';
import type { Config } from 'drizzle-kit';

export default {
schema: './src/db/schema/index.ts',
out: './src/db/migrations',
driver: 'pg',
dbCredentials: {
connectionString: process.env.DATABASE_URL!,
},
} satisfies Config;
import 'dotenv/config';
import type { Config } from 'drizzle-kit';

export default {
schema: './src/db/schema/index.ts',
out: './src/db/migrations',
driver: 'pg',
dbCredentials: {
connectionString: process.env.DATABASE_URL!,
},
} satisfies Config;
6 Replies
Monkie
Monkie12mo ago
When you say it fails whats the error?
PGT
PGTOP12mo ago
oh my god I forgot the most important piece of information lol one sec let me get the error
pthieu@Phongs-M1:~/www/commit-playground (main)% pn db:push

> [email protected] db:push /Users/pthieu/www/commit-playground
> drizzle-kit push:pg --config=drizzle.config.ts

drizzle-kit: v0.19.13
drizzle-orm: v0.28.6

Custom config path was provided, using 'drizzle.config.ts'
Reading config file '/Users/pthieu/www/commit-playground/drizzle.config.ts'
Error: Cannot find module '~/types'
Require stack:
- /Users/pthieu/www/commit-playground/src/db/schema/index.ts
- /Users/pthieu/www/commit-playground/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:119:18)
at Object.<anonymous> (/Users/pthieu/www/commit-playground/src/db/schema/index.ts:14:34)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._compile (/Users/pthieu/www/commit-playground/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:8623:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Object.newLoader [as .ts] (/Users/pthieu/www/commit-playground/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:8627:13)
at Module.load (node:internal/modules/cjs/loader:1119:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/pthieu/www/commit-playground/src/db/schema/index.ts',
'/Users/pthieu/www/commit-playground/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs'
]
}
pthieu@Phongs-M1:~/www/commit-playground (main)% pn db:push

> [email protected] db:push /Users/pthieu/www/commit-playground
> drizzle-kit push:pg --config=drizzle.config.ts

drizzle-kit: v0.19.13
drizzle-orm: v0.28.6

Custom config path was provided, using 'drizzle.config.ts'
Reading config file '/Users/pthieu/www/commit-playground/drizzle.config.ts'
Error: Cannot find module '~/types'
Require stack:
- /Users/pthieu/www/commit-playground/src/db/schema/index.ts
- /Users/pthieu/www/commit-playground/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:119:18)
at Object.<anonymous> (/Users/pthieu/www/commit-playground/src/db/schema/index.ts:14:34)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._compile (/Users/pthieu/www/commit-playground/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:8623:30)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Object.newLoader [as .ts] (/Users/pthieu/www/commit-playground/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:8627:13)
at Module.load (node:internal/modules/cjs/loader:1119:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/pthieu/www/commit-playground/src/db/schema/index.ts',
'/Users/pthieu/www/commit-playground/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs'
]
}
Angelelz
Angelelz12mo ago
GitHub
[BUG]: drizzle.config.ts doesn't follow tsconfig.json for modul...
What version of drizzle-orm are you using? ^0.28.6 What version of drizzle-kit are you using? ^0.19.13 Describe the Bug if i import using '@/app/lib/env', it doesn't work but if i impor...
PGT
PGTOP12mo ago
basically it can't detect the types file: Error: Cannot find module '~/types'
Angelelz
Angelelz12mo ago
Somebody there offered a solution, but I just think that relative paths is the way to go
PGT
PGTOP12mo ago
oh so basically just use the --project flag? i guess for the schema file, i can use relative paths, feels cleaner the rest of the app is already working with absolute paths, so should be just the one file
Want results from more Discord servers?
Add your server