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
- #charset ⇒ Object
- #collation ⇒ Object
- #create_database(database, options = {}) ⇒ Object
- #current_database ⇒ Object
- #drop_database(database) ⇒ Object
Instance Method Details
#charset ⇒ Object
24 25 26 |
# File 'lib/active_record/connection_adapters/sqlserver/database_tasks.rb', line 24 def charset select_value "SELECT DATABASEPROPERTYEX(DB_NAME(), 'SqlCharSetName')" end |
#collation ⇒ Object
28 29 30 |
# File 'lib/active_record/connection_adapters/sqlserver/database_tasks.rb', line 28 def collation @collation ||= select_value "SELECT DATABASEPROPERTYEX(DB_NAME(), 'Collation')" end |
#create_database(database, options = {}) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/active_record/connection_adapters/sqlserver/database_tasks.rb', line 7 def create_database(database, = {}) name = SQLServer::Utils.extract_identifiers(database) = () = () execute "CREATE DATABASE #{name} #{} #{}" end |
#current_database ⇒ Object
20 21 22 |
# File 'lib/active_record/connection_adapters/sqlserver/database_tasks.rb', line 20 def current_database select_value "SELECT DB_NAME()" end |
#drop_database(database) ⇒ Object
14 15 16 17 18 |
# File 'lib/active_record/connection_adapters/sqlserver/database_tasks.rb', line 14 def drop_database(database) name = SQLServer::Utils.extract_identifiers(database) execute "ALTER DATABASE #{name} SET SINGLE_USER WITH ROLLBACK IMMEDIATE" execute "DROP DATABASE #{name}" end |