Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rails 6: ActiveRecord

Rails 6: ActiveRecord

Nikolay Sverchkov

November 30, 2019
Tweet

More Decks by Nikolay Sverchkov

Other Decks in Programming

Transcript

  1. @ssnickolay RAILS 6.0: MULTI DB MULTI DB = DB SHARDING

    = + + + VERTICAL OR HORIZONTAL PARTITIONING / REPLICATION
  2. @ssnickolay RAILS 6.0: MULTI DB RAILS DID NOT HAVE ADEQUATE*

    MULTI DB SUPPORT *https://github.com/ankane/multiverse
  3. @ssnickolay RAILS 6.0: BULK INSERTS # Insert multiple records, performing

    an upsert # when records have duplicate ISBNs Book.upsert_all([ { title: 'Rework', author: 'David', isbn: '1' }, { title: 'Eloquent Ruby', author: 'Russ', isbn: '1' } ], unique_by: { columns: %w[ isbn ] }) *gem ‘activerecord-import`
  4. @ssnickolay RAILS 6.0: create_or_find_by def create_or_find_by(attributes, &block) transaction(requires_new: true) {

    create(attributes, &block) } rescue ActiveRecord!::RecordNotUnique find_by!(attributes) end
  5. @ssnickolay RAILS 6.0: create_or_find_by def create_or_find_by(attributes, &block) transaction(requires_new: true) {

    create(attributes, &block) } rescue ActiveRecord!::RecordNotUnique <Вот-Тут-> find_by!(attributes) end
  6. @ssnickolay RAILS 6.0: Other • Make t.timestamps with precision by

    default • Add support for UNLOGGED Postgresql tables • Add support for annotating queries generated by ActiveRecord::Relation with SQL comments • Make it possible to override the implicit order column • …