Skip to content

Commit

Permalink
Deployment fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EitanBlumin committed Apr 16, 2020
1 parent 88566a4 commit 18f723d
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 26 deletions.
38 changes: 36 additions & 2 deletions sql_clr_ics/Script.PreDeployment.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,50 @@
SELECT * FROM [$(TableName)]
--------------------------------------------------------------------------------------
*/
-- Make sure clr is enabled
DECLARE @InitAdvanced INT

IF EXISTS (select * from sys.configurations where name IN ('clr enabled') and value_in_use = 0)
BEGIN
SELECT @InitAdvanced = CONVERT(int, value) FROM sys.configurations WHERE name = 'show advanced options';

IF @InitAdvanced = 0
BEGIN
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
END

IF EXISTS (select * from sys.configurations where name = 'clr enabled' and value_in_use = 0)
BEGIN
EXEC sp_configure 'clr enabled', 1;
RECONFIGURE;
END

IF @InitAdvanced = 0
BEGIN
EXEC sp_configure 'show advanced options', 0;
RECONFIGURE;
END
END
GO
use [master];
GO
IF NOT EXISTS (select * from sys.asymmetric_keys WHERE name = 'sql_clr_ics_pkey')
-- Create symmetric key from DLL
IF NOT EXISTS (
select * from master.sys.asymmetric_keys
WHERE
name = 'sql_clr_ics_pkey'
--thumbprint = 0xC5022B1D1415FC7A
)
create asymmetric key sql_clr_ics_pkey
from executable file = '$(PathToSignedDLL)'
--encryption by password = 'vtwjmifewVfnhrYke@ZuhxkumsFT7_&#$!~<avjqn|mnvJhp'
GO
IF NOT EXISTS (select name from sys.syslogins where name = 'sql_clr_ics_login')
-- Create server login from symmetric key
IF NOT EXISTS (select name from master.sys.syslogins where name = 'sql_clr_ics_login')
create login sql_clr_ics_login from asymmetric key sql_clr_ics_pkey;
GO
-- Grant UNSAFE ASSEMBLY permissions to login which was created from DLL signing key
grant unsafe assembly to sql_clr_ics_login;
GO
-- Return execution context to intended target database
Expand Down
2 changes: 1 addition & 1 deletion sql_clr_ics/sql_clr_ics.publish.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>
<ItemGroup>
<SqlCmdVariable Include="PathToSignedDLL">
<Value>C:\ClrIcsTest\sql_clr_ics.dll</Value>
<Value>C:\SqlClrIcs\sql_clr_ics.dll</Value>
</SqlCmdVariable>
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion sql_clr_ics/sql_clr_ics.sqlproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</ItemGroup>
<ItemGroup>
<SqlCmdVariable Include="PathToSignedDLL">
<DefaultValue>C:\ClrIcsTest\sql_clr_ics.dll</DefaultValue>
<DefaultValue>C:\SqlClrIcs\sql_clr_ics.dll</DefaultValue>
<Value>$(SqlCmdVar__1)</Value>
</SqlCmdVariable>
</ItemGroup>
Expand Down
91 changes: 69 additions & 22 deletions sql_clr_ics/sql_clr_ics_install.sql

Large diffs are not rendered by default.

Binary file modified sql_clr_ics/sql_clr_ics_pkey.pfx
Binary file not shown.

0 comments on commit 18f723d

Please sign in to comment.