Would the ability to run sql before|after|around a migration be useful in rails?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Would the ability to run sql before|after|around a migration be useful in rails?

Jason Kenney
One issue I stumble on often is Postgres sql dependencies for advanced structure and rails migrations.

Scenic is helpful if its just views, but.... I actually think its approach can get in the way after you have something_vw_56.sql...

What would be REALLY helpful is if rails had built-in-hooks to just specify sql code that can run either:
- before the migration sequence
- after the migration sequence
- before a schema load (but after database creation)
- after schema load
- around a migration that has a particular tag associated with it (so you can drop specific materialized views, indexes, and recreate them only for a particular migration, and not on every single migration).


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Would the ability to run sql before|after|around a migration be useful in rails?

samsinite
I'd like to at least see support for SQL view migrations in rails, especially since ActiveRecord already supports read only models for SQL views fairly well. I feel that scenic personally does a fairly good job, and I'd understand if the majority of rails maintainers don't want to add to the rails maintenance burden for SQL view migration support. What would wrapping the entire migrations sequence be used for? Better ways to wrap and augment schema generation could be improved IMO. Thoughts?

On Saturday, March 9, 2019 at 7:14:51 AM UTC-8, Jason Kenney wrote:
One issue I stumble on often is Postgres sql dependencies for advanced structure and rails migrations.

Scenic is helpful if its just views, but.... I actually think its approach can get in the way after you have something_vw_56.sql...

What would be REALLY helpful is if rails had built-in-hooks to just specify sql code that can run either:
- before the migration sequence
- after the migration sequence
- before a schema load (but after database creation)
- after schema load
- around a migration that has a particular tag associated with it (so you can drop specific materialized views, indexes, and recreate them only for a particular migration, and not on every single migration).


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/8ed25528-52e9-462d-963a-e85f752e22d4%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Would the ability to run sql before|after|around a migration be useful in rails?

Colin Ross
In reply to this post by Jason Kenney
There is a similar gem for handling triggers and functions named fx (https://github.com/teoljungberg/fx)

I believe the rationale for keeping this out of rails core has to due with two pretty big knock on effects it would have:
  1) The mess of supporting across active record and endless false bug reports for things like "Custom function migration doesn't work in development but works in prod" b/c they are using sqlite in dev, etc.
  2) It would lock apps to SQL-based dumps (db/schema.sql) in many cases, which is less than optimal from a code management point of view (at least imho) since the diffs tend to be very messy.

The migrator (including the command recorder and allowing for dynamically built reversals) would get terribly complicated if it had to support arbitrary sql getting injected

On Saturday, March 9, 2019 at 7:14:51 AM UTC-8, Jason Kenney wrote:
One issue I stumble on often is Postgres sql dependencies for advanced structure and rails migrations.

Scenic is helpful if its just views, but.... I actually think its approach can get in the way after you have something_vw_56.sql...

What would be REALLY helpful is if rails had built-in-hooks to just specify sql code that can run either:
- before the migration sequence
- after the migration sequence
- before a schema load (but after database creation)
- after schema load
- around a migration that has a particular tag associated with it (so you can drop specific materialized views, indexes, and recreate them only for a particular migration, and not on every single migration).


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/bcdb0d3a-7261-4fbb-a544-b1ca3be84a58%40googlegroups.com.