Closed holahoon closed 2 weeks ago
have similar problems. Check following bug.
Found the solution.
In my directory where it contains multiple schema files, I named them as <some_name>.schema.ts
. I also have an index.ts
file which exports all the schemas.
I've set the schema
field my drizzle.config.ts
file set to ./src/lib/db/schema/*
. I think the problem relates to how all my <name>.schema.ts
files along with theindex.ts
file is picked up by drizzle-kit. Not sure what the issue is, but I've set the schema
path to ./src/lib/db/schema/index.ts
and it works 🤷♂️
What version of
drizzle-orm
are you using?0.31.2
What version of
drizzle-kit
are you using?0.22.7
Describe the Bug
Running
drizzle-kit generate
doesn't detect schema changes and doesn't generate updated migration file. I dropped all of my migrations and cleared/deleted all the tables from the database(postgres) so that I can start fresh. Made changes to the table schema and randrizzle-kit generate --config=drizzle.config.ts
to start generating the updated schemas. Some changes in certain tables were picked up, but other tables were missing the newly created columns. I wonder why only partial columns were recognized when generating.Expected behavior
I'm expecting the
id
column with it being the primary key to be added. But looking at the snapshot, it still shows thename
column being the primary key(which it was set to be primary key previously, but I changed it by addingid
column and assigning this column to be the primary key).I tried adding an extra
testField
field to this table:This is the latest snapshot.json file creating after running
drizzle-kit generate
:It still doesn't pick up the newly created column
test_field
.terminal
By looking at the above message,
drizzle-kit generate
doesn't pick up changes in the table schema files.Environment & setup
Her's my
drizzle.config.ts