Module: ActiveRecord::ConnectionAdapters::SQLServer::DatabaseTasks

Included in:
ActiveRecord::ConnectionAdapters::SQLServerAdapter
Defined in:
lib/active_record/connection_adapters/sqlserver/database_tasks.rb

Instance Method Summary collapse

Instance Method Details

#charsetObject



22
23
24
# File 'lib/active_record/connection_adapters/sqlserver/database_tasks.rb', line 22

def charset
  select_value "SELECT DATABASEPROPERTYEX(DB_NAME(), 'SqlCharSetName')"
end

#collationObject



26
27
28
# File 'lib/active_record/connection_adapters/sqlserver/database_tasks.rb', line 26

def collation
  select_value "SELECT DATABASEPROPERTYEX(DB_NAME(), 'Collation')"
end

#create_database(database, options = {}) ⇒ Object



6
7
8
9
10
11
# File 'lib/active_record/connection_adapters/sqlserver/database_tasks.rb', line 6

def create_database(database, options = {})
  name = SQLServer::Utils.extract_identifiers(database)
  db_options = create_database_options(options)
  edition_options = create_database_edition_options(options)
  do_execute "CREATE DATABASE #{name} #{db_options} #{edition_options}"
end

#current_databaseObject



18
19
20
# File 'lib/active_record/connection_adapters/sqlserver/database_tasks.rb', line 18

def current_database
  select_value 'SELECT DB_NAME()'
end

#drop_database(database) ⇒ Object



13
14
15
16
# File 'lib/active_record/connection_adapters/sqlserver/database_tasks.rb', line 13

def drop_database(database)
  name = SQLServer::Utils.extract_identifiers(database)
  do_execute "DROP DATABASE #{name}"
end