[Feature proposal] Migrations-like actions

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

[Feature proposal] Migrations-like actions

Vitaliy Klachkov
Hello!

Sorry if this proposal is a duplicate, I couldn't find anything related.

Quite often I have to run some actions on my application starts.
Those actions should be executed just once like database migrations.

Once an action is executed, it should never be invoked again. 

Right now I do what I need in migrations which is not right as migrations go for database related logic. 
My actions are not related to database (e.g. clean some files, do something with cache, send something to an external service, etc). 

I can use those actions in initialiazers with `if` conditions, but that looks quite weird. 

My proposal is simple. 
Please consider adding a DB migrations-like mechanism for actions that should be run once on start. 

Thank you.

Best wishes, 
Vitaliy.

--
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: [Feature proposal] Migrations-like actions

Prem Sichanugrist
Hi Vitaliy,

I actually think initializer is the right place to put those kind of stuff. Or, maybe do you want to put it in `bin/setup` so you would run it the first time after you clone your application?

Alternatively, there are a few data migration gems that you could use, but I think that's still not what you are looking for either, right?

Thank you,
Prem

On Nov 24, 2017, at 9:34 AM, Vitaliy Klachkov <[hidden email]> wrote:

Hello!

Sorry if this proposal is a duplicate, I couldn't find anything related.

Quite often I have to run some actions on my application starts.
Those actions should be executed just once like database migrations.

Once an action is executed, it should never be invoked again. 

Right now I do what I need in migrations which is not right as migrations go for database related logic. 
My actions are not related to database (e.g. clean some files, do something with cache, send something to an external service, etc). 

I can use those actions in initialiazers with `if` conditions, but that looks quite weird. 

My proposal is simple. 
Please consider adding a DB migrations-like mechanism for actions that should be run once on start. 

Thank you.

Best wishes, 
Vitaliy.

--
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.

--
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: [Feature proposal] Migrations-like actions

Vitaliy Klachkov
Hi Prem, 

I actually think initializer is the right place to put those kind of stuff

I don't think initializers are the right place for actions that have to be run just once. 
They are good for setting initial states/configuration of various parts of an application though.
Following this logic, we could say that initializers are the right place for database migrations.

Or, maybe do you want to put it in `bin/setup` so you would run it the first time after you clone your application?

No, I want to run things just once and save their states (have been run or not). 
The same thing as database migrations do. 

Alternatively, there are a few data migration gems that you could use, but I think that's still not what you are looking for either, right?

Actually, they are quite what I need. 

I wrote this email just to figure out what the community / core team thinks about adding such feature in Rails. :)


Best wishes, 
Vitaliy



On Fri, Nov 24, 2017 at 12:28 PM, Prem Sichanugrist <[hidden email]> wrote:
Hi Vitaliy,

I actually think initializer is the right place to put those kind of stuff. Or, maybe do you want to put it in `bin/setup` so you would run it the first time after you clone your application?

Alternatively, there are a few data migration gems that you could use, but I think that's still not what you are looking for either, right?

Thank you,
Prem

On Nov 24, 2017, at 9:34 AM, Vitaliy Klachkov <[hidden email]> wrote:

Hello!

Sorry if this proposal is a duplicate, I couldn't find anything related.

Quite often I have to run some actions on my application starts.
Those actions should be executed just once like database migrations.

Once an action is executed, it should never be invoked again. 

Right now I do what I need in migrations which is not right as migrations go for database related logic. 
My actions are not related to database (e.g. clean some files, do something with cache, send something to an external service, etc). 

I can use those actions in initialiazers with `if` conditions, but that looks quite weird. 

My proposal is simple. 
Please consider adding a DB migrations-like mechanism for actions that should be run once on start. 

Thank you.

Best wishes, 
Vitaliy.

--
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.

--
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.

--
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: [Feature proposal] Migrations-like actions

Xavier Noria
Can you provide concrete use cases?
--
Sent from Gmail Mobile

--
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: [Feature proposal] Migrations-like actions

Rory Oconnell
In reply to this post by Vitaliy Klachkov
Hi!

I wrote a gem which does exactly this: https://github.com/consultingMD/schlepper. 

It's an extraction of a basic system I had inside of our monorail. It has been in use in production for us for about 18 months. It's modeled similar to AR migrations by design. Task classes are subclasses of a base class. The task runner creates a table similar to AR migrations. The task class file names are versioned exactly like AR migrations. Upon running the rake command to run the tasks, it performs the same system as AR migrations. It finds all task files not yet run and executes them one by one. The one major difference is the design of the task running system is each class is independent. If one fails, the task runner continues. AR migrations are designed for linearity. 

On Thursday, November 23, 2017 at 4:35:50 PM UTC-8, Vitaliy Klachkov wrote:
Hello!

Sorry if this proposal is a duplicate, I couldn't find anything related.

Quite often I have to run some actions on my application starts.
Those actions should be executed just once like database migrations.

Once an action is executed, it should never be invoked again. 

Right now I do what I need in migrations which is not right as migrations go for database related logic. 
My actions are not related to database (e.g. clean some files, do something with cache, send something to an external service, etc). 

I can use those actions in initialiazers with `if` conditions, but that looks quite weird. 

My proposal is simple. 
Please consider adding a DB migrations-like mechanism for actions that should be run once on start. 

Thank you.

Best wishes, 
Vitaliy.

--
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: [Feature proposal] Migrations-like actions

Xavier Noria
On Thu, Nov 30, 2017 at 1:00 AM, Rory Oconnell <[hidden email]> wrote:

Hi!

I wrote a gem which does exactly this: https://github.com/consultingMD/schlepper

It's an extraction of a basic system I had inside of our monorail. It has been in use in production for us for about 18 months. It's modeled similar to AR migrations by design. Task classes are subclasses of a base class. The task runner creates a table similar to AR migrations. The task class file names are versioned exactly like AR migrations. Upon running the rake command to run the tasks, it performs the same system as AR migrations. It finds all task files not yet run and executes them one by one. The one major difference is the design of the task running system is each class is independent. If one fails, the task runner continues. AR migrations are designed for linearity.

Nice!
 

--
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: [Feature proposal] Migrations-like actions

Jason Fleetwood-Boldt

I maintain a gem here which I think has some cross-purpose for that need


it's stated purpose is for data migrations but it sounds like you can use it for your use case almost as-is.

-Jason


On Nov 29, 2017, at 7:26 PM, Xavier Noria <[hidden email]> wrote:

On Thu, Nov 30, 2017 at 1:00 AM, Rory Oconnell <[hidden email]> wrote:

Hi!

I wrote a gem which does exactly this: https://github.com/consultingMD/schlepper

It's an extraction of a basic system I had inside of our monorail. It has been in use in production for us for about 18 months. It's modeled similar to AR migrations by design. Task classes are subclasses of a base class. The task runner creates a table similar to AR migrations. The task class file names are versioned exactly like AR migrations. Upon running the rake command to run the tasks, it performs the same system as AR migrations. It finds all task files not yet run and executes them one by one. The one major difference is the design of the task running system is each class is independent. If one fails, the task runner continues. AR migrations are designed for linearity.

Nice!
 

--
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.

If you'd like to reply by encrypted email you can find my public key on jasonfleetwoodboldt.com (more about setting GPG: https://gpgtools.org

--
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.