Class: ArJdbc::Tasks::MSSQLDatabaseTasks
- Inherits:
-
Object
- Object
- ArJdbc::Tasks::MSSQLDatabaseTasks
- Defined in:
- lib/arjdbc/tasks/mssql_database_tasks.rb
Overview
:nodoc:
Class Method Summary collapse
Instance Method Summary collapse
- #charset ⇒ Object
- #collation ⇒ Object
- #create ⇒ Object
- #drop ⇒ Object
-
#initialize(db_config) ⇒ MSSQLDatabaseTasks
constructor
A new instance of MSSQLDatabaseTasks.
- #purge ⇒ Object
- #structure_dump(filename, _extra_flags) ⇒ Object
- #structure_load(filename, _extra_flags) ⇒ Object
Constructor Details
#initialize(db_config) ⇒ MSSQLDatabaseTasks
Returns a new instance of MSSQLDatabaseTasks.
16 17 18 19 |
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 16 def initialize(db_config) @db_config = db_config @configuration_hash = db_config.configuration_hash end |
Class Method Details
.using_database_configurations? ⇒ Boolean
12 13 14 |
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 12 def self.using_database_configurations? true end |
Instance Method Details
#charset ⇒ Object
39 40 41 |
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 39 def charset connection.charset end |
#collation ⇒ Object
43 44 45 |
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 43 def collation connection.collation end |
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 21 def create establish_master_connection connection.create_database(db_config.database, ) establish_connection(db_config) rescue ActiveRecord::StatementInvalid => e case e. when /database .* already exists/i raise ActiveRecord::Tasks::DatabaseAlreadyExists else raise end end |
#drop ⇒ Object
34 35 36 37 |
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 34 def drop establish_master_connection connection.drop_database(db_config.database) end |
#purge ⇒ Object
47 48 49 50 51 |
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 47 def purge clear_active_connections! drop create end |
#structure_dump(filename, _extra_flags) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 53 def structure_dump(filename, _extra_flags) args = args.concat(["-f #{filename}"]) run_cmd('mssql-scripter', args, 'dumping') end |
#structure_load(filename, _extra_flags) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 61 def structure_load(filename, _extra_flags) args = args.concat(["-i #{filename}"]) run_cmd('mssql-cli', args, 'loading') end |