alassek / activerecord-pg_enum

Integrate PostgreSQL's enumerated types with the Rails enum feature
MIT License
168 stars 10 forks source link

enum helper not working with change_table #7

Closed alassek closed 4 years ago

alassek commented 4 years ago

I assumed that create_table and change_table use the same class but it appears not.

NoMethodError: undefined method `enum' for #<ActiveRecord::ConnectionAdapters::PostgreSQL::Table:0x00007fe990c40bb8>
TylerRick commented 4 years ago

I ran into this too. What's the workaround?

TylerRick commented 4 years ago

Based on https://github.com/alassek/activerecord-pg_enum/blob/master/lib/active_record/pg_enum/4.2/table_definition.rb (I'm using Rails 5.2), I tried adding this to the top of my migration and it ran without errors:

ActiveRecord::ConnectionAdapters::PostgreSQL::Table.include ActiveRecord::PGEnum::TableDefinition
alassek commented 4 years ago

Use add_column for now

On Fri, Nov 15, 2019 at 14:31 Tyler Rick notifications@github.com wrote:

I ran into this too. What's the workaround?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/alassek/activerecord-pg_enum/issues/7?email_source=notifications&email_token=AAAOCNAOBC4B7FRFR3VMTNLQT4BKVA5CNFSM4JK4DOQKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEGUF4Q#issuecomment-554517234, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAOCNFMT5ZYDPRDKMVCUTTQT4BKVANCNFSM4JK4DOQA .