Skip to content

Commit

Permalink
Merge branch 'develop' into feature/bookmark-800-82
Browse files Browse the repository at this point in the history
  • Loading branch information
randywoods committed Aug 17, 2023
2 parents 1f72723 + 3433e2c commit 59a8c59
Show file tree
Hide file tree
Showing 15 changed files with 9,326 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void CopyDBAcrossServersTest()
{
string clientCode = "DHS";
string appCode = "CSET";
DbManager manager = new DbManager(new Version("12.0.2.5"),clientCode, appCode);
DbManager manager = new DbManager(new Version("12.0.2.7"),clientCode, appCode);
//TODO finish this.
//manager.CopyDBAcrossServers();
}
Expand All @@ -42,7 +42,7 @@ public void CopyDBFromInstallationSource()
//setup a destination file
string clientCode = "DHS";
string appCode = "CSET";
DbManager manager = new DbManager(new Version("12.0.2.5"), clientCode, appCode);
DbManager manager = new DbManager(new Version("12.0.2.7"), clientCode, appCode);
//run the same test twice and make sure that the number increment works
string mdf = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\CSETWebTest.mdf";
string ldf = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\CSETWebTest_log.ldf";
Expand All @@ -68,14 +68,14 @@ public void TestUpgrade()
//setup a destination file
string clientCode = "Test";
string appCode = "Test";
DbManager manager = new DbManager(new Version("12.0.2.5"), clientCode, appCode);
DbManager manager = new DbManager(new Version("12.0.2.7"), clientCode, appCode);

//manager.ForceCloseAndDetach(DbManager.localdb2019_ConnectionString, "TestWeb");
//manager.AttachTest("TestWeb", testdb, testlog);
VersionUpgrader upgrader = new VersionUpgrader(Assembly.GetAssembly(typeof(DbManager)).Location);
manager.SetupDb();

upgrader.UpgradeOnly(new Version("12.0.2.5"), "data source=(localdb)\\mssqllocaldb;initial catalog=TestWeb;persist security info=True;Integrated Security=SSPI;MultipleActiveResultSets=True");
upgrader.UpgradeOnly(new Version("12.0.2.7"), "data source=(localdb)\\mssqllocaldb;initial catalog=TestWeb;persist security info=True;Integrated Security=SSPI;MultipleActiveResultSets=True");


}
Expand All @@ -88,7 +88,7 @@ public void TestSetup()
//setup a destination file
string clientCode = "DHS";
string appCode = "CSET";
DbManager manager = new DbManager(new Version("12.0.2.5"), clientCode, appCode);
DbManager manager = new DbManager(new Version("12.0.2.7"), clientCode, appCode);
manager.SetupDb();
}

Expand All @@ -100,7 +100,7 @@ public void CopyDBFromInstallationSourceTest2()
string mdf = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\CSETWebTest.mdf";
string ldf = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\CSETWebTest_log.ldf";

