From 63f79866e38953e4128aaba1875ac2a507335013 Mon Sep 17 00:00:00 2001 From: Robert Wagner Date: Mon, 3 Mar 2025 13:36:20 +1000 Subject: [PATCH] Customise the template for ClickHouse --- .github/workflows/main.yml | 4 +-- README.md | 30 ++++--------------- src/Directory.Build.props | 4 +-- .../NoPublicApiChanges.Run.approved.cs | 15 ++++++++++ src/Tests/DatabaseSupportTests.cs | 6 ++-- src/Tests/NoPublicApiChanges.cs | 4 +-- src/Tests/Tests.csproj | 16 +++++----- ...up-newprovider.sln => dbup-clickhouse.sln} | 4 +-- ...ttings => dbup-clickhouse.sln.DotSettings} | 3 ++ src/dbup-clickhouse/ClickHouseExtensions.cs | 12 ++++++++ src/dbup-clickhouse/ClickHouseJournal.cs | 23 ++++++++++++++ .../dbup-clickhouse.csproj} | 16 +++++----- 12 files changed, 86 insertions(+), 51 deletions(-) create mode 100644 src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs rename src/{dbup-newprovider.sln => dbup-clickhouse.sln} (91%) rename src/{dbup-newprovider.sln.DotSettings => dbup-clickhouse.sln.DotSettings} (55%) create mode 100644 src/dbup-clickhouse/ClickHouseExtensions.cs create mode 100644 src/dbup-clickhouse/ClickHouseJournal.cs rename src/{dbup-newprovider/dbup-newprovider.csproj => dbup-clickhouse/dbup-clickhouse.csproj} (54%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 92f3e92..18198a1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,8 +1,8 @@ name: CI on: - #push: - #pull_request: + push: + pull_request: workflow_dispatch: jobs: diff --git a/README.md b/README.md index e4ae19f..ccae84e 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,15 @@ -# Using this Template +[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/DbUp/dbup-clickhouse/main.yml?branch=main)](https://github.com/DbUp/dbup-clickhouse/actions/workflows/main.yml?query=branch%3Amain) +[![NuGet](https://img.shields.io/nuget/dt/dbup-clickhouse.svg)](https://www.nuget.org/packages/dbup-clickhouse) +[![NuGet](https://img.shields.io/nuget/v/dbup-clickhouse.svg)](https://www.nuget.org/packages/dbup-clickhouse) +[![Prerelease](https://img.shields.io/nuget/vpre/dbup-clickhouse?color=orange&label=prerelease)](https://www.nuget.org/packages/dbup-clickhouse) -1. Create a new Repository in GitHub based on this template - - The name should be in the form `dbup-nameofthenewprovider` - - It should be public -1. Create PR to add the name of the repo to the `AllProviders.txt` file in the `DbUp` repository -1. Clone it -1. Open it in VSCode or other light weight editor that doesn't have strong opinions about solution/project structure (i.e. not Rider/VS) -1. Rename the following: - - `dbup-newprovider.sln` - - `dbup-newprovider.sln.DotSettings` - - `dbup-newprovider\dbup-newprovider.csproj` - - `dbup-newprovider` directory -1. Search for `NewProvider` and replace with the new provider's name, **turning on the preserve case option** -1. Run `dotnet build` to ensure it builds -1. Uncomment the `push` and `pull_request` lines in `.github\workflows\main.yml` -1. Delete these instructions up to and including the next line, then check in - -[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/DbUp/dbup-newprovider/main.yml?branch=main)](https://github.com/DbUp/dbup-newprovider/actions/workflows/main.yml?query=branch%3Amain) -[![NuGet](https://img.shields.io/nuget/dt/dbup-newprovider.svg)](https://www.nuget.org/packages/dbup-newprovider) -[![NuGet](https://img.shields.io/nuget/v/dbup-newprovider.svg)](https://www.nuget.org/packages/dbup-newprovider) -[![Prerelease](https://img.shields.io/nuget/vpre/dbup-newprovider?color=orange&label=prerelease)](https://www.nuget.org/packages/dbup-newprovider) - -# DbUp NewProvider support +# DbUp ClickHouse support DbUp is a .NET library that helps you to deploy changes to SQL Server databases. It tracks which SQL scripts have been run already, and runs the change scripts that are needed to get your database up to date. ## Getting Help To learn more about DbUp check out the [documentation](https://dbup.readthedocs.io/en/latest/) -Please only log issue related to NewProvider support in this repo. For cross cutting issues, please use our [main issue list](https://github.com/DbUp/DbUp/issues). +Please only log issue related to ClickHouse support in this repo. For cross cutting issues, please use our [main issue list](https://github.com/DbUp/DbUp/issues). # Contributing diff --git a/src/Directory.Build.props b/src/Directory.Build.props index fb1c760..814c271 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -3,10 +3,10 @@ https://github.com/orgs/DbUp/people - https://github.com/DbUp/dbup-newprovider/releases + https://github.com/DbUp/dbup-clickhouse/releases https://dbup.github.io MIT - https://github.com/dbup-newprovider/dbup-newprovider.git + https://github.com/dbup-clickhouse/dbup-clickhouse.git latest true diff --git a/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs b/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs new file mode 100644 index 0000000..edee20c --- /dev/null +++ b/src/Tests/ApprovalFiles/NoPublicApiChanges.Run.approved.cs @@ -0,0 +1,15 @@ + +namespace DbUp.ClickHouse +{ + public static class ClickHouseExtensions + { + public static DbUp.Builder.UpgradeEngineBuilder ClickHouseDatabase(this DbUp.Builder.SupportedDatabases supportedDatabases, string connectionString) { } + } + public class ClickHouseJournal : DbUp.Engine.IJournal + { + public ClickHouseJournal(System.Func connectionManagerFactory, System.Func logFactory, string tableName) { } + public void EnsureTableExistsAndIsLatestVersion(System.Func dbCommandFactory) { } + public string[] GetExecutedScripts() { } + public void StoreExecutedScript(DbUp.Engine.SqlScript script, System.Func dbCommandFactory) { } + } +} diff --git a/src/Tests/DatabaseSupportTests.cs b/src/Tests/DatabaseSupportTests.cs index 30eb010..100864a 100644 --- a/src/Tests/DatabaseSupportTests.cs +++ b/src/Tests/DatabaseSupportTests.cs @@ -1,7 +1,7 @@ using DbUp.Builder; using DbUp.Tests.Common; -namespace DbUp.NewProvider.Tests; +namespace DbUp.ClickHouse.Tests; public class DatabaseSupportTests : DatabaseSupportTestsBase { @@ -10,11 +10,11 @@ public DatabaseSupportTests() : base() } protected override UpgradeEngineBuilder DeployTo(SupportedDatabases to) - => to.NewProviderDatabase(""); + => to.ClickHouseDatabase(""); protected override UpgradeEngineBuilder AddCustomNamedJournalToBuilder(UpgradeEngineBuilder builder, string schema, string tableName) => builder.JournalTo( (connectionManagerFactory, logFactory) - => new NewProviderJournal(connectionManagerFactory, logFactory, tableName) + => new ClickHouseJournal(connectionManagerFactory, logFactory, tableName) ); } diff --git a/src/Tests/NoPublicApiChanges.cs b/src/Tests/NoPublicApiChanges.cs index 2fe9721..b98c14d 100644 --- a/src/Tests/NoPublicApiChanges.cs +++ b/src/Tests/NoPublicApiChanges.cs @@ -1,11 +1,11 @@ using DbUp.Tests.Common; -namespace DbUp.NewProvider.Tests; +namespace DbUp.ClickHouse.Tests; public class NoPublicApiChanges : NoPublicApiChangesBase { public NoPublicApiChanges() - : base(typeof(NewProviderExtensions).Assembly) + : base(typeof(ClickHouseExtensions).Assembly) { } } diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index 133f28b..d036074 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -1,19 +1,19 @@ - net462;net8 + net8 Tests - DbUp.NewProvider.Tests - + DbUp.ClickHouse.Tests + enable enable - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/dbup-newprovider.sln b/src/dbup-clickhouse.sln similarity index 91% rename from src/dbup-newprovider.sln rename to src/dbup-clickhouse.sln index d827e00..f9793b1 100644 --- a/src/dbup-newprovider.sln +++ b/src/dbup-clickhouse.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbup-newprovider", "dbup-newprovider\dbup-newprovider.csproj", "{2A7189BD-96CE-41CA-9100-E1B1DD10FF40}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbup-clickhouse", "dbup-clickhouse\dbup-clickhouse.csproj", "{2A7189BD-96CE-41CA-9100-E1B1DD10FF40}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{8CE634FE-6772-408E-9340-909F6218F8F7}" EndProject @@ -22,7 +22,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{77157734-01DA-4AA3-A15C-504013343B29}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig - dbup-newprovider.sln.DotSettings = dbup-newprovider.sln.DotSettings + dbup-clickhouse.sln.DotSettings = dbup-clickhouse.sln.DotSettings Directory.Build.props = Directory.Build.props EndProjectSection EndProject diff --git a/src/dbup-newprovider.sln.DotSettings b/src/dbup-clickhouse.sln.DotSettings similarity index 55% rename from src/dbup-newprovider.sln.DotSettings rename to src/dbup-clickhouse.sln.DotSettings index 2c78c0a..57ed69b 100644 --- a/src/dbup-newprovider.sln.DotSettings +++ b/src/dbup-clickhouse.sln.DotSettings @@ -5,5 +5,8 @@ SQ <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="aaBb" /></Policy> + True <data><IncludeFilters /><ExcludeFilters /></data> <data /> \ No newline at end of file diff --git a/src/dbup-clickhouse/ClickHouseExtensions.cs b/src/dbup-clickhouse/ClickHouseExtensions.cs new file mode 100644 index 0000000..17823ee --- /dev/null +++ b/src/dbup-clickhouse/ClickHouseExtensions.cs @@ -0,0 +1,12 @@ +using System; +using DbUp.Builder; + +namespace DbUp.ClickHouse; + +public static class ClickHouseExtensions +{ + public static UpgradeEngineBuilder ClickHouseDatabase(this SupportedDatabases supportedDatabases, string connectionString) + { + throw new NotImplementedException(); + } +} diff --git a/src/dbup-clickhouse/ClickHouseJournal.cs b/src/dbup-clickhouse/ClickHouseJournal.cs new file mode 100644 index 0000000..f5b504a --- /dev/null +++ b/src/dbup-clickhouse/ClickHouseJournal.cs @@ -0,0 +1,23 @@ +using System; +using System.Data; +using DbUp.Engine; +using DbUp.Engine.Output; +using DbUp.Engine.Transactions; + +namespace DbUp.ClickHouse; + +public class ClickHouseJournal( +// Remove pragma once implemented +#pragma warning disable CS9113 // Parameter is unread. + Func connectionManagerFactory, + Func logFactory, + string tableName +#pragma warning restore CS9113 // Parameter is unread. + ) : IJournal +{ + public string[] GetExecutedScripts() => throw new NotImplementedException(); + + public void StoreExecutedScript(SqlScript script, Func dbCommandFactory) => throw new NotImplementedException(); + + public void EnsureTableExistsAndIsLatestVersion(Func dbCommandFactory) => throw new NotImplementedException(); +} diff --git a/src/dbup-newprovider/dbup-newprovider.csproj b/src/dbup-clickhouse/dbup-clickhouse.csproj similarity index 54% rename from src/dbup-newprovider/dbup-newprovider.csproj rename to src/dbup-clickhouse/dbup-clickhouse.csproj index 222ae0d..f023af2 100644 --- a/src/dbup-newprovider/dbup-newprovider.csproj +++ b/src/dbup-clickhouse/dbup-clickhouse.csproj @@ -1,23 +1,23 @@  - DbUp makes it easy to deploy and upgrade SQL Server databases. This package adds NewProvider support. - DbUp NewProvider Support + DbUp makes it easy to deploy and upgrade SQL Server databases. This package adds ClickHouse support. + DbUp ClickHouse Support DbUp Contributors DbUp Copyright © DbUp Contributors 2015 - netstandard1.3;netstandard2.0;net35;net45 - dbup-newprovider - DbUp.NewProvider - dbup-newprovider + netstandard2.0 + dbup-clickhouse + DbUp.ClickHouse + dbup-clickhouse ../dbup.snk true - https://github.com/DbUp/dbup-newprovider.git + https://github.com/DbUp/dbup-clickhouse.git dbup-icon.png - +