sql_cmd 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/optional_dependencies.rb +3 -13
- data/lib/sql_cmd/database.rb +11 -2
- 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: 2026009b040577e9e545648215f0bed077ff75c6b901aeb0144643a07be6262e
|
4
|
+
data.tar.gz: 45656864eaae255a6eb8103605f33e2ec5fd87c3375af4e3750bd935bf32abab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05e96b27be968770e656dddcd91e56969c6a4ec71b6deb38e50b352380fe1afed015de25f10e59ba55bb8181a8b39e3bcf65008be731fadb69c22f600e93d115
|
7
|
+
data.tar.gz: 699ebf6a150ff70284d6c3a81ccf2538d7f0965143d8efa253ed6925082ca9032da4e4b9e2c1679f19e2eed3029a7179cdd380a61eb10b8f4bef5e45d4eff3eb
|
@@ -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,6 +214,8 @@ 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
|
@@ -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.4
|
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-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: easy_json_config
|