@@ -10,7 +10,7 @@ module Tasks
10
10
class SQLServerDatabaseTasks
11
11
DEFAULT_COLLATION = "SQL_Latin1_General_CP1_CI_AS"
12
12
13
- delegate :connection , :establish_connection , to : ActiveRecord ::Base
13
+ delegate :lease_connection , :establish_connection , to : ActiveRecord ::Base
14
14
15
15
def self . using_database_configurations?
16
16
true
@@ -23,7 +23,7 @@ def initialize(configuration)
23
23
24
24
def create ( master_established = false )
25
25
establish_master_connection unless master_established
26
- connection . create_database configuration . database , configuration_hash . merge ( collation : default_collation )
26
+ lease_connection . create_database configuration . database , configuration_hash . merge ( collation : default_collation )
27
27
establish_connection configuration
28
28
rescue ActiveRecord ::StatementInvalid => e
29
29
if /database .* already exists/i === e . message
@@ -35,15 +35,15 @@ def create(master_established = false)
35
35
36
36
def drop
37
37
establish_master_connection
38
- connection . drop_database configuration . database
38
+ lease_connection . drop_database configuration . database
39
39
end
40
40
41
41
def charset
42
- connection . charset
42
+ lease_connection . charset
43
43
end
44
44
45
45
def collation
46
- connection . collation
46
+ lease_connection . collation
47
47
end
48
48
49
49
def purge
@@ -67,9 +67,9 @@ def structure_dump(filename, extra_flags)
67
67
"-P #{ Shellwords . escape ( configuration_hash [ :password ] ) } " ,
68
68
"-o #{ Shellwords . escape ( filename ) } " ,
69
69
]
70
- table_args = connection . tables . map { |t | Shellwords . escape ( t ) }
70
+ table_args = lease_connection . tables . map { |t | Shellwords . escape ( t ) }
71
71
command . concat ( table_args )
72
- view_args = connection . views . map { |v | Shellwords . escape ( v ) }
72
+ view_args = lease_connection . views . map { |v | Shellwords . escape ( v ) }
73
73
command . concat ( view_args )
74
74
raise "Error dumping database" unless Kernel . system ( command . join ( " " ) )
75
75
@@ -83,7 +83,7 @@ def structure_dump(filename, extra_flags)
83
83
end
84
84
85
85
def structure_load ( filename , extra_flags )
86
- connection . execute File . read ( filename )
86
+ lease_connection . execute File . read ( filename )
87
87
end
88
88
89
89
private
0 commit comments