Does introspect only generate schema in the "out" (./drizzle) directory?

My config looks like this:
export default defineConfig({
dialect: 'postgresql',
schema: './src/lib/server/db/schema.ts',
dbCredentials: {
url: process.env.POSTGRES_URL
},
verbose: true,
strict: true,
})
export default defineConfig({
dialect: 'postgresql',
schema: './src/lib/server/db/schema.ts',
dbCredentials: {
url: process.env.POSTGRES_URL
},
verbose: true,
strict: true,
})
But if I run introspect, it always generates in ./drizzle Am I doing something wrong or is this expected?
6 Replies
francis
francis•4mo ago
it's always been that way for me, I have a package script to generate the schema and copy it to the target
Darren
Darren•4mo ago
change to:
export default defineConfig({
dialect: 'postgresql',
schema: './src/lib/server/db/schema.ts',
out: './src/lib/server/db/migrations',
dbCredentials: {
url: process.env.POSTGRES_URL
},
verbose: true,
strict: true,
})
export default defineConfig({
dialect: 'postgresql',
schema: './src/lib/server/db/schema.ts',
out: './src/lib/server/db/migrations',
dbCredentials: {
url: process.env.POSTGRES_URL
},
verbose: true,
strict: true,
})
Chris Soul
Chris SoulOP•4mo ago
Wouldn't that also put all the migrations there? I only want the schema
Darren
Darren•4mo ago
well you can just change it to './src/lib/server/db' it will overwrite your exisitng schema and relatiopn file tho, which is prob not what you want but if you want to keep all your migrations seperate and only diff for introspect then you can either use a seperate config file and specify on cli using introspect --config=intro.config.ts or using introspect --out=src/lib/server/db/
Chris Soul
Chris SoulOP•4mo ago
I think I'm overengineering it at this point 😄 I don't need to introspect that often so I'll just manually move them Thank you both though!
francis
francis•4mo ago
here's my commands, fyi "drizzle-kit introspect && npm run postprocess-pulled-schema && mv drizzle/schema.ts src/lib/db/schema.ts", (in a package.json script) postprocess-pulled-schema is an intermediate step I put in that runs sed over the output to change some things - e.g. introspect always pulls timestamp columns in 'string' mode, so I have "shx sed -i \"s/mode: 'string'/mode: 'date'/\" drizzle/schema.ts", to fix those I recommend setting that sort of thing up since it's relatively easy to do and have it be consistent
Want results from more Discord servers?
Add your server