Skip to content

Commit

Permalink
Updated to dbup-core 6.0 beta, targeted netstandard2 and update Npgsq…
Browse files Browse the repository at this point in the history
…l reference
  • Loading branch information
droyad committed Jul 24, 2024
1 parent e19e2c0 commit 4b89161
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 118 deletions.
14 changes: 0 additions & 14 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,4 @@
<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition="'$(TF_BUILD)' == 'true' Or '$(CI)' == 'true'">

<!-- Perform a deterministic build, so our binaries aren't impacted by build server environmental factors (e.g. file paths). -->
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>

<!-- Embed source files that are not tracked by the source control manager in the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>

<!-- Recommended: Embed symbols containing Source Link in the main file (exe/dll) -->
<DebugType>embedded</DebugType>

</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
DB Operation: Open connection
Info: Beginning database upgrade
Info: Checking whether journal table exists..
Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Dispose command
Info: Journal table does not exist
Info: Executing Database Server script 'Script0001.sql'
Info: Checking whether journal table exists..
Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Dispose command
Info: Creating the "schemaversions" table
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
DB Operation: Open connection
Info: Beginning database upgrade
Info: Checking whether journal table exists..
Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'TestSchemaVersions' and TABLE_SCHEMA = 'test'
DB Operation: Dispose command
Info: Journal table does not exist
Info: Executing Database Server script 'Script0001.sql'
Info: Checking whether journal table exists..
Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'TestSchemaVersions' and TABLE_SCHEMA = 'test'
DB Operation: Dispose command
Info: Creating the "test"."TestSchemaVersions" table
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
DB Operation: Open connection
Info: Beginning database upgrade
Info: Checking whether journal table exists..
Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Dispose command
Info: Journal table does not exist
Info: Executing Database Server script 'Script0001.sql'
Info: Checking whether journal table exists..
Info: Checking whether journal table exists
DB Operation: Execute scalar command: select 1 from INFORMATION_SCHEMA.TABLES where TABLE_NAME = 'schemaversions'
DB Operation: Dispose command
Info: Creating the "schemaversions" table
Expand Down
45 changes: 0 additions & 45 deletions src/Tests/ApprovalFiles/NoPublicApiChanges.Run.Net.verified.cs

This file was deleted.

12 changes: 6 additions & 6 deletions src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net462;net8</TargetFrameworks>
<TargetFramework>net8</TargetFramework>
<AssemblyName>Tests</AssemblyName>
<RootNamespace>DbUp.Redshift.Tests</RootNamespace>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<!-- <ImplicitUsings>enable</ImplicitUsings> Can't use implict usings with net46 -->
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);NETSDK1138</NoWarn> <!-- Purposefully leaving an old version of netcoreapp to ensure we have compatibility. This never gets published -->
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\dbup-redshift\dbup-redshift.csproj" />
<PackageReference Include="DbUp.Tests.Common" Version="5.0.37" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.6" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PackageReference Include="DbUp.Tests.Common" Version="6.0.0-beta.108" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
3 changes: 3 additions & 0 deletions src/dbup-redshift.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SQ/@EntryIndexedValue">SQ</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=4a98fdf6_002D7d98_002D4f5a_002Dafeb_002Dea44ad98c70c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=f9fce829_002De6f4_002D4cb2_002D80f1_002D5497c44f51df/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/FilterSettingsManager/CoverageFilterXml/@EntryValue">&lt;data&gt;&lt;IncludeFilters /&gt;&lt;ExcludeFilters /&gt;&lt;/data&gt;</s:String>
<s:String x:Key="/Default/FilterSettingsManager/AttributeFilterXml/@EntryValue">&lt;data /&gt;</s:String></wpf:ResourceDictionary>
17 changes: 5 additions & 12 deletions src/dbup-redshift/RedshiftExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,14 @@ public static void RedshiftDatabase(this SupportedDatabasesForEnsureDatabase sup
logMasterConnectionStringBuilder.Password = "******";
}

logger.WriteInformation("Master ConnectionString => {0}", logMasterConnectionStringBuilder.ConnectionString);
logger.LogInformation("Master ConnectionString => {0}", logMasterConnectionStringBuilder.ConnectionString);

