README.md in sequel-rails-1.2.1 vs README.md in sequel-rails-1.2.2

- old
+ new

@@ -25,11 +25,11 @@ [brasten](https://github.com/brasten) proposed us. Using sequel-rails ================== -Using sequel with Rails (5.2.x, 6.x, 7.x) requires a couple minor changes. +Using sequel with Rails (5.2.x, 6.x, 7.x) requires a few minor changes. First, add the following to your Gemfile (after the `Rails` lines): ```ruby # depending on you database @@ -48,39 +48,41 @@ ```ruby # require 'rails/all' # Instead of 'rails/all', require these: -require "active_model/railtie" -require "active_job/railtie" -# require "active_record/railtie" -require "action_controller/railtie" -require "action_mailer/railtie" -require "action_view/railtie" -require "action_cable/engine" -require "sprockets/railtie" -require "rails/test_unit/railtie" +%w( + action_cable/engine + action_controller/railtie + action_mailer/railtie + action_view/railtie + active_job/railtie + rails/test_unit/railtie +).each do |railtie| + begin + require railtie + rescue LoadError + end +end ``` -Then you need to get rid of `ActiveRecord` configurations, that is if you +Then you need to get rid of `ActiveRecord` and `ActiveStorage` configurations, that is if you didn't generate the new app with `-O` (or the long form `--skip-active-record`): -For example in a fresh `Rails 5.0.0.1`, you would need to remove those lines: +For example in a fresh `Rails 7`, you would need to remove those lines: ``` -config/initializers/new_framework_defaults.rb -line 18: Rails.application.config.active_record.belongs_to_required_by_default = true -``` - -``` config/environments/development.rb -line 38: config.active_record.migration_error = :page_load +line 37: # config.active_storage.service = :local +line 54: # config.active_record.migration_error = :page_load +line 57: # config.active_record.verbose_query_logs = true ``` ``` config/environments/production.rb -line 85: config.active_record.dump_schema_after_migration = false +line 41: # config.active_storage.service = :local +line 92: # config.active_record.dump_schema_after_migration = false ``` Starting with sequel-rails 0.4.0.pre3 we don't change default Sequel behaviour nor include any plugin by default, if you want to get back the previous behaviour, you can create a new initializer (eg: `config/initializers/sequel.rb`) @@ -88,10 +90,26 @@ ```ruby require "sequel_rails/railties/legacy_model_config" ``` +## Rails 7 + +Rake `db:*` mappings are currently not supported in Rails 7, so you'll need to use +the `sequel:*` tasks instead. For example, to migrate your database, you'll need to +run `rails sequel:migrate` instead of `rails db:migrate`. + +The rake command to create your db requires that Sequel does not attempt to connect +to load models before creating the db. Add this to your `config/application.rb` + +``` +# config/application.rb +if defined?(Rake.application) && Rake.application.top_level_tasks.include?('sequel:create') + config.sequel.skip_connect = true +end +``` + After those changes, you should be good to go! Features provided by `sequel-rails` =================================== @@ -456,9 +474,11 @@ * kamilpavlicko (@kamilpavlicko) * Stefan Vermaas (@stefanvermaas) * Yuri Smirnov (@tycooon) * Mickael Kurmann (@elbouillon) * Radoslaw Wojnarowski (@rwojnarowski) +* David Kelly (@opensourceame) +* PikachuEXE (@PikachuEXE) Credits ======= The [dm-rails](http://github.com/datamapper/dm-rails) team wrote most of the original code, I just sequel-ized it, but since then most of it has been either adapted or rewritten.