DbManager manager = new DbManager(new Version("12.0.2.5"), clientCode, appCode);
DbManager manager = new DbManager(new Version("12.0.2.7"), clientCode, appCode);
//run the same test twice and make sure that the number increment works
string conString = "Server=(localdb)\\mssqllocaldb;Integrated Security=true;AttachDbFileName=" + mdf;
using (SqlConnection conn = new SqlConnection(conString))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<AssemblyVersion>12.0.2.5</AssemblyVersion>
<AssemblyVersion>12.0.2.7</AssemblyVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
////////////////////////////////
//
// Copyright 2023 Battelle Energy Alliance, LLC
//
//
////////////////////////////////
using System;
using Microsoft.Data.SqlClient;
using System.IO;
namespace UpgradeLibrary.Upgrade
{
internal class ConvertDatabase12026 : ConvertSqlDatabase
{
public ConvertDatabase12026(string path) : base(path)
{
myVersion = new Version("12.0.2.6");
}

/// <summary>
/// Runs the database update script
/// </summary>
/// <param name="conn"></param>
public override void Execute(SqlConnection conn)
{
try
{
RunFile(Path.Combine(this.applicationPath, "VersionUpgrader", "SQL", "12025_to_12026.sql"), conn);
RunFile(Path.Combine(this.applicationPath, "VersionUpgrader", "SQL", "12025_to_12026_data.sql"), conn);

this.UpgradeToVersionLocalDB(conn, myVersion);
}
catch (Exception e)
{
throw new DatabaseUpgradeException("Error in upgrading database version 12.0.2.5 to 12.0.2.6: " + e.Message);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
////////////////////////////////
//
// Copyright 2023 Battelle Energy Alliance, LLC
//
//
////////////////////////////////
using System;
using Microsoft.Data.SqlClient;
using System.IO;
namespace UpgradeLibrary.Upgrade
{
internal class ConvertDatabase12027 : ConvertSqlDatabase
{
public ConvertDatabase12027(string path) : base(path)
{
myVersion = new Version("12.0.2.7");
}

/// <summary>
/// Runs the database update script
/// </summary>
/// <param name="conn"></param>
public override void Execute(SqlConnection conn)
{
try
{
RunFile(Path.Combine(this.applicationPath, "VersionUpgrader", "SQL", "12026_to_12027_data.sql"), conn);

this.UpgradeToVersionLocalDB(conn, myVersion);
}
catch (Exception e)
{
throw new DatabaseUpgradeException("Error in upgrading database version 12.0.2.6 to 12.0.2.7: " + e.Message);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
Run this script on:
(localdb)\INLLocalDb2022.CSETWeb12025 - This database will be modified
to synchronize it with:
(localdb)\INLLocalDb2022.CSETWeb12026
You are recommended to back up your database before running this script
Script created by SQL Compare version 14.10.9.22680 from Red Gate Software Ltd at 8/14/2023 5:25:17 PM
*/
SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL Serializable
GO
BEGIN TRANSACTION
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[SECTOR]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[SECTOR] ADD
[Is_NIPP] [bit] NOT NULL CONSTRAINT [DF__SECTOR__Is_NIPP__4C214075] DEFAULT ((0)),
[NIPP_sector] [int] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Altering [dbo].[SECTOR_INDUSTRY]'
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
ALTER TABLE [dbo].[SECTOR_INDUSTRY] ADD
[Is_NIPP] [bit] NOT NULL CONSTRAINT [DF__SECTOR_IN__Is_NI__4D1564AE] DEFAULT ((0)),
[Is_Other] [bit] NOT NULL CONSTRAINT [DF__SECTOR_IN__Is_Ot__4E0988E7] DEFAULT ((0)),
[NIPP_subsector] [int] NULL
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[DETAILS_DEMOGRAPHICS]'
GO
CREATE TABLE [dbo].[DETAILS_DEMOGRAPHICS]
(
[Assessment_Id] [int] NOT NULL,
[DataItemName] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[StringValue] [nvarchar] (max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[IntValue] [int] NULL,
[FloatValue] [float] NULL,
[BoolValue] [bit] NULL,
[DateTimeValue] [datetime] NULL
)
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_DETAILS_DEMOGRAPHICS] on [dbo].[DETAILS_DEMOGRAPHICS]'
GO
ALTER TABLE [dbo].[DETAILS_DEMOGRAPHICS] ADD CONSTRAINT [PK_DETAILS_DEMOGRAPHICS] PRIMARY KEY CLUSTERED ([Assessment_Id], [DataItemName])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating [dbo].[DETAILS_DEMOGRAPHICS_OPTIONS]'
GO
CREATE TABLE [dbo].[DETAILS_DEMOGRAPHICS_OPTIONS]
(
[Option_Id] [int] NOT NULL IDENTITY(1, 1),
[DataItemName] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[Sequence] [int] NOT NULL,
[OptionValue] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[OptionText] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
)
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
PRINT N'Creating primary key [PK_DETAIL_DEMOG_OPTIONS] on [dbo].[DETAILS_DEMOGRAPHICS_OPTIONS]'
GO
ALTER TABLE [dbo].[DETAILS_DEMOGRAPHICS_OPTIONS] ADD CONSTRAINT [PK_DETAIL_DEMOG_OPTIONS] PRIMARY KEY CLUSTERED ([Option_Id])
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
COMMIT TRANSACTION
GO
IF @@ERROR <> 0 SET NOEXEC ON
GO
-- This statement writes to the SQL Server Log so SQL Monitor can show this deployment.
IF HAS_PERMS_BY_NAME(N'sys.xp_logevent', N'OBJECT', N'EXECUTE') = 1
BEGIN
DECLARE @databaseName AS nvarchar(2048), @eventMessage AS nvarchar(2048)
SET @databaseName = REPLACE(REPLACE(DB_NAME(), N'\', N'\\'), N'"', N'\"')
SET @eventMessage = N'Redgate SQL Compare: { "deployment": { "description": "Redgate SQL Compare deployed to ' + @databaseName + N'", "database": "' + @databaseName + N'" }}'
EXECUTE sys.xp_logevent 55000, @eventMessage
END
GO
DECLARE @Success AS BIT
SET @Success = 1
SET NOEXEC OFF
IF (@Success = 1) PRINT 'The database update succeeded'
ELSE BEGIN
IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION
PRINT 'The database update failed'
END
GO
Loading

0 comments on commit 59a8c59

Please sign in to comment.