using (var connection = new NpgsqlConnection(masterConnectionStringBuilder.ConnectionString))
{
connection.Open();

var sqlCommandText = string.Format
(
@"SELECT case WHEN oid IS NOT NULL THEN 1 ELSE 0 end FROM pg_database WHERE datname = '{0}' limit 1;",
databaseName
);
var sqlCommandText =
$@"SELECT case WHEN oid IS NOT NULL THEN 1 ELSE 0 end FROM pg_database WHERE datname = '{databaseName}' limit 1;";


// check to see if the database already exists..
Expand All @@ -150,11 +147,7 @@ public static void RedshiftDatabase(this SupportedDatabasesForEnsureDatabase sup
}
}

sqlCommandText = string.Format
(
"create database \"{0}\";",
databaseName
);
sqlCommandText = $"create database \"{databaseName}\";";

// Create the database...
using (var command = new NpgsqlCommand(sqlCommandText, connection)
Expand All @@ -166,7 +159,7 @@ public static void RedshiftDatabase(this SupportedDatabasesForEnsureDatabase sup

}

logger.WriteInformation(@"Created database {0}", databaseName);
logger.LogInformation(@"Created database {0}", databaseName);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/dbup-redshift/RedshiftScriptExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ protected override void ExecuteCommandsWithinExceptionHandler(int index, SqlScri
catch (PostgresException exception)
#endif
{
Log().WriteInformation("Npgsql exception has occured in script: '{0}'", script.Name);
Log().WriteError("Script block number: {0}; Block line {1}; Position: {2}; Message: {3}", index, exception.Line, exception.Position, exception.Message);
Log().WriteError(exception.ToString());
Log().LogInformation("Npgsql exception has occured in script: '{0}'", script.Name);
Log().LogError("Script block number: {0}; Block line {1}; Position: {2}; Message: {3}", index, exception.Line, exception.Position, exception.Message);
Log().LogError(exception.ToString());
throw;
}
}
Expand Down
58 changes: 26 additions & 32 deletions src/dbup-redshift/dbup-redshift.csproj
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>DbUp makes it easy to deploy and upgrade SQL Server databases. This package adds Amazon Redshift support.</Description>
<Title>DbUp Redshift Support</Title>
<TargetFrameworks>netstandard1.3;netstandard2.0;net35;net45</TargetFrameworks>
<AssemblyName>dbup-redshift</AssemblyName>
<RootNamespace>DbUp.Redshift</RootNamespace>
<AssemblyOriginatorKeyFile>../dbup.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<RepositoryUrl>https://github.com/DbUp/dbup-redshift.git</RepositoryUrl>
<Product>dbup_redshift</Product>
<PackageId>dbup-redshift</PackageId>
<PackageIcon>dbup-icon.png</PackageIcon>
</PropertyGroup>
<PropertyGroup>
<Description>DbUp makes it easy to deploy and upgrade SQL Server databases. This package adds Amazon Redshift support.</Description>
<Title>DbUp Redshift Support</Title>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>dbup-redshift</AssemblyName>
<RootNamespace>DbUp.Redshift</RootNamespace>
<AssemblyOriginatorKeyFile>../dbup.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<RepositoryUrl>https://github.com/DbUp/dbup-redshift.git</RepositoryUrl>
<Product>dbup_redshift</Product>
<PackageId>dbup-redshift</PackageId>
<PackageIcon>dbup-icon.png</PackageIcon>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net35'">
<DefineConstants>$(DefineConstants);NPGSQLv2</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="dbup-core" Version="4.5.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net35'">
<PackageReference Include="Npgsql" Version="2.2.7" /> <!-- Last version that supports .NET 3.5 -->
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net35'">
<PackageReference Include="Npgsql" Version="3.2.6" />
</ItemGroup>

<ItemGroup>
<None Visible="false" Include="../dbup-icon.png" Pack="True" PackagePath="" />
</ItemGroup>
<PropertyGroup Condition="'$(CI)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> <!-- Perform a deterministic build, so our binaries aren't impacted by build server environmental factors (e.g. file paths). -->
<EmbedUntrackedSources>true</EmbedUntrackedSources> <!-- Embed source files that are not tracked by the source control manager in the PDB -->
<DebugType>embedded</DebugType> <!-- Recommended: Embed symbols containing Source Link in the main file (exe/dll) -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="dbup-core" Version="6.0.0-beta.108"/>
<PackageReference Include="Npgsql" Version="8.0.3" />
</ItemGroup>

<ItemGroup>
<None Visible="false" Include="../dbup-icon.png" Pack="True" PackagePath=""/>
</ItemGroup>
</Project>

0 comments on commit 4b89161

Please sign in to comment.