migratus icon indicating copy to clipboard operation
migratus copied to clipboard

Allow for future migrations that are not run until the timestamp on the migration has passed

Open sirmspencer opened this issue 1 year ago • 10 comments

Add an optional input to migratus/create that sets the date X days in the future, and then update migratus/migrate to skip those.

The use case is for when the table structure changes so that there is an old table or column that needs to be cleaned up. This would let me create that clean up for 30 days when I know all the other code changes have taken place.

sirmspencer avatar Jun 20 '23 18:06 sirmspencer

That sounds like it would be a reasonable idea. Should be easy enough to pass an additional flag for this and then filter against it when selecting the migrations to run.

yogthos avatar Jun 20 '23 19:06 yogthos

I can take care of it. Do you want two flags? 1 for migratus/create to generate the future timestamp, and 1 for migratus/migrate to skip future migrations?

sirmspencer avatar Jun 20 '23 19:06 sirmspencer

Sounds great, and that would make sense, maybe create could take an additional argument to specify the start time explicitly then and if it's provided use that instead of generating the timestamp.

yogthos avatar Jun 20 '23 21:06 yogthos

Sounds great, and that would make sense, maybe create could take an additional argument to specify the start time explicitly then and if it's provided use that instead of generating the timestamp.

For which of the functions?

sirmspencer avatar Jun 20 '23 21:06 sirmspencer

(mig/create {:future-days 30} title :edn)

(mig/migrate {:to :now})

(mig/migrate {:to "20230526202953"})

??

sirmspencer avatar Jun 20 '23 21:06 sirmspencer

This could be added later, but I wouldn't do it in this pr.

(mig/rollback {:to "20230526202953"})

sirmspencer avatar Jun 20 '23 21:06 sirmspencer

Yeah, I think human readable format would be ideal here for create. :) And migrate to :now or explicit timestamp sounds good.

yogthos avatar Jun 20 '23 22:06 yogthos

Default to :now or not? Its bordering on breaking, but I would also guess that with mig/create, no one is making future dates manually.

sirmspencer avatar Jun 20 '23 22:06 sirmspencer

I think defaulting to :now would be reasonable, that's basically the implicit behavior right now.

yogthos avatar Jun 20 '23 23:06 yogthos

I think defaulting to :now would be reasonable, that's basically the implicit behavior right now.

Perfect. That is what I was thinking too.

sirmspencer avatar Jun 20 '23 23:06 sirmspencer