HornsAndHooves / pg_saurus

ActiveRecord extension to get more from PostgreSQL.
Other
27 stars 12 forks source link

Begin support for Rails 6 #40

Closed maneyko closed 2 years ago

maneyko commented 3 years ago

Many of the ActiveRecord internals that PgSaurus relies on have changed from Rails 5 to Rails 6. Beginning support for Rails 6 will require PgSaurus to be bumped up to 5.0.0 and lose compatibility with Rails 5 and below.

Main changes:

I have tested these changes on a medium-sized project locally that uses Rails 6+ and Ruby 2.7+ and am not experiencing any issues.

Further, I have dropped, created, and migrated this app for both Rails 5 and Rails 6 and the dumps are nearly identical. Here is the command I did to create the DB dump:

$ pg_dumpall -c --if-exists -U maneyko --database=$my_apps_database > rails5.sql

The only difference between the dump between rails5.sql and rails6.sql is that Rails 6 adds a constraint on created_at and updated_at timestamp fields:

<     created_at timestamp without time zone NOT NULL,
<     updated_at timestamp without time zone NOT NULL
---
>     created_at timestamp(6) without time zone NOT NULL,
>     updated_at timestamp(6) without time zone NOT NULL
albertosaurus commented 3 years ago

I have a more fundamental question. What does PG Saurus do that Rails 6 doesn't do out of the box?

maneyko commented 3 years ago

I believe there still is some functionality that we get out of PgSaurus but it acts more as a DSL a this point, rather than adding new functionality to Rails. One of the main things PgSaurus supports that Rails does not (I think) is using different schemas within a single Rails application. I did look in to dropping support for PgSaurus but it was easier to just extend it to support Rails 6.

I don't think this is a reason to never support Rails 6 for PgSaurus, but the 5.x versions of PgSaurus can be viewed as a transition to move logic entirely back to Rails.

baburdick commented 3 years ago

@albertosaurus, IIRC PgSaurus is still required to support PG schemas. My (possibly mistaken) understanding is that Rails 6 does not support them, or does not support them as richly as PgSaurus.