sql_cmd 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sql_cmd/always_on.rb +4 -2
- data/lib/sql_cmd/database.rb +7 -2
- data/lib/sql_cmd/query.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cfa3746415cf3ffeccd0227470f936f5c17246df1a794c298d9b3099d250c51
|
4
|
+
data.tar.gz: d6daaee8c5d44944fee44fa1ebe1f3ec00aecb31745279ab83841a682569643d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f96c675df9e2190737e50cc5086fe742b9ad2b9c288fe9eed90b383c6ef10c539269bd88183eda3e4a6d87d1d6c5ad3e1abf85ef7f997ba4556060d74a95ba36
|
7
|
+
data.tar.gz: 77cabdfa762399d3baec7c6cc28e6f44ac56d6430a0bbad9dd2efb91e017a3094b9adb44964c47894ab014c2b250975d7dcd6787f6876ac8b35f605a820e9017
|
data/lib/sql_cmd/always_on.rb
CHANGED
@@ -62,8 +62,10 @@ module SqlCmd
|
|
62
62
|
EasyIO.logger.header 'AlwaysOn Permissions Migration to Replica'
|
63
63
|
EasyIO.logger.debug 'Migrating logins to replica...'
|
64
64
|
import_script_filename = SqlCmd.export_logins(start_time, primary_connection_string, database_name)
|
65
|
-
|
66
|
-
|
65
|
+
unless import_script_filename.nil?
|
66
|
+
EasyIO.logger.info "Importing logins on [#{SqlCmd.connection_string_part(replica_connection_string, :server)}]..."
|
67
|
+
SqlCmd.execute_script_file(replica_connection_string, import_script_filename)
|
68
|
+
end
|
67
69
|
EasyIO.logger.debug 'Running database_status script...'
|
68
70
|
database_info = SqlCmd::Database.info(connection_string, database_name)
|
69
71
|
replica_database_info = SqlCmd::Database.info(replica_connection_string, database_name)
|
data/lib/sql_cmd/database.rb
CHANGED
@@ -477,7 +477,7 @@ module SqlCmd
|
|
477
477
|
end
|
478
478
|
failure_message = 'Restore appears to have failed! '
|
479
479
|
failure_message += job_status == 'NoJob' ? 'The job could not be found and the restored database is not up to date!' : "The job did not start in time. Check sql job 'Restore: #{database_name}' history on [#{server_name}] for details."
|
480
|
-
raise failure_message + "
|
480
|
+
raise failure_message + "\nRestore destination: #{server_name}\\#{database_name}"
|
481
481
|
end
|
482
482
|
|
483
483
|
def check_restore_date(start_time, connection_string, database_name, messages = :none, log_only: false)
|
@@ -535,7 +535,11 @@ module SqlCmd
|
|
535
535
|
end
|
536
536
|
|
537
537
|
def apply_recovery_model(connection_string, database_name, options)
|
538
|
-
|
538
|
+
if recovery_model_set?(connection_string, database_name, options)
|
539
|
+
EasyIO.logger.info "Recovery model already set to '#{options['recovery_model']}'. No change needed."
|
540
|
+
return
|
541
|
+
end
|
542
|
+
EasyIO.logger.info "Setting recovery model to '#{options['recovery_model']}'..."
|
539
543
|
options['recovery_model'] ||= 'FULL'
|
540
544
|
options['rollback'] ||= 'ROLLBACK IMMEDIATE' # other options: ROLLBACK AFTER 30, NO_WAIT
|
541
545
|
sql_script = "ALTER DATABASE [#{database_name}] SET RECOVERY #{options['recovery_model']} WITH #{options['rollback']}"
|
@@ -547,6 +551,7 @@ module SqlCmd
|
|
547
551
|
#{'=' * 120}\n"
|
548
552
|
EOS
|
549
553
|
raise failure_message unless recovery_model_set?(connection_string, database_name, options)
|
554
|
+
EasyIO.logger.info "Recovery model updated to '#{options['recovery_model']}'."
|
550
555
|
end
|
551
556
|
|
552
557
|
def recovery_model_set?(connection_string, database_name, options)
|
data/lib/sql_cmd/query.rb
CHANGED
@@ -245,6 +245,7 @@ module SqlCmd
|
|
245
245
|
def migrate_logins(start_time, source_connection_string, destination_connection_string, database_name)
|
246
246
|
start_time = SqlCmd.unify_start_time(start_time)
|
247
247
|
import_script_filename = export_logins(start_time, source_connection_string, database_name)
|
248
|
+
return if import_script_filename.nil?
|
248
249
|
if ::File.exist?(import_script_filename)
|
249
250
|
EasyIO.logger.info "Importing logins on [#{connection_string_part(destination_connection_string, :server)}]..."
|
250
251
|
execute_script_file(destination_connection_string, import_script_filename)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sql_cmd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Munoz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: easy_json_config
|