Sha256: f29c24824d352ed28ec7a39e5be5b1d0a19c2d3b2661226eb48e2a580646ffff
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
require_relative 'spec_helper' require_relative 'support/paging_shared_example' require 'active_record' ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:' ActiveRecord::Schema.define do self.verbose = false create_table :products, force: true do |t| t.string :name t.string :slug t.integer :category_id t.integer :price t.timestamps null: true end create_table :categories, force: true do |t| t.string :title t.string :slug t.timestamps null: true end end class Product < ActiveRecord::Base belongs_to :category end class Category < ActiveRecord::Base end module ActiveRecord class Base def self.reset_pk_sequence case ActiveRecord::Base.connection.adapter_name when 'SQLite' new_max = maximum(primary_key) || 0 update_seq_sql = "update sqlite_sequence set seq = #{new_max} where name = '#{table_name}';" ActiveRecord::Base.connection.execute(update_seq_sql) when 'PostgreSQL' ActiveRecord::Base.connection.reset_pk_sequence!(table_name) else raise 'Task not implemented for this DB adapter' end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
trailblazer-finder-0.1.4 | spec/spec_helper_active_record.rb |
trailblazer-finder-0.1.3 | spec/spec_helper_active_record.rb |