This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PostgresEnum | |
extend ActiveSupport::Concern | |
class_methods do | |
def postgres_enum_for(column, type_name:) | |
enums = ActiveRecord::Base.connection.exec_query <<-SQL | |
SELECT pg_enum.enumlabel AS enumlabel | |
FROM pg_type | |
JOIN pg_enum | |
ON pg_enum.enumtypid = pg_type.oid |