Sha256: 9eeba425c7afd98e0e66711016d8b6b6019f4049062f7770c6a86d6e7734bd4f

Contents?: true

Size: 1.46 KB

Versions: 41

Compression:

Stored size: 1.46 KB

Contents

namespace :postgresql do
  task :setup do
    require 'bundler'
    Bundler.require(:default, :postgresql)
  end

  task :create_database => :setup do
    spec = CompositePrimaryKeys::ConnectionSpec['postgresql']
    ActiveRecord::Base.clear_all_connections!
    ActiveRecord::Base.establish_connection(spec.dup.merge('database' => 'postgres'))
    ActiveRecord::Base.connection.create_database(spec['database'])
    ActiveRecord::Base.clear_all_connections!
  end

  desc 'Build the Postgresql test database'
  task :build_database => :create_database do
    spec = CompositePrimaryKeys::ConnectionSpec['postgresql']
    ActiveRecord::Base.clear_all_connections!
    connection = ActiveRecord::Base.establish_connection(spec)

    schema = File.join(PROJECT_ROOT, 'test', 'fixtures', 'db_definitions', 'postgresql.sql')
    sql = File.read(schema)

    ActiveRecord::Base.connection.execute(sql)
    ActiveRecord::Base.clear_all_connections!
  end

  desc 'Drop the Postgresql test database'
  task :drop_database  => :setup do
    spec = CompositePrimaryKeys::ConnectionSpec['postgresql']
    ActiveRecord::Base.clear_all_connections!
    connection = ActiveRecord::Base.establish_connection(spec.merge('database' => 'postgres'))
    ActiveRecord::Base.connection.drop_database(spec['database'])
    ActiveRecord::Base.clear_all_connections!
  end

  desc 'Rebuild the PostgreSQL test database'
  task :rebuild_database => [:drop_database, :build_database]
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
composite_primary_keys-13.0.1 tasks/databases/postgresql.rake
composite_primary_keys-13.0.0 tasks/databases/postgresql.rake
composite_primary_keys-12.0.10 tasks/databases/postgresql.rake
composite_primary_keys-12.0.9 tasks/databases/postgresql.rake
composite_primary_keys-12.0.8 tasks/databases/postgresql.rake
composite_primary_keys-12.0.6 tasks/databases/postgresql.rake
composite_primary_keys-12.0.5 tasks/databases/postgresql.rake
composite_primary_keys-12.0.4 tasks/databases/postgresql.rake
composite_primary_keys-12.0.3 tasks/databases/postgresql.rake
composite_primary_keys-12.0.2 tasks/databases/postgresql.rake
composite_primary_keys-11.3.1 tasks/databases/postgresql.rake
composite_primary_keys-12.0.1 tasks/databases/postgresql.rake
composite_primary_keys-12.0.0 tasks/databases/postgresql.rake
composite_primary_keys-12.0.0.rc5 tasks/databases/postgresql.rake
composite_primary_keys-12.0.0.rc4 tasks/databases/postgresql.rake
composite_primary_keys-12.0.0.rc3 tasks/databases/postgresql.rake
composite_primary_keys-12.0.0.rc2 tasks/databases/postgresql.rake
composite_primary_keys-12.0.0.rc1 tasks/databases/postgresql.rake
composite_primary_keys-11.2.0 tasks/databases/postgresql.rake
composite_primary_keys-11.1.0 tasks/databases/postgresql.rake