Sha256: 77d4f1a60413e80dd350c4cde8ce1a9dfcdd2b90919448a95f5f4d59495232b8

Contents?: true

Size: 996 Bytes

Versions: 15

Compression:

Stored size: 996 Bytes

Contents

require 'active_record'

class PGInitializer
  def self.initialize!
    config = {
      'adapter'   => 'postgresql',
      'encoding'  => 'unicode',
      'database'  => 'superstore_test',
      'pool'      => 5,
      'host'      => 'localhost'
    }

    ActiveRecord::Base.configurations = { test: config }

    ActiveRecord::Tasks::DatabaseTasks.drop config
    ActiveRecord::Tasks::DatabaseTasks.create config
    ActiveRecord::Base.establish_connection config

    create_labels_table
    create_users_table
  end

  def self.create_labels_table
    ActiveRecord::Migration.create_table :labels do |t|
      t.string :issue_id, null: false
      t.string :name, null: false
    end
  end

  def self.create_users_table
    ActiveRecord::Migration.create_table :users do |t|
      t.string :special_id, null: false
      t.index :special_id, unique: true
    end
  end

  def self.table_names
    %w(labels users)
  end
end

PGInitializer.initialize!
ActiveRecord::Migration.verbose = false

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
superstore-3.0.0 test/support/pg.rb
superstore-2.5.0 test/support/pg.rb
superstore-2.4.4 test/support/pg.rb
superstore-2.4.3 test/support/pg.rb
superstore-2.4.2 test/support/pg.rb
superstore-2.4.1 test/support/pg.rb
superstore-2.4.0 test/support/pg.rb
superstore-2.3.0 test/support/pg.rb
superstore-2.2.0 test/support/pg.rb
superstore-2.1.3 test/support/pg.rb
superstore-2.1.2 test/support/pg.rb
superstore-2.1.1 test/support/pg.rb
superstore-2.1.0 test/support/pg.rb
superstore-2.0.1 test/support/pg.rb
superstore-2.0.0 test/support/pg.rb