Sha256: b3852b7782b521a662a80b966a96802b85d2ff11edb8b553cb7fead6efb7aac2

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

module TablesSpecHelper

  class Company < ActiveRecord::Base
    extend BulkMethodsMixin
    has_many :employees, -> { where("companies.id == employees.companies_id") }, :class_name => 'Company'
  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

2 entries across 2 versions & 1 rubygems

Version Path
partitioned-2.1.0 spec/support/tables_spec_helper.rb
partitioned-2.0.0 spec/support/tables_spec_helper.rb