Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENUM changes not creating migration changes for columns with a ENUM[] type #203

Open
mjeti opened this issue Apr 8, 2022 · 6 comments
Open
Labels

Comments

@mjeti
Copy link

mjeti commented Apr 8, 2022

say we had a table with two enum based columns where one is a enum val and one is a list.
If I change the entities in the underlying enum type, no migration statement is generated for the column with a enum list type.

test_enum: [val_1, val_2]
test_table
 column_enum        test_enum
 column_enum_list      test_enum[]

I changed the test_enum type to
test_enum: [val_1, val_2, val_3]

a migration would be generated as so

alter type "public"."test_enum" rename to "test_enum__old_version_to_be_dropped";

create type "public"."test_enum" as enum ('val_1', 'val_2', 'val_3');

alter table "public"."test_table" alter column column_enum type "public"."test_enum" using column_enum::text::"public"."test_enum";

drop type "public"."test_enum__old_version_to_be_dropped";

this will fail because it will complain about test_table.column_enum_list still using the []test_enum__old_version_to_be_dropped type.

@maximsmol maximsmol added the bug label Apr 13, 2022
@mjeti
Copy link
Author

mjeti commented Apr 15, 2022

thanks @maximsmol! Any idea if this is something that can be fixed?

@maximsmol
Copy link
Collaborator

Sorry, didn't check GitHub notifs for a few days after going over the issues backlog.

Seems like it's not detecting the list-of-enums column as dependent on the enum's definition. Should be an easy fix if you wanna have a go at it, I'll be doing a bunch of project-wide things for a while before I get to specific issues.

@mjeti
Copy link
Author

mjeti commented Apr 25, 2022

Cool. Could you point in a direction of where the code change would need to happen?

gjbadros added a commit to gjbadros/schemainspect that referenced this issue May 27, 2023
… manage dependencies correctly so those enums can be changed; I think this fixes djrobstep/migra#203 on the related migra package
@gjbadros
Copy link

I think I have working fix (that at least works for my limited very similar scenario). The patch is just on the relations query of the schemainspect dependency. See:

gjbadros/schemainspect@59c7ab0

@joshainglis
Copy link

I've also got a generic array dependency handling over here (it's mixed in with handling comments also)
joshainglis/schemainspect@9d79b0d...joshainglis:schemainspect:master

As well as adding a topological sort of the table dependencies to handle tables with array types joshainglis/migra@0a9a62c...joshainglis:migra:master

@gjbadros
Copy link

Oh awesome, thanks @joshainglis -- comments is another thing on my list that I do poorly (and they matter for postgraphile lots). @djrobstep are you interested in PRs for these improvements?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants