sql_cmd 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/optional_dependencies.rb +3 -13
- data/lib/sql_cmd/database.rb +12 -3
- data/sql_scripts/Agent/JobRunStatus.sql +1 -1
- 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: 863a0cf5e7a7251818d980f5e2719290d89bab6cc9de33349bcbade454b3e1bf
|
4
|
+
data.tar.gz: 0c1463b9bfdcffc2fdc17e113025d61d6b3f77de525e381f0b28fffcf06fae43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7236624b3fbac8d3ac37655277535205261d9a75aa9b5147d81d2699c0632b54a4470c0c708b317b36a7cb5fa99e521c4c915df9a5e7f25f4241f26ed580307
|
7
|
+
data.tar.gz: 2c6ef2c7c0f05c9fc7398982c75833e0453f9312649ed4294737e732fab187451d16946710c484437fdba740f6081702d13ecd27c1801e23049dbb09717183cb
|
@@ -3,18 +3,8 @@ module OptionalDepedencies
|
|
3
3
|
|
4
4
|
def load_azure_blob_storage_dependencies
|
5
5
|
azure_blob_storage_dependencies = {
|
6
|
-
|
7
|
-
|
8
|
-
# 'faraday-net_http_persistent' => '1.1.0',
|
9
|
-
# 'ruby2_keywords' => '0.0.4',
|
10
|
-
# 'faraday' => '1.4.1',
|
11
|
-
# 'faraday_middleware' => '1.0.0',
|
12
|
-
# 'connection_pool' => '2.2.5'
|
13
|
-
# 'net-http-persistent' => '4.0.1',
|
14
|
-
# 'racc' => '1.5.2',
|
15
|
-
# 'nokogiri' => '1.11.4',
|
16
|
-
'azure/storage/common' => '2.0.2',
|
17
|
-
'azure/storage/blob' => '2.0.1',
|
6
|
+
'azure/storage/common' => '>= 2.0.4',
|
7
|
+
'azure/storage/blob' => '>= 2.0.3',
|
18
8
|
}
|
19
9
|
load_gem_list(azure_blob_storage_dependencies)
|
20
10
|
end
|
@@ -25,6 +15,6 @@ module OptionalDepedencies
|
|
25
15
|
require current_gem
|
26
16
|
end
|
27
17
|
rescue Gem::LoadError => e
|
28
|
-
raise Gem::LoadError, "You are using functionality requiring the optional gem dependency '#{e.name}', but the gem is not
|
18
|
+
raise Gem::LoadError, "You are using functionality requiring the optional gem dependency '#{e.name}', but the gem is not installed, or is not using a version matching '#{e.requirement}'.\n\n#{e.message}"
|
29
19
|
end
|
30
20
|
end
|
data/lib/sql_cmd/database.rb
CHANGED
@@ -137,7 +137,7 @@ module SqlCmd
|
|
137
137
|
connection_string = SqlCmd.remove_connection_string_part(connection_string, :database)
|
138
138
|
sql_server = SqlCmd.connection_string_part(connection_string, :server)
|
139
139
|
database_info = info(connection_string, database_name)
|
140
|
-
import_script_path =
|
140
|
+
import_script_path = import_security_script_path(start_time, connection_string, database_name, backup_url)
|
141
141
|
unless database_info['DatabaseNotFound']
|
142
142
|
raise "Failed to restore database: [#{database_name}] on [#{sql_server}]! Database already exists!" unless overwrite || force_restore
|
143
143
|
unless options['logonly'] || database_info['state_desc'] != 'ONLINE' || permissions == :no_permissions
|
@@ -214,10 +214,12 @@ module SqlCmd
|
|
214
214
|
raise "Insufficient free space on #{sql_server} to restore database! Must have greater than #{free_space_threshold}% space remaining after restore." if insufficient_space
|
215
215
|
end
|
216
216
|
|
217
|
+
database_backup_types = %w(1 5)
|
218
|
+
drop(connection_string, database_name) if options['drop_before_restoring'] && !database_info['DatabaseNotFound'] && database_backup_types.include?(sql_backup_header['BackupType'])
|
217
219
|
run_restore_as_job(connection_string, sql_server_settings, backup_files, database_name, options: options)
|
218
220
|
monitor_restore(minimum_restore_date, connection_string, database_name, backup_files, options) unless asynchronous
|
219
221
|
end
|
220
|
-
import_security(connection_string, database_name, import_script_path, backup_url, options) unless import_script_path.nil? || [:no_permissions, :export_only].include?(permissions)
|
222
|
+
import_security(connection_string, database_name, import_script_path, backup_url, options) unless database_info['DatabaseNotFound'] || import_script_path.nil? || [:no_permissions, :export_only].include?(permissions)
|
221
223
|
SqlCmd.update_sql_compatibility(connection_string, database_name, options['compatibility_level']) if options['compatibility_level']
|
222
224
|
apply_recovery_model(connection_string, database_name, options) if options['recovery_model']
|
223
225
|
SqlCmd::AlwaysOn.add_to_availability_group(connection_string, database_name, full_backup_method: full_backup_method) if sql_server_settings['AlwaysOnEnabled'] && !options['secondaryreplica'] && !options['skip_always_on']
|
@@ -560,12 +562,19 @@ module SqlCmd
|
|
560
562
|
SqlCmd.execute_query(connection_string, sql_script, return_type: :scalar, readonly: true) || false
|
561
563
|
end
|
562
564
|
|
563
|
-
def
|
565
|
+
def import_security_script_path(start_time, connection_string, database_name, storage_url = nil)
|
564
566
|
start_time = SqlCmd.unify_start_time(start_time)
|
565
567
|
server_name = SqlCmd.connection_string_part(connection_string, :server)
|
566
568
|
export_folder = "#{SqlCmd.config['paths']['cache']}/sql_cmd/logins"
|
567
569
|
basename_prefix = storage_url.nil? ? "#{EasyFormat::File.windows_friendly_name(server_name)}_" : ''
|
568
570
|
import_script_path = "#{export_folder}/#{basename_prefix}#{database_name}_database_permissions_#{EasyTime.yyyymmdd(start_time)}.sql"
|
571
|
+
end
|
572
|
+
|
573
|
+
def export_security(start_time, connection_string, database_name, storage_url = nil, options = {})
|
574
|
+
start_time = SqlCmd.unify_start_time(start_time)
|
575
|
+
server_name = SqlCmd.connection_string_part(connection_string, :server)
|
576
|
+
export_folder = "#{SqlCmd.config['paths']['cache']}/sql_cmd/logins"
|
577
|
+
import_script_path = import_security_script_path(start_time, connection_string, database_name, storage_url)
|
569
578
|
if ::File.exist?(import_script_path) && ::File.mtime(import_script_path) > start_time
|
570
579
|
content = ::File.read(import_script_path)
|
571
580
|
SqlCmd::Azure::AttachedStorage.upload(::File.basename(import_script_path), content, options['storage_account_name'], options['storage_access_key'], storage_url: storage_url) unless storage_url.nil?
|
@@ -6,7 +6,7 @@ SELECT
|
|
6
6
|
j.name AS job_name,
|
7
7
|
ja.start_execution_date,
|
8
8
|
ISNULL(last_executed_step_id,0)+1 AS current_executed_step_id,
|
9
|
-
|
9
|
+
js.step_name
|
10
10
|
FROM msdb.dbo.sysjobactivity ja
|
11
11
|
LEFT JOIN msdb.dbo.sysjobhistory jh
|
12
12
|
ON ja.job_history_id = jh.instance_id
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Munoz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: easy_json_config
|