squasher icon indicating copy to clipboard operation
squasher copied to clipboard

Use Rails 7 migrations by default

Open dankimio opened this issue 6 years ago • 12 comments

dankimio avatar Oct 04 '18 07:10 dankimio

@jalkoby

Would you be happy to merge a PR implementing this feature request? :slightly_smiling_face:

blackst0ne avatar Feb 19 '19 01:02 blackst0ne

Hi @blackst0ne , yes it makes sense as rails 5+ is only maintained. so please do it

jalkoby avatar Feb 21 '19 11:02 jalkoby

Any news? When generating migrations, the [5.2] after < ActiveRecord::Migration is not added, blocking automatic migrations. It's easy to add it by hand afterwards, but would be nice if it was already there. Thanks for the very nice gem!

qortex avatar May 26 '19 15:05 qortex

Any plan for such an easy fix guys?

qortex avatar Mar 04 '20 17:03 qortex

Ok, actually found out giving an argument on the command line fixes the issue: --migration=5.0. Going to 6.0 doesn't seem to work, but not a problem :)

qortex avatar Mar 04 '20 18:03 qortex

not yet, don't have time at the moment

jalkoby avatar Mar 06 '20 19:03 jalkoby

@jalkoby Maybe I could help with a PR? I'd just need some directions on which files to update / change.

dankimio avatar Mar 07 '20 06:03 dankimio

sorry for a long response. here's a thing - the next major release should rework the whole concept of squasher. instead to be an automated shell script(driven by ruby) it will be an integrated rake wrapper which will hack the core rails schema generation tasks. so I don't think it's a good idea to tweak the existent code

jalkoby avatar Mar 16 '20 22:03 jalkoby

@jalkoby hey! Any news about the next major release date?

alec-c4 avatar Jun 30 '21 21:06 alec-c4

Just installed the gem, and ran squasher clean in a Rails 7 project, and got:

rake aborted!
StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Active Record release the migration was written for:

  class SquasherClean < ActiveRecord::Migration[7.0]
/Users/pboling/src/command_center/db/migrate/20230213193907_squasher_clean.rb:1:in `<main>'
/Users/pboling/.asdf/installs/ruby/2.7.7/bin/bundle:25:in `load'
/Users/pboling/.asdf/installs/ruby/2.7.7/bin/bundle:25:in `<main>'

Question: Does this gem still work?

Answer: Maybe? But... you need to run:

squasher clean --migration=7.0

Or, at least it doesn't raise an error that way. It also doesn't remove the squashed migrations, which I was expecting it to do... Actually it didn't do anything it should have.

So then I tried:

❯ squasher 2023 --migration=7.0
Squasher is creating a tmp database
rake aborted!
ActiveRecord::AdapterNotSpecified: database configuration does not specify adapter
/Users/pboling/src/command_center/config/environment.rb:5:in `<main>'
/Users/pboling/.asdf/installs/ruby/2.7.7/bin/bundle:25:in `load'
/Users/pboling/.asdf/installs/ruby/2.7.7/bin/bundle:25:in `<main>'

The strange thing is, my database configuration does specify an adapter, but perhaps this gem can't handle the multi-db style yaml config?

Seems to be not working with Rails 7.

pboling avatar Feb 13 '23 19:02 pboling

running into the same bug with a multi db yaml

omarluq avatar Mar 09 '23 02:03 omarluq

This solution works for me in Rails 7:

squasher 2023 --migration=7.0

dpaluy avatar Jun 08 '23 15:06 dpaluy