{"action":"closed","issue":{"url":"https://api.github.com/repos/vapor/postgresql/issues/92","repository_url":"https://api.github.com/repos/vapor/postgresql","labels_url":"https://api.github.com/repos/vapor/postgresql/issues/92/labels{/name}","comments_url":"https://api.github.com/repos/vapor/postgresql/issues/92/comments","events_url":"https://api.github.com/repos/vapor/postgresql/issues/92/events","html_url":"https://github.com/vapor/postgresql/issues/92","id":341392753,"node_id":"MDU6SXNzdWUzNDEzOTI3NTM=","number":92,"title":"Nested enums with same name overwrite each other","user":{"login":"clayellis","id":10712068,"node_id":"MDQ6VXNlcjEwNzEyMDY4","avatar_url":"https://avatars0.githubusercontent.com/u/10712068?v=4","gravatar_id":"","url":"https://api.github.com/users/clayellis","html_url":"https://github.com/clayellis","followers_url":"https://api.github.com/users/clayellis/followers","following_url":"https://api.github.com/users/clayellis/following{/other_user}","gists_url":"https://api.github.com/users/clayellis/gists{/gist_id}","starred_url":"https://api.github.com/users/clayellis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clayellis/subscriptions","organizations_url":"https://api.github.com/users/clayellis/orgs","repos_url":"https://api.github.com/users/clayellis/repos","events_url":"https://api.github.com/users/clayellis/events{/privacy}","received_events_url":"https://api.github.com/users/clayellis/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-07-16T05:16:55Z","updated_at":"2018-07-16T06:45:36Z","closed_at":"2018-07-16T06:45:36Z","author_association":"NONE","body":"I'm seeing a behavior with `PostgreSQLEnum` that may need to be changed or documented as it is definitely something that isn't easily debugged. \r\n\r\nIf you have two nested enums with the same name, .e.g: `Category.Kind` and `Transaction.Kind`, the `postgreSQLEnumTypeName` for both will be the same (`KIND`). This means that when the migrations are run, the first will be overridden by the second. Inspecting the psql db and querying for types using `\\dT` confirms this with a single listing for `kind`. \r\n\r\nThis is potentially misleading behavior as I should reasonably expect that since `Category.Kind` and `Transaction.Kind` are both unique enums in Swift, that the default migrations should provide two unique psql enums (perhaps `category_kind` and `transaction_kind`). \r\n\r\nI haven't confirmed this behavior with other databases.\r\n\r\n#### Current workarounds are:\r\n\r\n~1. Provide a `static` `postgreSQLEnumTypeName` (`\"CATEGORY_KIND\"`). Preferred, but it seems like this could be default behavior.~ (Doesn't actually work, causes a crash while migrating the second enum. I'll look into what's causing the crash.)\r\n2. Don't nest the `enum`s and use a prefix (`Category.Kind` > `CategoryKind`). Not preferred because it's less Swifty.\r\n3. Choose unique names for each `enum` (`Category.Kind`, `Transaction.Style`). Not preferred because it's not very scalable across a large project, (the list of synonyms for \"type/kind\" is short.)"}}
{"actor":{"display_login":"clayellis"}}