Sha256: b676b5f9b0b096919379705dda0c43b63bc8c4997f4f44c4922f6b48df7b563b

Contents?: true

Size: 1.49 KB

Versions: 41

Compression:

Stored size: 1.49 KB

Contents

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

  task :create_database => :setup do
    spec = CompositePrimaryKeys::ConnectionSpec['sqlserver']
    database = spec.delete('database')
    ActiveRecord::Base.clear_all_connections!

    ActiveRecord::Base.establish_connection(spec)
    ActiveRecord::Base.connection.execute("CREATE DATABASE [#{database}]")
    ActiveRecord::Base.clear_all_connections!
  end

  task :build_database => :create_database do
    spec = CompositePrimaryKeys::ConnectionSpec['sqlserver']
    ActiveRecord::Base.establish_connection(spec)

    schema = File.join(PROJECT_ROOT, 'test', 'fixtures', 'db_definitions', 'sqlserver.sql')
    sql = File.read(schema)
    ActiveRecord::Base.connection.execute(sql)
    ActiveRecord::Base.clear_all_connections!
  end

  desc 'Drop the SQL Server test database'
  task :drop_database => :setup do
    spec = CompositePrimaryKeys::ConnectionSpec['sqlserver']
    ActiveRecord::Base.clear_all_connections!
    ActiveRecord::Base.establish_connection(spec)
    database = spec.delete('database')
    ActiveRecord::Base.connection.execute(<<-SQL)
      USE master;
      ALTER DATABASE [#{database}] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
      DROP DATABASE [#{database}];
    SQL
    ActiveRecord::Base.clear_all_connections!
  end

  desc 'Rebuild the SQL Server 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/sqlserver.rake
composite_primary_keys-13.0.0 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.10 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.9 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.8 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.6 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.5 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.4 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.3 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.2 tasks/databases/sqlserver.rake
composite_primary_keys-11.3.1 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.1 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.0 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.0.rc5 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.0.rc4 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.0.rc3 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.0.rc2 tasks/databases/sqlserver.rake
composite_primary_keys-12.0.0.rc1 tasks/databases/sqlserver.rake
composite_primary_keys-11.2.0 tasks/databases/sqlserver.rake
composite_primary_keys-11.1.0 tasks/databases/sqlserver.rake