Drizzle Kit Generate renames columns incorrectly
I am running a drizzle-kit generate. It appears to think I added/renamed a column on all of my tables that does not exist. Any help on how or why this is happening would be appreciated!
26 Replies
Did you recently update Drizzle Kit? I know these kind of "unnecessary migrations" happen when breaking changes are introduced in Kit
@Mario564 I have not updated drizzle kit
This is a new repo, and my team has been testing out drizzle, we love the syntax but we are running into so many weird issues with the migration proccess
thanks for the help btw ❤️
Could you give me the definiton of
timestampNotNullDefault
and defaultColumns
?Hmm
Is the variable
startTime
present anywhere in your code? If so, where?Its in another schema file
Ah, I see, I think I might know what's going on
Am I doing something wrong?
Try making
timestampNotNullDefault
a function instead of a variable:
I assume the issue is that timestampNotNullDefault
is applied first to startTime
in event
table, and on subsequent tables, a new reference doesn't get created so it just uses the same one for all other tables
Making a function should create a new reference each time it's called and should fix this issue@Mario564 thank you! I am giving it a shot now
Alright, let me know if that solves it
If it does, I also suggest making
defaultColumns
and primaryKeyDefaultUUID
functions as well, just to avoid future issues with references@Mario564 looks like the issue is persisting
I assume I shoould just get rid of the helpers and define each type manually
there is also no explicit documentation on allowing you to do this, it mentions being able to create objects for commonly used columns, but it also implicitly suggests you can
Do you get prompted to change other columns? This seems to be correct, since the
event
table is the one with startTime
column. This correct behavior unless you get prompted to change more columns on other tablesI got prompted to change other columns
I even removed all the references and explicitly added the timestamp in each table and it is still happening
Is
startTime
defined anywhere else aside from event
table?no
Let's test something: will it work if you explicitly define an alias for the column?
That seemed to stop it from effecting other tables
You might need to use this workaround for the time being, I'm not sure what exactly is going on that causes this behavior
Especially since you mention this, this should work pretty much all the time
@Mario564 I removed all my previous migrations and started from scratch. Thank you again for the help it seems to be fine for now. At least I know some steps to resolve it 👍
Sounds good. I and others will be here to assist if needed