Sha256: 22f51f3fc1400b18540a56928c7be8184274e047d2b7ba154ed5cc6a70fad7e7

Contents?: true

Size: 1.33 KB

Versions: 20

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

module TablesSpecHelper

  class Company < ActiveRecord::Base
    extend BulkMethodsMixin
    has_many :employees, :class_name => 'Company', :conditions => "companies.id = employees.companies_id"
  end

  def create_tables
    ActiveRecord::Base.connection.execute <<-SQL
      create table companies
      (
          id               serial not null primary key,
          created_at       timestamp not null default now(),
          updated_at       timestamp,
          name             text null
      );

      insert into companies (name) values ('Fluent Mobile, inc.');
      insert into companies (name) values ('Fiksu, inc.');
      insert into companies (name) values ('FreeMyApps, inc.');

      create table employees
      (
          id               serial not null primary key,
          created_at       timestamp not null default now(),
          updated_at       timestamp,
          name             text not null,
          salary           integer default 3,
          company_id       integer not null,
          integer_field    integer not null default 1
      );

      create schema employees_partitions;
    SQL
  end

  def drop_tables
    ActiveRecord::Base.connection.execute <<-SQL
      drop schema employees_partitions cascade;
      drop table employees;
      drop table companies;
    SQL
  end

end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
partitioned-1.3.5 spec/support/tables_spec_helper.rb
partitioned-1.3.4 spec/support/tables_spec_helper.rb
bulk_data_methods-1.1.2 spec/support/tables_spec_helper.rb
partitioned-1.3.3 spec/support/tables_spec_helper.rb
partitioned-1.3.2 spec/support/tables_spec_helper.rb
partitioned-1.3.1 spec/support/tables_spec_helper.rb
partitioned-1.3.0 spec/support/tables_spec_helper.rb
partitioned-1.2.1 spec/support/tables_spec_helper.rb
bulk_data_methods-1.1.1 spec/support/tables_spec_helper.rb
partitioned-1.2.0 spec/support/tables_spec_helper.rb
bulk_data_methods-1.1.0 spec/support/tables_spec_helper.rb
partitioned-1.1.11 spec/support/tables_spec_helper.rb
partitioned-1.1.10 spec/support/tables_spec_helper.rb
partitioned-1.1.9 spec/support/tables_spec_helper.rb
partitioned-1.1.8 spec/support/tables_spec_helper.rb
partitioned-1.1.7 spec/support/tables_spec_helper.rb
partitioned-1.1.6 spec/support/tables_spec_helper.rb
partitioned-1.1.5 spec/support/tables_spec_helper.rb
partitioned-1.1.3 spec/support/tables_spec_helper.rb
bulk_data_methods-1.0.0 spec/support/tables_spec_helper.rb