Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 82d6dd6

Browse files
committed
Initial copy from main project
1 parent 4dc9ce0 commit 82d6dd6

22 files changed

+490
-25
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/DbUp/dbup-newprovider/CI/main)](https://github.com/DbUp/dbup-newprovider/actions/workflows/main.yml?query=branch%3Amain)
2-
[![NuGet](https://img.shields.io/nuget/dt/dbup-newprovider.svg)](https://www.nuget.org/packages/dbup-newprovider)
3-
[![NuGet](https://img.shields.io/nuget/v/dbup-newprovider.svg)](https://www.nuget.org/packages/dbup-newprovider)
4-
[![Prerelease](https://img.shields.io/nuget/vpre/dbup-newprovider?color=orange&label=prerelease)](https://www.nuget.org/packages/dbup-newprovider)
1+
[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/DbUp/dbup-sqlce/CI/main)](https://github.com/DbUp/dbup-sqlce/actions/workflows/main.yml?query=branch%3Amain)
2+
[![NuGet](https://img.shields.io/nuget/dt/dbup-sqlce.svg)](https://www.nuget.org/packages/dbup-sqlce)
3+
[![NuGet](https://img.shields.io/nuget/v/dbup-sqlce.svg)](https://www.nuget.org/packages/dbup-sqlce)
4+
[![Prerelease](https://img.shields.io/nuget/vpre/dbup-sqlce?color=orange&label=prerelease)](https://www.nuget.org/packages/dbup-sqlce)
55

6-
# DbUp NewProvider support
6+
# DbUp SQL CE Support
77
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.
88

99
## Getting Help
1010
To learn more about DbUp check out the [documentation](https://dbup.readthedocs.io/en/latest/)
1111

12-
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).
12+
Please only log issue related to SQL CE Support in this repo. For cross cutting issues, please use our [main issue list](https://github.com/DbUp/DbUp/issues).
1313

1414
# Contributing
1515

src/Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
<PropertyGroup>
55
<Authors>https://github.com/orgs/DbUp/people</Authors>
6-
<PackageReleaseNotes>https://github.com/DbUp/dbup-newprovider/releases</PackageReleaseNotes>
6+
<PackageReleaseNotes>https://github.com/DbUp/dbup-sqlce/releases</PackageReleaseNotes>
77
<PackageProjectUrl>https://dbup.github.io</PackageProjectUrl>
88
<PackageLicenseExpression>MIT</PackageLicenseExpression>
9-
<RepositoryUrl>https://github.com/dbup-newprovider/dbup-newprovider.git</RepositoryUrl>
9+
<RepositoryUrl>https://github.com/dbup-sqlce/dbup-sqlce.git</RepositoryUrl>
1010
<LangVersion>latest</LangVersion>
1111
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
1212
</PropertyGroup>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
DB Operation: Open connection
2+
Info: Beginning database upgrade
3+
Info: Checking whether journal table exists..
4+
DB Operation: Execute scalar command: SELECT count(*) FROM information_schema.tables WHERE table_name='SchemaVersions'
5+
DB Operation: Dispose command
6+
Info: Journal table does not exist
7+
Info: Executing Database Server script 'Script0001.sql'
8+
Info: Checking whether journal table exists..
9+
DB Operation: Execute scalar command: SELECT count(*) FROM information_schema.tables WHERE table_name='SchemaVersions'
10+
DB Operation: Dispose command
11+
Info: Creating the [SchemaVersions] table
12+
DB Operation: Execute non query command: create table [SchemaVersions] (
13+
[Id] int identity(1,1) not null constraint [PK_SchemaVersions_Id] primary key,
14+
[ScriptName] nvarchar(255) not null,
15+
[Applied] datetime not null
16+
)
17+
DB Operation: Dispose command
18+
Info: The [SchemaVersions] table has been created
19+
DB Operation: Execute non query command: script1contents
20+
DB Operation: Dispose command
21+
DB Operation: Create parameter
22+
Info: DB Operation: Add parameter to command: scriptName=Script0001.sql
23+
DB Operation: Create parameter
24+
Info: DB Operation: Add parameter to command: applied=<date>
25+
DB Operation: Execute non query command: insert into [SchemaVersions] (ScriptName, Applied) values (@scriptName, @applied)
26+
DB Operation: Dispose command
27+
Info: Upgrade successful
28+
DB Operation: Dispose connection
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
DB Operation: Open connection
2+
Info: Beginning database upgrade
3+
Info: Checking whether journal table exists..
4+
DB Operation: Execute scalar command: SELECT count(*) FROM information_schema.tables WHERE table_schema = 'test'AND table_name = 'TestSchemaVersions')
5+
DB Operation: Dispose command
6+
Info: Journal table does not exist
7+
Info: Executing Database Server script 'Script0001.sql'
8+
Info: Checking whether journal table exists..
9+
DB Operation: Execute scalar command: SELECT count(*) FROM information_schema.tables WHERE table_schema = 'test'AND table_name = 'TestSchemaVersions')
10+
DB Operation: Dispose command
11+
Info: Creating the [test].[TestSchemaVersions] table
12+
DB Operation: Execute non query command: create table [test].[TestSchemaVersions] (
13+
[Id] int identity(1,1) not null constraint [PK_TestSchemaVersions_Id] primary key,
14+
[ScriptName] nvarchar(255) not null,
15+
[Applied] datetime not null
16+
)
17+
DB Operation: Dispose command
18+
Info: The [test].[TestSchemaVersions] table has been created
19+
DB Operation: Execute non query command: script1contents
20+
DB Operation: Dispose command
21+
DB Operation: Create parameter
22+
Info: DB Operation: Add parameter to command: scriptName=Script0001.sql
23+
DB Operation: Create parameter
24+
Info: DB Operation: Add parameter to command: applied=<date>
25+
DB Operation: Execute non query command: insert into [test].[TestSchemaVersions] (ScriptName, Applied) values (@scriptName, @applied)
26+
DB Operation: Dispose command
27+
Info: Upgrade successful
28+
DB Operation: Dispose connection
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
DB Operation: Open connection
2+
Info: Beginning database upgrade
3+
Info: Checking whether journal table exists..
4+
DB Operation: Execute scalar command: SELECT count(*) FROM information_schema.tables WHERE table_name='SchemaVersions'
5+
DB Operation: Dispose command
6+
Info: Journal table does not exist
7+
Info: Executing Database Server script 'Script0001.sql'
8+
Info: Checking whether journal table exists..
9+
DB Operation: Execute scalar command: SELECT count(*) FROM information_schema.tables WHERE table_name='SchemaVersions'
10+
DB Operation: Dispose command
11+
Info: Creating the [SchemaVersions] table
12+
DB Operation: Execute non query command: create table [SchemaVersions] (
13+
[Id] int identity(1,1) not null constraint [PK_SchemaVersions_Id] primary key,
14+
[ScriptName] nvarchar(255) not null,
15+
[Applied] datetime not null
16+
)
17+
DB Operation: Dispose command
18+
Info: The [SchemaVersions] table has been created
19+
DB Operation: Execute non query command: print SubstitutedValue
20+
DB Operation: Dispose command
21+
DB Operation: Create parameter
22+
Info: DB Operation: Add parameter to command: scriptName=Script0001.sql
23+
DB Operation: Create parameter
24+
Info: DB Operation: Add parameter to command: applied=<date>
25+
DB Operation: Execute non query command: insert into [SchemaVersions] (ScriptName, Applied) values (@scriptName, @applied)
26+
DB Operation: Dispose command
27+
Info: Upgrade successful
28+
DB Operation: Dispose connection
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[assembly: System.CLSCompliantAttribute(true)]
2+
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
3+
[assembly: System.Runtime.InteropServices.GuidAttribute("2523f9cc-42c7-48da-b873-74851c335931")]
4+
5+
public static class SqlCeExtensions
6+
{
7+
public static DbUp.Builder.UpgradeEngineBuilder SqlCeDatabase(this DbUp.Builder.SupportedDatabases supported, string connectionString) { }
8+
public static DbUp.Builder.UpgradeEngineBuilder SqlCeDatabase(this DbUp.Builder.SupportedDatabases supported, DbUp.Engine.Transactions.IConnectionManager connectionManager) { }
9+
}
10+
namespace DbUp.SqlCe
11+
{
12+
public class SqlCeConnectionManager : DbUp.Engine.Transactions.DatabaseConnectionManager, DbUp.Engine.Transactions.IConnectionManager
13+
{
14+
public SqlCeConnectionManager(string connectionString) { }
15+
public override System.Collections.Generic.IEnumerable<string> SplitScriptIntoCommands(string scriptContents) { }
16+
}
17+
public class SqlCeObjectParser : DbUp.Support.SqlObjectParser, DbUp.Engine.ISqlObjectParser
18+
{
19+
public SqlCeObjectParser() { }
20+
}
21+
public class SqlCePreprocessor : DbUp.Engine.IScriptPreprocessor
22+
{
23+
public SqlCePreprocessor() { }
24+
public string Process(string contents) { }
25+
}
26+
public class SqlCeScriptExecutor : DbUp.Support.ScriptExecutor, DbUp.Engine.IScriptExecutor
27+
{
28+
public SqlCeScriptExecutor(System.Func<DbUp.Engine.Transactions.IConnectionManager> connectionManagerFactory, System.Func<DbUp.Engine.Output.IUpgradeLog> log, string schema, System.Func<bool> variablesEnabled, System.Collections.Generic.IEnumerable<DbUp.Engine.IScriptPreprocessor> scriptPreprocessors, System.Func<DbUp.Engine.IJournal> journal) { }
29+
protected override void ExecuteCommandsWithinExceptionHandler(int index, DbUp.Engine.SqlScript script, System.Action executeCommand) { }
30+
protected override string GetVerifySchemaSql(string schema) { }
31+
}
32+
public class SqlCeTableJournal : DbUp.Support.TableJournal, DbUp.Engine.IJournal
33+
{
34+
public SqlCeTableJournal(System.Func<DbUp.Engine.Transactions.IConnectionManager> connectionManager, System.Func<DbUp.Engine.Output.IUpgradeLog> logger, string schema, string table) { }
35+
protected override string CreateSchemaTableSql(string quotedPrimaryKeyName) { }
36+
protected override string DoesTableExistSql() { }
37+
protected override string GetInsertJournalEntrySql(string scriptName, string applied) { }
38+
protected override string GetJournalEntriesSql() { }
39+
}
40+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[assembly: System.CLSCompliantAttribute(true)]
2+
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
3+
[assembly: System.Runtime.InteropServices.GuidAttribute("2523f9cc-42c7-48da-b873-74851c335931")]
4+
5+
public static class SqlCeExtensions
6+
{
7+
public static DbUp.Builder.UpgradeEngineBuilder SqlCeDatabase(this DbUp.Builder.SupportedDatabases supported, string connectionString) { }
8+
public static DbUp.Builder.UpgradeEngineBuilder SqlCeDatabase(this DbUp.Builder.SupportedDatabases supported, DbUp.Engine.Transactions.IConnectionManager connectionManager) { }
9+
}
10+
namespace DbUp.SqlCe
11+
{
12+
public class SqlCeConnectionManager : DbUp.Engine.Transactions.DatabaseConnectionManager, DbUp.Engine.Transactions.IConnectionManager
13+
{
14+
public SqlCeConnectionManager(string connectionString) { }
15+
public override System.Collections.Generic.IEnumerable<string> SplitScriptIntoCommands(string scriptContents) { }
16+
}
17+
public class SqlCeObjectParser : DbUp.Support.SqlObjectParser, DbUp.Engine.ISqlObjectParser
18+
{
19+
public SqlCeObjectParser() { }
20+
}
21+
public class SqlCePreprocessor : DbUp.Engine.IScriptPreprocessor
22+
{
23+
public SqlCePreprocessor() { }
24+
public string Process(string contents) { }
25+
}
26+
public class SqlCeScriptExecutor : DbUp.Support.ScriptExecutor, DbUp.Engine.IScriptExecutor
27+
{
28+
public SqlCeScriptExecutor(System.Func<DbUp.Engine.Transactions.IConnectionManager> connectionManagerFactory, System.Func<DbUp.Engine.Output.IUpgradeLog> log, string schema, System.Func<bool> variablesEnabled, System.Collections.Generic.IEnumerable<DbUp.Engine.IScriptPreprocessor> scriptPreprocessors, System.Func<DbUp.Engine.IJournal> journal) { }
29+
protected override void ExecuteCommandsWithinExceptionHandler(int index, DbUp.Engine.SqlScript script, System.Action executeCommand) { }
30+
protected override string GetVerifySchemaSql(string schema) { }
31+
}
32+
public class SqlCeTableJournal : DbUp.Support.TableJournal, DbUp.Engine.IJournal
33+
{
34+
public SqlCeTableJournal(System.Func<DbUp.Engine.Transactions.IConnectionManager> connectionManager, System.Func<DbUp.Engine.Output.IUpgradeLog> logger, string schema, string table) { }
35+
protected override string CreateSchemaTableSql(string quotedPrimaryKeyName) { }
36+
protected override string DoesTableExistSql() { }
37+
protected override string GetInsertJournalEntrySql(string scriptName, string applied) { }
38+
protected override string GetJournalEntriesSql() { }
39+
}
40+
}

src/Tests/DatabaseSupportTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#if !NETCORE
2+
using DbUp.Builder;
3+
using DbUp.SqlCe;
4+
using DbUp.Tests.Common;
5+
6+
namespace DbUp.Tests.Providers.SqlCe;
7+
8+
public class DatabaseSupportTests : DatabaseSupportTestsBase
9+
{
10+
public DatabaseSupportTests() : base()
11+
{
12+
}
13+
14+
protected override UpgradeEngineBuilder DeployTo(SupportedDatabases to)
15+
=> to.SqlCeDatabase("");
16+
17+
protected override UpgradeEngineBuilder AddCustomNamedJournalToBuilder(UpgradeEngineBuilder builder, string schema, string tableName)
18+
=> builder.JournalTo(
19+
(connectionManagerFactory, logFactory)
20+
=> new SqlCeTableJournal(connectionManagerFactory, logFactory, schema, tableName)
21+
);
22+
}
23+
#endif

src/Tests/NoPublicApiChanges.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#if !NETCORE
2+
using DbUp.Tests.Common;
3+
4+
namespace DbUp.Tests.Providers.SqlCe;
5+
6+
public class NoPublicApiChanges : NoPublicApiChangesBase
7+
{
8+
public NoPublicApiChanges()
9+
: base(typeof(SqlCeExtensions).Assembly)
10+
{
11+
}
12+
}
13+
#endif

src/Tests/SqlCeSupportTests.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#if !NETCORE
2+
using System;
3+
using System.Data.SqlServerCe;
4+
using System.IO;
5+
using Shouldly;
6+
using Xunit;
7+
8+
namespace DbUp.Tests.Support.SqlCe
9+
{
10+
public class SqlCeSupportTests
11+
{
12+
[Fact]
13+
public void CanUseSqlCe4()
14+
{
15+
const string connectionString = "Data Source=test.sdf; Persist Security Info=False";
16+
17+
if (!File.Exists("test.sdf"))
18+
{
19+
var engine = new SqlCeEngine(connectionString);
20+
engine.CreateDatabase();
21+
}
22+
23+
//Verify supports scripts which specify schema (To Support SqlCe and Sql with Schemas)
24+
var upgrader = DeployChanges.To
25+
.SqlCeDatabase(connectionString)
26+
.WithScript("Script0001", "create table $schema$.Foo (Id int)")
27+
.Build();
28+
29+
var result = upgrader.PerformUpgrade();
30+
31+
result.Successful.ShouldBe(true);
32+
}
33+
}
34+
}
35+
#endif

src/Tests/Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net462;net8</TargetFrameworks>
4+
<TargetFrameworks>net462</TargetFrameworks>
55
<AssemblyName>Tests</AssemblyName>
6-
<RootNamespace>DbUp.NewProvider.Tests</RootNamespace>
6+
<RootNamespace>DbUp.SqlCe.Tests</RootNamespace>
77
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
88
<!-- <ImplicitUsings>enable</ImplicitUsings> Can't use implict usings with net46 -->
99
<Nullable>enable</Nullable>
@@ -12,7 +12,7 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<ProjectReference Include="..\dbup-newprovider\dbup-newprovider.csproj" />
15+
<ProjectReference Include="..\dbup-sqlce\dbup-sqlce.csproj" />
1616
<PackageReference Include="DbUp.Tests.Common" Version="5.0.37" />
1717
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
1818
<PackageReference Include="xunit" Version="2.6.6" />

src/dbup-newprovider.sln renamed to src/dbup-sqlce.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbup-newprovider", "dbup-newprovider\dbup-newprovider.csproj", "{2A7189BD-96CE-41CA-9100-E1B1DD10FF40}"
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbup-sqlce", "dbup-sqlce\dbup-sqlce.csproj", "{2A7189BD-96CE-41CA-9100-E1B1DD10FF40}"
44
EndProject
55
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{8CE634FE-6772-408E-9340-909F6218F8F7}"
66
EndProject
@@ -22,7 +22,7 @@ EndProject
2222
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{77157734-01DA-4AA3-A15C-504013343B29}"
2323
ProjectSection(SolutionItems) = preProject
2424
.editorconfig = .editorconfig
25-
dbup-newprovider.sln.DotSettings = dbup-newprovider.sln.DotSettings
25+
dbup-sqlce.sln.DotSettings = dbup-sqlce.sln.DotSettings
2626
EndProjectSection
2727
EndProject
2828
Global
File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Reflection;
3+
using System.Runtime.InteropServices;
4+
5+
[assembly: AssemblyCompany("DbUp Contributors")]
6+
[assembly: AssemblyProduct("DbUp")]
7+
[assembly: AssemblyCopyright("Copyright © DbUp Contributors 2015")]
8+
[assembly: ComVisible(false)]
9+
[assembly: CLSCompliant(true)]
10+
11+
// The following GUID is for the ID of the typelib if this project is exposed to COM
12+
[assembly: Guid("2523f9cc-42c7-48da-b873-74851c335931")]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Collections.Generic;
2+
using System.Data.SqlServerCe;
3+
using DbUp.Engine.Transactions;
4+
using DbUp.Support;
5+
6+
namespace DbUp.SqlCe
7+
{
8+
/// <summary>
9+
/// Manages SqlCe Database Connections
10+
/// </summary>
11+
public class SqlCeConnectionManager : DatabaseConnectionManager
12+
{
13+
/// <summary>
14+
/// Manages SqlCe Database Connections
15+
/// </summary>
16+
/// <param name="connectionString"></param>
17+
public SqlCeConnectionManager(string connectionString) : base(l => new SqlCeConnection(connectionString))
18+
{
19+
}
20+
21+
public override IEnumerable<string> SplitScriptIntoCommands(string scriptContents)
22+
{
23+
var commandSplitter = new SqlCommandSplitter();
24+
var scriptStatements = commandSplitter.SplitScriptIntoCommands(scriptContents);
25+
return scriptStatements;
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)