Quick Q about migrations (still experimental, I kn...
# orm-help
r
Quick Q about migrations (still experimental, I know) and Postgres support in v2. Currently in Postgres, you can’t add columns in specific positions (i.e., not at the end of the table) without actually creating a new table based on the old but with the new column in position, copying over data, dropping the old table, and then renaming the new. Is this in the purview of the migrations team? A bit obscure example, I know, but just wondering how deep y’all are thinking about migrations.
r
Hey @Robert Hall 👋 Could you create a feature request here explaining the above use case?
j
This is something that we ignored in the past and will look into in the future: https://github.com/prisma/prisma/issues/2554
We focused a lot on introspecting databases for 2.0 (so creating a schema based on an existing database), and had some initial problems getting the correct order out of the database in all our database systems that we care about.
Now with 2.0 being done, we will investigate more how we can fix this, which will then possibly lead to the fields in your model having meaning - which would be translated to of course also being considered in Migrations.
Does that make sense @Robert Hall?
r
Makes perfect sense, and glad it’s on your radar.
FYI, I’ve run into real use cases in actual work (I’ve needed createdAt, updatedAt, deletedAt columns in specific positions for HIIPA compliance reasons)
j
Uh wow!
We just added this issue as a "bonus" one for the next release, so we will hopefully get to investigate this a bit.
r
Look like you guys already have a ticket, so I don’t need to open one, yes?
j
Would be nice if you could leave a comment on it, to show the direct user impact this would have.
r
Tell me where to leave a comment, and I’ll leave one.
j
r
cool
j
Until then you can of course fix the order of the columns manually with the tool of your choice.
Not what you are looking for of course, but a workaround until we caught up.
r
yup
j
Absolutely perfect.
r
Cool
j
Order will probably be that Introspection can pick it up correctly first, then on table creation with migrate and last changing the order of columns in tables.
Just to give you some context on what we are looking at here.
👍 1
r
Yeah, it’s definitely a weird dance