Cal
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
ignore me, order of enums fixed everything, thanks for all the help folks
75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
ah, order is important as stated 🙂
75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
sorry to be back so soon 😄
75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
no worries at all, was fun to get more of an understanding, awesome stuff, thanks!
75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
👍 thought so 🙂
75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
Well I think I am in this scenario now, given that the
migrate
has brought me here and I'll have to write a script to correct the issue or am I missing something here?75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
oh 100%
75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
this looks very appealing indeed,
enum
's always seem to cause issues hey? 😄75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
thank you @Andrew Sherman for the explanation here; the crux of this issue stems from the fact that
generate
/migrate
allowed the DB to get into this state in the first place (due to the out of sync enum values - of course you should error, because otherwise developers would be relying on the fact they could have value A
/B
but some one could insert value C
if they did it directly in the DB and cause all sorts of issues)
So in terms of rectifying already broken migration files, what do you think the best cause of action should be here? Given that a temp fix to manually sort it is fine, although if other developers are working on the platform, I'd hate to explain that after the migrate
they need to run a random script to fix the issue?75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
good stuff, I am glad that the flow makes sense as it feels like a natural DX to do that 🙂
75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
We are doing exactly it, so push is reading pg_enum and other tables for all needed info and then read ts schema and search for a difference. As long as you have 3 values in ts schema and 5 enum values in database - it means you removed 2 of themSo in this case, correct that I removed the value from the
enum
on the drizzle-orm
side of things, generated migrations with generate
then migrate
'd them into the db at some point over the evolution of the application as my needs changed
I think the problem is that the push
is now trying to re-insert the enum value even though it's in the db? (and I agree, there are more values in db due to the limitations of pg_enum
etc)75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
I suppose that's the scenario that I was referencing, was a quick-setup of the database with good known migrations, then
push
to test out local changes thereafter, but is that something that you'd not recommend and just push
straight from the schema?75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
thanks @Andrew Sherman, just for clarification then, with the existing migrations, they are currently set up so that they will
add
values to an enum
and keep the existing ones in place - I did read that article in my attempt at debugging this before reaching out for the support 😄
So that means if I were to use migrate
on a new DB instance, then use push
to manage further testing/updates, this issue would pop up again surely?
just wondering what the DX would look like;
migrate
on a new db instance
drop
enum (and all columns
that depend on it)
then run push
to add the enum
values back in and then also re-create the columns that are missing?
i suppose, instead of throwing an error
, if we detect that an enum value is already in the pg_enum
, it is essentially a no-op and does not attempt to insert?75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
i can try and spin up a new instance of db and run everything in again with a fresh
migrate
?75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
nope, only ran in via migrations
75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
Same issue;
75 replies
DTDrizzle Team
•Created by Cal on 5/22/2024 in #help
drizzle-kit push inconsistent with database with migrations already applied
give me 2 mins
75 replies