Git Product home page Git Product logo

Comments (10)

alassek avatar alassek commented on August 29, 2024 4

Native enums are supported by 7, so I'll probably do one more release to officially deprecate this library so people can migrate their schemas.

from activerecord-pg_enum.

soffes avatar soffes commented on August 29, 2024 4

@alassek I have really enjoyed using your gem. Thanks so much for all of your work! ❤️

from activerecord-pg_enum.

alassek avatar alassek commented on August 29, 2024 2

@soffes thank you, I glad that it was useful! Lately I've been much happier working with ROM, so it's just as well that Rails is obsoleting this gem.

The major difference is that my syntax was t.enum :column_name, as: "sql_type" and rails is t.enum :column_name, enum_type: "sql_type". I think mine reads better but whatever.

As for the module builder, my recommendation is to just copy-paste the code into your project. It's a very small part of the gem, not really worth the dependency on its own.

from activerecord-pg_enum.

jasonfb avatar jasonfb commented on August 29, 2024 1

Nevermind, this is now in Rails 7.

When upgrading to Rails 7, you will remove this gem and:

replace the model enum defs

PGEnum()

with the default rails

enum thing: {..}

and in the rails migration as on the setting for the enum field becomes enum_type
https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/lectures/36600895
otherwise, Rails 7 seems to

covered recently in my Hot Glue tutorial
https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/lectures/36600895

from activerecord-pg_enum.

soffes avatar soffes commented on August 29, 2024

@alassek if you have the time, it would really appreciate a guide for how to adopt the Rails 7 things. I was able to figure out the model changes, but I'm having trouble finding how to update the migrations other using using plain SQL.


For others, this is what I in my models:

KINDS = %w[foo bar]

# Before
include PGEnum(kind: KINDS, _suffix: true)

# After
enum :kind, KINDS.index_by(&:to_sym), suffix: true

Also the Rails 7 docs say _suffix: but it's actually suffix:.

from activerecord-pg_enum.

rayfaddis avatar rayfaddis commented on August 29, 2024

Rails 7 added better enum model support for PG enums though only added the create_enum migration command so this gem still offers\offered some nice and additional things.

See my Rails 7 PR that adds all of the migration commands to Rails 7 rails/rails#44898

from activerecord-pg_enum.

alassek avatar alassek commented on August 29, 2024

@rayfaddis That's a fair point. I will release a new version with only the additional stuff.

from activerecord-pg_enum.

alassek avatar alassek commented on August 29, 2024

Version 2.0 has been released for Rails 7, there are a couple breaking interface changes. See CHANGELOG for more info

from activerecord-pg_enum.

jasonfb avatar jasonfb commented on August 29, 2024

@alassek - can you explain what advantage this gem has over the native Rails 7 tools?

from activerecord-pg_enum.

alassek avatar alassek commented on August 29, 2024

@jasonfb Everything that Rails 7 has implemented has been dropped from 2.0 but there were some additional migration helpers that they didn't implement:

  • drop_enum
  • rename_enum
  • add_enum_value
  • rename_enum_value

from activerecord-pg_enum.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.