├── Build.bat
├── License.txt
├── packages
├── NUnit.2.6.0.12054
│ ├── tools
│ │ ├── runpnunit.bat
│ │ ├── agent.conf
│ │ ├── nunit.exe
│ │ ├── lib
│ │ │ ├── fit.dll
│ │ │ ├── Failure.png
│ │ │ ├── Ignored.png
│ │ │ ├── Skipped.png
│ │ │ ├── Success.png
│ │ │ ├── log4net.dll
│ │ │ ├── nunit.core.dll
│ │ │ ├── nunit.uikit.dll
│ │ │ ├── nunit.util.dll
│ │ │ ├── Inconclusive.png
│ │ │ ├── nunit-gui-runner.dll
│ │ │ ├── nunit.fixtures.dll
│ │ │ ├── nunit.uiexception.dll
│ │ │ ├── nunit-console-runner.dll
│ │ │ └── nunit.core.interfaces.dll
│ │ ├── runFile.exe
│ │ ├── nunit-x86.exe
│ │ ├── nunit-agent.exe
│ │ ├── pnunit-agent.exe
│ │ ├── pnunit.tests.dll
│ │ ├── nunit-agent-x86.exe
│ │ ├── nunit-console.exe
│ │ ├── nunit.framework.dll
│ │ ├── pnunit-launcher.exe
│ │ ├── nunit-console-x86.exe
│ │ ├── pnunit.framework.dll
│ │ ├── agent.log.conf
│ │ ├── launcher.log.conf
│ │ ├── NUnitTests.nunit
│ │ ├── test.conf
│ │ ├── runFile.exe.config
│ │ ├── nunit-console.exe.config
│ │ ├── nunit-agent.exe.config
│ │ ├── nunit-console-x86.exe.config
│ │ ├── nunit-agent-x86.exe.config
│ │ ├── pnunit-agent.exe.config
│ │ ├── pnunit-launcher.exe.config
│ │ ├── nunit.exe.config
│ │ ├── nunit-x86.exe.config
│ │ └── NUnitTests.config
│ ├── license.txt
│ └── lib
│ │ └── nunit.framework.dll
├── Moq.4.0.10827
│ ├── Moq.chm
│ ├── lib
│ │ ├── NET35
│ │ │ ├── Moq.dll
│ │ │ └── Moq.pdb
│ │ ├── NET40
│ │ │ ├── Moq.dll
│ │ │ └── Moq.pdb
│ │ └── Silverlight4
│ │ │ ├── Castle.Core.dll
│ │ │ ├── Moq.Silverlight.dll
│ │ │ └── Moq.Silverlight.pdb
│ └── License.txt
└── repositories.config
├── Build.ps1
├── .editorconfig
├── Insight.Database.Schema
├── GlobalSuppressions.cs
├── packages.config
├── SchemaEventType.cs
├── SchemaEventConsoleLogger.cs
├── Implementation
│ ├── Script.cs
│ ├── Contract.cs
│ ├── Service.cs
│ ├── BrokerPriority.cs
│ ├── Role.cs
│ ├── User.cs
│ ├── Function.cs
│ ├── View.cs
│ ├── Table.cs
│ ├── StoredProcedure.cs
│ ├── Certificate.cs
│ ├── Trigger.cs
│ ├── SymmetricKey.cs
│ ├── MasterKey.cs
│ ├── Constraint.cs
│ ├── Schema.cs
│ ├── MessageType.cs
│ ├── Login.cs
│ ├── Queue.cs
│ ├── PartitionFunction.cs
│ ├── UserDefinedType.cs
│ ├── Index.cs
│ ├── PartitionScheme.cs
│ ├── PrimaryKey.cs
│ ├── Default.cs
│ ├── AutoProc.cs
│ ├── Permission.cs
│ └── SchemaImpl.cs
├── IColumnDefinitionProvider.cs
├── CodeAnalysisRules.ruleset
├── SchemaRegistryEntry.cs
├── Properties
│ └── AssemblyInfo.cs
├── ColumnDefinition.cs
├── SchemaEventArgs.cs
├── LambdaComparer.cs
├── SchemaException.cs
├── SchemaParsingException.cs
├── ConnectionExtensions.cs
├── Singularizer.cs
├── SqlName.cs
├── SchemaEventLogger.cs
├── RecordingDbCommand.cs
├── SqlColumnDefinitionProvider.cs
└── SchemaObjectType.cs
├── .hgignore
├── Insight.Database.Schema.Sample
├── app.config
├── Receipts.sql
├── Sizes.sql
├── Glasses.sql
├── Servings.sql
├── Beer.sql
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
└── Insight.Database.Schema.Sample.csproj
├── Insight.Database.Schema.Tests
├── packages.config
├── SingularizerTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── DatabaseTests.cs
├── BaseInstallerTest.cs
├── SqlParserTests.cs
└── Insight.Database.Schema.Tests.csproj
├── .gitignore
├── Insight.Database.Schema.Installer
├── App.config
├── Properties
│ └── AssemblyInfo.cs
└── Insight.Database.Schema.Installer.csproj
├── Insight.Database.Schema.Verifier
├── App.config
├── Properties
│ └── AssemblyInfo.cs
└── Insight.Database.Schema.Verifier.csproj
├── Properties
├── Settings.settings
├── AssemblyInfo.cs
├── Settings.Designer.cs
├── Resources.Designer.cs
└── Resources.resx
├── Building.txt
├── Insight.Database.Schema.nuspec
├── .hgtags
├── Build.psake.ps1
├── README.md
├── TestSchema.sql
├── autobuild.proj
└── Insight.sln
/Build.bat:
--------------------------------------------------------------------------------
1 | PowerShell .\build.ps1 %1
--------------------------------------------------------------------------------
/License.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/License.txt
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/runpnunit.bat:
--------------------------------------------------------------------------------
1 | start pnunit-agent agent.conf
2 | pnunit-launcher test.conf
--------------------------------------------------------------------------------
/Build.ps1:
--------------------------------------------------------------------------------
1 | param (
2 | [string] $target = "default"
3 | )
4 |
5 | Invoke-psake .\Build.psake.ps1 -taskList $target
6 |
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/Moq.chm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/Moq.4.0.10827/Moq.chm
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/license.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/license.txt
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/lib/NET35/Moq.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/Moq.4.0.10827/lib/NET35/Moq.dll
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/lib/NET35/Moq.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/Moq.4.0.10827/lib/NET35/Moq.pdb
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/lib/NET40/Moq.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/Moq.4.0.10827/lib/NET40/Moq.dll
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/lib/NET40/Moq.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/Moq.4.0.10827/lib/NET40/Moq.pdb
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/agent.conf:
--------------------------------------------------------------------------------
1 |
2 | 8080
3 | .
4 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/nunit.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/nunit.exe
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | [*]
2 | end_of_line = crlf
3 | insert_final_newline = true
4 | indent_style = tab
5 | indent_size = 4
6 | trim_tailing_whitespace = true
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/fit.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/fit.dll
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/runFile.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/runFile.exe
--------------------------------------------------------------------------------
/Insight.Database.Schema/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/Insight.Database.Schema/GlobalSuppressions.cs
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/nunit-x86.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/nunit-x86.exe
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/Failure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/Failure.png
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/Ignored.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/Ignored.png
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/Skipped.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/Skipped.png
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/Success.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/Success.png
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/log4net.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/log4net.dll
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/nunit-agent.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/nunit-agent.exe
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/pnunit-agent.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/pnunit-agent.exe
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/pnunit.tests.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/pnunit.tests.dll
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/lib/nunit.framework.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/lib/nunit.framework.dll
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/nunit.core.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/nunit.core.dll
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/nunit.uikit.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/nunit.uikit.dll
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/nunit.util.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/nunit.util.dll
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/nunit-agent-x86.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/nunit-agent-x86.exe
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/nunit-console.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/nunit-console.exe
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/nunit.framework.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/nunit.framework.dll
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/pnunit-launcher.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/pnunit-launcher.exe
--------------------------------------------------------------------------------
/.hgignore:
--------------------------------------------------------------------------------
1 | glob:bin
2 | glob:obj
3 | glob:*.user
4 | glob:*.suo
5 | syntax: glob
6 | *.docstates
7 | *.nupkg
8 | *.orig
9 | *.rej
10 | StyleCop.Cache
11 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/Inconclusive.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/Inconclusive.png
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/nunit-console-x86.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/nunit-console-x86.exe
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/pnunit.framework.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/pnunit.framework.dll
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/lib/Silverlight4/Castle.Core.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/Moq.4.0.10827/lib/Silverlight4/Castle.Core.dll
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/nunit-gui-runner.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/nunit-gui-runner.dll
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/nunit.fixtures.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/nunit.fixtures.dll
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/lib/Silverlight4/Moq.Silverlight.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/Moq.4.0.10827/lib/Silverlight4/Moq.Silverlight.dll
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/lib/Silverlight4/Moq.Silverlight.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/Moq.4.0.10827/lib/Silverlight4/Moq.Silverlight.pdb
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/nunit.uiexception.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/nunit.uiexception.dll
--------------------------------------------------------------------------------
/Insight.Database.Schema/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/nunit-console-runner.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/nunit-console-runner.dll
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/lib/nunit.core.interfaces.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fg/Insight.Database.Schema/master/packages/NUnit.2.6.0.12054/tools/lib/nunit.core.interfaces.dll
--------------------------------------------------------------------------------
/Insight.Database.Schema.Sample/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | obj
3 | *.user
4 | *.suo
5 | *.docstates
6 | *.nupkg
7 | *.orig
8 | *.rej
9 | StyleCop.Cache
10 |
11 | TestResult.xml
12 |
13 | Insight.Database.Schema.Tests.dll.config
14 | packages
--------------------------------------------------------------------------------
/Insight.Database.Schema.Installer/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Verifier/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/packages/repositories.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Sample/Receipts.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE [Receipts]
2 | (
3 | [ID] [int] NOT NULL,
4 | [Name] [nvarchar](128) NOT NULL
5 | ) ON [PRIMARY]
6 | GO
7 |
8 | ALTER TABLE [Receipts] WITH NOCHECK ADD CONSTRAINT [PK_Receipts] PRIMARY KEY NONCLUSTERED
9 | (
10 | [ID]
11 | )
12 | GO
13 |
14 | -- AUTOPROC All [Receipts]
15 | GO
--------------------------------------------------------------------------------
/Insight.Database.Schema.Sample/Sizes.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE [Sizes]
2 | (
3 | [BeerID] [int] NOT NULL,
4 | [GlassID] [int] NOT NULL,
5 | ) ON [PRIMARY]
6 | GO
7 |
8 | ALTER TABLE [Sizes] WITH NOCHECK ADD CONSTRAINT [PK_Sizes] PRIMARY KEY NONCLUSTERED
9 | (
10 | [BeerID],
11 | [GlassID]
12 | )
13 | GO
14 |
15 | -- AUTOPROC All [Sizes]
16 | GO
--------------------------------------------------------------------------------
/Insight.Database.Schema.Sample/Glasses.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE [Glasses]
2 | (
3 | [ID] [int] IDENTITY,
4 | [Name] [varchar](32) NULL,
5 | [Ounces] [int] NULL
6 | ) ON [PRIMARY]
7 | GO
8 |
9 | ALTER TABLE [Glasses] WITH NOCHECK ADD CONSTRAINT [PK_Glasses] PRIMARY KEY NONCLUSTERED
10 | (
11 | [ID]
12 | )
13 | GO
14 |
15 | -- AUTOPROC All [Glasses]
16 | GO
17 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Sample/Servings.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE [Servings]
2 | (
3 | [ID] [int] IDENTITY,
4 | [BeerID] [int] NOT NULL,
5 | [GlassesID] [int] NOT NULL,
6 | [When] [datetime] NULL,
7 | ) ON [PRIMARY]
8 | GO
9 |
10 | ALTER TABLE [Servings] WITH NOCHECK ADD CONSTRAINT [PK_Servings] PRIMARY KEY NONCLUSTERED
11 | (
12 | [ID]
13 | )
14 | GO
15 |
16 | -- AUTOPROC All [Servings]
17 | GO
--------------------------------------------------------------------------------
/Insight.Database.Schema/SchemaEventType.cs:
--------------------------------------------------------------------------------
1 | #region Using directives
2 |
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 |
7 | #endregion
8 |
9 | namespace Insight.Database.Schema
10 | {
11 | ///
12 | /// The type of schema event
13 | ///
14 | public enum SchemaEventType
15 | {
16 | BeforeDrop,
17 | BeforeCreate,
18 | AfterCreate,
19 | DropFailed
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/SchemaEventConsoleLogger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Insight.Database.Schema
7 | {
8 | ///
9 | /// Logs console events to the console
10 | ///
11 | public class SchemaEventConsoleLogger : SchemaEventLogger
12 | {
13 | public override void LogSchemaChange (SchemaEventArgs se)
14 | {
15 | Console.WriteLine (FormatEventArgs (se));
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Building.txt:
--------------------------------------------------------------------------------
1 | Notes for Building Insight.Database.Schema
2 | ==========================================
3 |
4 | * Build requires Psake. You can get it from http://nuget.org/packages/Psake
5 | * You will need to provide your own Insight.Database.Schema.Tests.dll.config file with your test connection strings. Try this one:
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Sample/Beer.sql:
--------------------------------------------------------------------------------
1 | CREATE TABLE [Beer]
2 | (
3 | [ID] [int] IDENTITY,
4 | [Name] [nvarchar](128) NOT NULL,
5 | [Flavor] [nvarchar](128) NULL,
6 | [OriginalGravity] [decimal](18, 2) NULL,
7 | [Details] [varchar](MAX),
8 | [Hoppiness] [int] DEFAULT(6),
9 | [Yumminess] AS [Hoppiness] * 2,
10 | [RowVersion] [timestamp]
11 | ) ON [PRIMARY]
12 | GO
13 |
14 | ALTER TABLE [Beer] WITH NOCHECK ADD CONSTRAINT [PK_Beer] PRIMARY KEY NONCLUSTERED
15 | (
16 | [ID]
17 | )
18 | GO
19 |
20 | -- AUTOPROC All,Optimistic [Beer]
21 | GO
22 |
23 | GRANT ALL ON SelectBeer TO [public]
24 | GO
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/agent.log.conf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/launcher.log.conf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Script.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class Script : SchemaImpl
11 | {
12 | public Script(string name, string sql) : base(name, sql, 1)
13 | {
14 | }
15 |
16 | public override bool Exists(IDbConnection connection)
17 | {
18 | return true;
19 | }
20 |
21 | public override bool CanDrop(SchemaInstaller.InstallContext context, IDbConnection connection)
22 | {
23 | return false;
24 | }
25 |
26 | public override void Drop(IDbConnection connection)
27 | {
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/NUnitTests.nunit:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/IColumnDefinitionProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Insight.Database.Schema
7 | {
8 | ///
9 | /// Provides the schema engine the definitions of the columns of a table.
10 | ///
11 | /// This class is framework code and is not intended to be used by external code.
12 | public interface IColumnDefinitionProvider
13 | {
14 | ///
15 | /// Returns the column definitions for a given table.
16 | ///
17 | /// The name of the table.
18 | /// A list of the columns for the table.
19 | IList GetColumns(SqlName tableName);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Contract.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class Contract : SchemaImpl
11 | {
12 | public Contract(string name, string sql) : base(name, sql, 1)
13 | {
14 | }
15 |
16 | public override bool Exists(IDbConnection connection)
17 | {
18 | return 0 < connection.ExecuteScalarSql(String.Format(@"
19 | SELECT COUNT (*)
20 | FROM sys.service_contracts
21 | WHERE name = '{0}'",
22 | Name.Object));
23 | }
24 |
25 | public override void Drop(IDbConnection connection)
26 | {
27 | connection.ExecuteSql(String.Format(@"DROP CONTRACT {0}", Name.ObjectFormatted));
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Service.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Text.RegularExpressions;
8 |
9 | namespace Insight.Database.Schema.Implementation
10 | {
11 | class Service : SchemaImpl
12 | {
13 | public Service(string name, string sql) : base(name, sql, 1)
14 | {
15 | }
16 |
17 | public override bool Exists(IDbConnection connection)
18 | {
19 | return 0 < connection.ExecuteScalarSql(String.Format(@"
20 | SELECT COUNT (*)
21 | FROM sys.services
22 | WHERE name = '{0}'",
23 | Name.Object));
24 | }
25 |
26 | public override void Drop(IDbConnection connection)
27 | {
28 | connection.ExecuteSql(String.Format(@"DROP SERVICE {0}", Name.ObjectFormatted));
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/BrokerPriority.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class BrokerPriority : SchemaImpl
11 | {
12 | public BrokerPriority(string name, string sql) : base(name, sql, 1)
13 | {
14 | }
15 |
16 | public override bool Exists(IDbConnection connection)
17 | {
18 | return 0 < connection.ExecuteScalarSql(String.Format(@"
19 | SELECT COUNT (*)
20 | FROM sys.conversation_priorities
21 | WHERE name = '{0}'",
22 | Name.Object));
23 | }
24 |
25 | public override void Drop(IDbConnection connection)
26 | {
27 | connection.ExecuteSql(String.Format(@"DROP BROKER PRIORITY {0}", Name.ObjectFormatted));
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Role.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Text.RegularExpressions;
8 |
9 | namespace Insight.Database.Schema.Implementation
10 | {
11 | class Role : SchemaImpl
12 | {
13 | public Role(string name, string sql) : base(name, sql, 1)
14 | {
15 | }
16 |
17 | public override bool Exists(IDbConnection connection)
18 | {
19 | return 0 < connection.ExecuteScalarSql(String.Format(@"
20 | SELECT COUNT (*)
21 | FROM sys.database_principals WHERE name = '{0}' AND type = 'R'",
22 | Name.Object));
23 | }
24 |
25 | public override void Drop(IDbConnection connection)
26 | {
27 | connection.ExecuteSql(String.Format(@"DROP ROLE {0}", Name.ObjectFormatted));
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/User.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Text.RegularExpressions;
8 |
9 | namespace Insight.Database.Schema.Implementation
10 | {
11 | class User : SchemaImpl
12 | {
13 | public User(string name, string sql) : base(name, sql, 1)
14 | {
15 | }
16 |
17 | public override bool Exists(IDbConnection connection)
18 | {
19 | return 0 < connection.ExecuteScalarSql(String.Format(@"
20 | SELECT COUNT (*)
21 | FROM sys.database_principals WHERE name = '{0}' AND type <> 'R'",
22 | Name.Object));
23 | }
24 |
25 | public override void Drop(IDbConnection connection)
26 | {
27 | connection.ExecuteSql(String.Format(@"DROP USER {0}", Name.ObjectFormatted));
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/CodeAnalysisRules.ruleset:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/test.conf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Testing
6 |
7 |
8 | Testing
9 | pnunit.tests.dll
10 | TestLibraries.Testing.EqualTo19
11 | localhost:8080
12 |
13 | ..\server
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Function.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class Function : SchemaImpl
11 | {
12 | public Function(string name, string sql) : base(name, sql, 2)
13 | {
14 | }
15 |
16 | public override bool Exists(IDbConnection connection)
17 | {
18 | return 0 < connection.ExecuteScalarSql(String.Format(@"
19 | SELECT COUNT (*)
20 | FROM sys.objects o
21 | JOIN sys.schemas s ON (o.schema_id = s.schema_id)
22 | WHERE s.name = '{0}' AND o.name = '{1}'",
23 | Name.Schema,
24 | Name.Object));
25 | }
26 |
27 | public override void Drop(IDbConnection connection)
28 | {
29 | connection.ExecuteSql(String.Format(@"DROP FUNCTION {0}", Name.SchemaQualifiedObject));
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/View.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Text.RegularExpressions;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class View : SchemaImpl
11 | {
12 | public View(string name, string sql) : base(name, sql, 2)
13 | {
14 | }
15 |
16 | public override bool Exists(System.Data.IDbConnection connection)
17 | {
18 | return 0 < connection.ExecuteScalarSql(String.Format(@"
19 | SELECT COUNT (*)
20 | FROM sys.views v
21 | JOIN sys.schemas s ON (v.schema_id = s.schema_id)
22 | WHERE s.name = '{0}' AND v.name = '{1}'",
23 | Name.Schema,
24 | Name.Table));
25 | }
26 |
27 | public override void Drop(System.Data.IDbConnection connection)
28 | {
29 | connection.ExecuteSql(String.Format ("DROP VIEW {0}", Name.FullName));
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Table.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Text.RegularExpressions;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class Table : SchemaImpl
11 | {
12 | public Table(string name, string sql) : base(name, sql, 2)
13 | {
14 | }
15 |
16 | public override bool Exists(System.Data.IDbConnection connection)
17 | {
18 | return 0 < connection.ExecuteScalarSql(String.Format(@"
19 | SELECT COUNT (*)
20 | FROM sys.tables t
21 | JOIN sys.schemas s ON (t.schema_id = s.schema_id)
22 | WHERE s.name = '{0}' AND t.name = '{1}'",
23 | Name.Schema,
24 | Name.Table));
25 | }
26 |
27 | public override void Drop(System.Data.IDbConnection connection)
28 | {
29 | connection.ExecuteSql(String.Format ("DROP TABLE {0}", Name.FullName));
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/StoredProcedure.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class StoredProcedure : SchemaImpl
11 | {
12 | public StoredProcedure(string name, string sql) : base(name, sql, 2)
13 | {
14 | }
15 |
16 | public override bool Exists(IDbConnection connection)
17 | {
18 | return 0 < connection.ExecuteScalarSql(String.Format(@"
19 | SELECT COUNT (*)
20 | FROM sys.procedures p
21 | JOIN sys.schemas s ON (p.schema_id = s.schema_id)
22 | WHERE s.name = '{0}' AND p.name = '{1}'",
23 | Name.Schema,
24 | Name.Object));
25 | }
26 |
27 | public override void Drop(IDbConnection connection)
28 | {
29 | connection.ExecuteSql(String.Format(@"DROP PROCEDURE {0}",
30 | Name.SchemaQualifiedObject));
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/SchemaRegistryEntry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Insight.Database.Schema
7 | {
8 | ///
9 | /// Represents a record in the schema registry.
10 | ///
11 | class SchemaRegistryEntry
12 | {
13 | ///
14 | /// The schema group to which this belongs.
15 | ///
16 | public string SchemaGroup;
17 |
18 | ///
19 | /// The name of the schema object.
20 | ///
21 | public string ObjectName;
22 |
23 | ///
24 | /// The signature of the object.
25 | ///
26 | public string Signature;
27 |
28 | ///
29 | /// The type of the object.
30 | ///
31 | public SchemaObjectType Type;
32 |
33 | ///
34 | /// The original order in which the object was installed.
35 | ///
36 | public int OriginalOrder;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Certificate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class Certificate : SchemaImpl
11 | {
12 | public Certificate(string name, string sql) : base(name, sql, 2)
13 | {
14 | }
15 |
16 | public override bool Exists(IDbConnection connection)
17 | {
18 | return 0 < connection.ExecuteScalarSql(String.Format(@"
19 | SELECT COUNT (*)
20 | FROM sys.certificates
21 | WHERE name = '{0}'",
22 | Name.Object));
23 | }
24 |
25 | public override bool CanDrop(SchemaInstaller.InstallContext context, IDbConnection connection)
26 | {
27 | return false;
28 | }
29 |
30 | public override void Drop(IDbConnection connection)
31 | {
32 | throw new InvalidOperationException("For your protection, certificates must be dropped manually.");
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.235
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | using System;
12 | using System.Reflection;
13 | using System.Runtime.CompilerServices;
14 | using System.Runtime.InteropServices;
15 |
16 | [assembly: AssemblyTitle("eMoney Insight")]
17 | [assembly: AssemblyCompany("Insight Module")]
18 | [assembly: AssemblyProduct("Insight")]
19 | [assembly: AssemblyCopyright("Copyright © Jon Wagner, used by permission")]
20 | [assembly: ComVisible(false)]
21 | [assembly: CLSCompliant(false)]
22 | [assembly: AssemblyVersion("1.0.12.34")]
23 | [assembly: AssemblyFileVersion("1.0.12.34")]
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Trigger.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Globalization;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Text.RegularExpressions;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class Trigger : SchemaImpl
11 | {
12 | public Trigger(string name, string sql) : base(name, sql, 2)
13 | {
14 | }
15 |
16 | public override bool Exists(System.Data.IDbConnection connection)
17 | {
18 | return 0 < connection.ExecuteScalarSql(String.Format(@"
19 | SELECT COUNT (*)
20 | FROM sys.triggers t
21 | JOIN sys.objects o ON (t.object_id = o.object_id)
22 | JOIN sys.schemas s ON (o.schema_id = s.schema_id)
23 | WHERE s.name = '{0}' AND t.name = '{1}'",
24 | Name.Schema,
25 | Name.Table));
26 | }
27 |
28 | public override void Drop(System.Data.IDbConnection connection)
29 | {
30 | connection.ExecuteSql(String.Format ("DROP TRIGGER {0}", Name.FullName));
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Tests/SingularizerTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Moq;
7 | using NUnit.Framework;
8 |
9 | namespace Insight.Database.Schema.Tests
10 | {
11 | [TestFixture]
12 | public class SingularizerTests
13 | {
14 | private void Test(string plural, string singular)
15 | {
16 | Assert.AreEqual(plural.ToLower(), Singularizer.Singularize(singular).ToLower());
17 | }
18 |
19 | #region Singular Tests
20 | [Test]
21 | public void TestSinglePlural()
22 | {
23 | Test("person", "people");
24 | Test("octopus", "octopi");
25 | Test("deer", "deer");
26 | Test("wolf", "wolves");
27 | Test("wife", "wives");
28 | Test("compass", "compasses");
29 | Test("cliff", "cliffs");
30 | Test("turf", "turfs");
31 | Test("case", "cases");
32 | Test("objective", "objectives");
33 | Test("size", "sizes");
34 | }
35 | #endregion
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/SymmetricKey.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Text.RegularExpressions;
8 |
9 | namespace Insight.Database.Schema.Implementation
10 | {
11 | class SymmetricKey : SchemaImpl
12 | {
13 | public SymmetricKey(string name, string sql) : base(name, sql, 1)
14 | {
15 | }
16 |
17 | public override bool Exists(System.Data.IDbConnection connection)
18 | {
19 | return 0 < connection.ExecuteScalarSql(String.Format(@"
20 | SELECT COUNT (*)
21 | FROM sys.symmetric_keys
22 | WHERE name = '{0}'",
23 | Name.Object));
24 | }
25 |
26 | public override bool CanDrop(SchemaInstaller.InstallContext context, IDbConnection connection)
27 | {
28 | return false;
29 | }
30 |
31 | public override void Drop(System.Data.IDbConnection connection)
32 | {
33 | throw new InvalidOperationException("For your protection, symmetric keys must be dropped manually.");
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/MasterKey.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Text.RegularExpressions;
8 |
9 | namespace Insight.Database.Schema.Implementation
10 | {
11 | class MasterKey : SchemaImpl
12 | {
13 | public MasterKey(string name, string sql) : base(name, sql, 1)
14 | {
15 | }
16 |
17 | public override bool Exists(System.Data.IDbConnection connection)
18 | {
19 | return 0 < connection.ExecuteScalarSql(String.Format(@"
20 | SELECT COUNT (*)
21 | FROM sys.symmetric_keys
22 | WHERE name = '{0}'",
23 | "##MS_DatabaseMasterKey##"));
24 | }
25 |
26 | public override bool CanDrop(SchemaInstaller.InstallContext context, IDbConnection connection)
27 | {
28 | return false;
29 | }
30 |
31 | public override void Drop(System.Data.IDbConnection connection)
32 | {
33 | throw new InvalidOperationException("For your protection, master keys must be dropped manually.");
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Constraint.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class Constraint : SchemaImpl
11 | {
12 | public Constraint(string name, string sql) : base(name, sql, 3)
13 | {
14 | }
15 |
16 | public override bool Exists(IDbConnection connection)
17 | {
18 | return 0 < connection.ExecuteScalarSql(String.Format(@"SELECT COUNT(*)
19 | FROM sys.objects o
20 | JOIN sys.tables t ON (o.parent_object_id = t.object_id)
21 | JOIN sys.schemas s ON (t.schema_id = s.schema_id)
22 | WHERE s.Name = '{0}' AND t.name = '{1}' AND o.name = '{2}'",
23 | Name.Schema,
24 | Name.Table,
25 | Name.Object));
26 | }
27 |
28 | public override void Drop(IDbConnection connection)
29 | {
30 | connection.ExecuteSql(String.Format(@"ALTER TABLE {0} DROP CONSTRAINT {1}",
31 | Name.SchemaQualifiedTable,
32 | Name.ObjectFormatted));
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Schema.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Text.RegularExpressions;
8 |
9 | namespace Insight.Database.Schema.Implementation
10 | {
11 | class Schema : SchemaImpl
12 | {
13 | public Schema(string name, string sql) : base(name, sql, 1)
14 | {
15 | }
16 |
17 | public override bool Exists(System.Data.IDbConnection connection)
18 | {
19 | return 0 < connection.ExecuteScalarSql(String.Format("SELECT COUNT (*) FROM sys.schemas WHERE name = '{0}'", Name.Object));
20 | }
21 |
22 | public override void Drop(System.Data.IDbConnection connection)
23 | {
24 | connection.ExecuteSql(String.Format ("DROP SCHEMA {0}", Name.ObjectFormatted));
25 | }
26 |
27 | public override bool CanDrop(SchemaInstaller.InstallContext context, IDbConnection connection)
28 | {
29 | return 0 == connection.ExecuteScalarSql(String.Format("SELECT COUNT(*) FROM sys.objects o WHERE o.schema_id = SCHEMA_ID('{0}')", Name.Object));
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.1
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Insight.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.235
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | using System;
12 | using System.Reflection;
13 | using System.Runtime.CompilerServices;
14 | using System.Runtime.InteropServices;
15 | using System.Diagnostics.CodeAnalysis;
16 | using System.Resources;
17 |
18 | [assembly: AssemblyTitle("Insight.Database Schema")]
19 | [assembly: AssemblyCompany("Insight")]
20 | [assembly: AssemblyProduct("Insight")]
21 | [assembly: AssemblyCopyright("Copyright © Jon Wagner, used by permission")]
22 | [assembly: ComVisible(false)]
23 | [assembly: CLSCompliant(true)]
24 | [assembly: AssemblyVersion("1.0.0.0")]
25 | [assembly: AssemblyFileVersion("1.0.0.0")]
26 |
27 | [assembly: NeutralResourcesLanguageAttribute("en-US")]
28 |
29 | [assembly: InternalsVisibleTo("Insight.Database.Schema.Tests")]
30 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/MessageType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class MessageType : SchemaImpl
11 | {
12 | public MessageType(string name, string sql) : base(name, sql, 1)
13 | {
14 | }
15 |
16 | public override bool Exists(IDbConnection connection)
17 | {
18 | return 0 < connection.ExecuteScalarSql(String.Format(@"
19 | SELECT COUNT (*)
20 | FROM sys.service_message_types
21 | WHERE name = '{0}'",
22 | Name.Object));
23 | }
24 |
25 | public override bool CanDrop(SchemaInstaller.InstallContext context, IDbConnection connection)
26 | {
27 | return 0 == connection.ExecuteScalarSql(String.Format(@"
28 | SELECT COUNT(*)
29 | FROM sys.service_contract_message_usages c
30 | JOIN sys.service_message_types m ON (c.message_type_id = m.message_type_id)
31 | WHERE m.name = '{0}'",
32 | Name.Object));
33 | }
34 |
35 | public override void Drop(IDbConnection connection)
36 | {
37 | connection.ExecuteSql(String.Format(@"DROP MESSAGE TYPE {0}", Name.ObjectFormatted));
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Login.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Text.RegularExpressions;
8 |
9 | namespace Insight.Database.Schema.Implementation
10 | {
11 | class Login : SchemaImpl
12 | {
13 | public Login(string name, string sql) : base(name, sql, 1)
14 | {
15 | }
16 |
17 | public override bool Exists(IDbConnection connection)
18 | {
19 | return 0 < connection.ExecuteScalarSql(String.Format(@"
20 | SELECT COUNT (*)
21 | FROM sys.server_principals WHERE name = '{0}' AND type <> 'R'",
22 | Name.Object));
23 | }
24 |
25 | public override void Install(IDbConnection connection, IEnumerable objects)
26 | {
27 | if (!Exists(connection))
28 | base.Install(connection, objects);
29 | }
30 |
31 | public override bool CanDrop(SchemaInstaller.InstallContext context, IDbConnection connection)
32 | {
33 | // assume that logins can be used across the server
34 | return false;
35 | }
36 |
37 | public override void Drop(IDbConnection connection)
38 | {
39 | connection.ExecuteSql(String.Format(@"DROP LOGIN {0}", Name.ObjectFormatted));
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Queue.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Text.RegularExpressions;
8 |
9 | namespace Insight.Database.Schema.Implementation
10 | {
11 | class Queue : SchemaImpl
12 | {
13 | public Queue(string name, string sql) : base(name, sql, 2)
14 | {
15 | }
16 |
17 | public override bool Exists(IDbConnection connection)
18 | {
19 | return 0 < connection.ExecuteScalarSql(String.Format(@"
20 | SELECT COUNT (*)
21 | FROM sys.service_queues
22 | WHERE object_id = OBJECT_ID('{0}')",
23 | Name.SchemaQualifiedObject));
24 | }
25 |
26 | public override bool CanDrop(SchemaInstaller.InstallContext context, IDbConnection connection)
27 | {
28 | return 0 == connection.ExecuteScalarSql(String.Format(@"
29 | SELECT COUNT(*)
30 | FROM sys.service_queues q
31 | JOIN sys.service_queue_usages u ON (q.object_id = u.service_queue_id)
32 | WHERE q.object_id = OBJECT_ID('{0}')",
33 | Name.SchemaQualifiedObject));
34 | }
35 |
36 | public override void Drop(IDbConnection connection)
37 | {
38 | connection.ExecuteSql(String.Format(@"DROP QUEUE {0}", Name.SchemaQualifiedObject));
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/PartitionFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Text.RegularExpressions;
8 |
9 | namespace Insight.Database.Schema.Implementation
10 | {
11 | class PartitionFunction : SchemaImpl
12 | {
13 | public PartitionFunction(string name, string sql) : base(name, sql, 1)
14 | {
15 | }
16 |
17 | public override bool Exists(IDbConnection connection)
18 | {
19 | return 0 < connection.ExecuteScalarSql(String.Format(@"
20 | SELECT COUNT (*)
21 | FROM sys.partition_functions
22 | WHERE name = '{0}'",
23 | Name.Object));
24 | }
25 |
26 | public override bool CanModify(SchemaInstaller.InstallContext context, IDbConnection connection)
27 | {
28 | // we can drop a function as long as there are no schemes using it
29 | return connection.ExecuteScalarSql(
30 | "SELECT COUNT(*) FROM sys.partition_functions p JOIN sys.partition_schemes s ON (p.function_id = s.function_id) WHERE p.name = @Name",
31 | new Dictionary() { { "Name", Name.Object } }) == 0;
32 | }
33 |
34 | public override void Drop(IDbConnection connection)
35 | {
36 | connection.ExecuteSql(String.Format(@"DROP PARTITION FUNCTION {0}", Name.ObjectFormatted));
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/UserDefinedType.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Text.RegularExpressions;
8 |
9 | namespace Insight.Database.Schema.Implementation
10 | {
11 | class UserDefinedType : SchemaImpl
12 | {
13 | public UserDefinedType(string name, string sql) : base(name, sql, 2)
14 | {
15 | }
16 |
17 | public override bool Exists(System.Data.IDbConnection connection)
18 | {
19 | return 0 < connection.ExecuteScalarSql(String.Format(@"
20 | SELECT COUNT (*)
21 | FROM sys.types t
22 | JOIN sys.schemas s ON (t.schema_id = s.schema_id)
23 | WHERE s.name = '{0}' AND t.name = '{1}'",
24 | Name.Schema,
25 | Name.Object));
26 | }
27 |
28 | public override bool CanModify(SchemaInstaller.InstallContext context, IDbConnection connection)
29 | {
30 | // we can drop a udt unless it is used in a table
31 | return connection.ExecuteScalarSql(
32 | "SELECT COUNT(*) FROM sys.types t JOIN sys.columns c ON (t.user_type_id = c.user_type_id) WHERE t.Name = @Name",
33 | new Dictionary() { { "Name", Name.Object } }) == 0;
34 | }
35 |
36 | public override void Drop(System.Data.IDbConnection connection)
37 | {
38 | connection.ExecuteSql(String.Format ("DROP TYPE {0}", Name.FullName));
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Sample/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Insight.Database.Schema;
6 | using System.Reflection;
7 | using System.Data.SqlClient;
8 |
9 | namespace Insight.Database.Schema.Sample
10 | {
11 | class Program
12 | {
13 | static void Main(string[] args)
14 | {
15 | SqlConnectionStringBuilder connectionString = new SqlConnectionStringBuilder("Database=.;Initial Catalog=InsightTest;Integrated Security=true");
16 |
17 | SchemaInstaller.CreateDatabase(connectionString.ConnectionString);
18 |
19 | using (SqlConnection connection = new SqlConnection(connectionString.ConnectionString))
20 | {
21 | connection.Open();
22 |
23 | // make sure our database exists
24 | SchemaInstaller installer = new SchemaInstaller(connection);
25 | new SchemaEventConsoleLogger().Attach(installer);
26 |
27 | // load the schema from the embedded resources in this project
28 | SchemaObjectCollection schema = new SchemaObjectCollection();
29 | schema.Load(Assembly.GetExecutingAssembly());
30 |
31 | // install the schema
32 | Console.WriteLine("Installing");
33 | installer.Install("BeerGarten", schema);
34 |
35 | // uninstall the schema
36 | if (args.Length > 0 && args[0].ToUpperInvariant() == "UNINSTALL")
37 | {
38 | Console.WriteLine("Uninstalling");
39 | installer.Uninstall("BeerGarten");
40 | }
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Index.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class Index : SchemaImpl
11 | {
12 | public Index(string name, string sql) : base(name, sql, 3)
13 | {
14 | }
15 |
16 | public override bool Exists(IDbConnection connection)
17 | {
18 | return 0 < connection.ExecuteScalarSql(String.Format(@"SELECT COUNT(*)
19 | FROM sys.indexes i
20 | JOIN sys.objects t ON (i.object_id = t.object_id)
21 | JOIN sys.schemas s ON (t.schema_id = s.schema_id)
22 | WHERE s.Name = '{0}' AND t.name = '{1}' AND i.name = '{2}'",
23 | Name.Schema,
24 | Name.Table,
25 | Name.Object));
26 | }
27 |
28 | public override bool CanModify(SchemaInstaller.InstallContext context, IDbConnection connection)
29 | {
30 | // azure can't drop the clustered index, so we have to warn if we are attempting to modify that
31 | if (context.IsAzure)
32 | {
33 | if (Sql.IndexOf("NONCLUSTERED", StringComparison.OrdinalIgnoreCase) == -1 && Sql.IndexOf("CLUSTERED", StringComparison.OrdinalIgnoreCase) != -1)
34 | return false;
35 | }
36 |
37 | return true;
38 | }
39 |
40 | public override void Drop(IDbConnection connection)
41 | {
42 | connection.ExecuteSql(String.Format(@"DROP INDEX {1} ON {0}",
43 | Name.SchemaQualifiedTable,
44 | Name.ObjectFormatted));
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/PartitionScheme.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Text.RegularExpressions;
8 |
9 | namespace Insight.Database.Schema.Implementation
10 | {
11 | class PartitionScheme : SchemaImpl
12 | {
13 | public PartitionScheme(string name, string sql) : base(name, sql, 1)
14 | {
15 | }
16 |
17 | public override bool Exists(IDbConnection connection)
18 | {
19 | return 0 < connection.ExecuteScalarSql(String.Format(@"
20 | SELECT COUNT (*)
21 | FROM sys.partition_schemes
22 | WHERE name = '{0}'",
23 | Name.Object));
24 | }
25 |
26 | public override bool CanModify(SchemaInstaller.InstallContext context, IDbConnection connection)
27 | {
28 | // we can drop a scheme as long as there are no tables using it
29 | return connection.ExecuteScalarSql(@"SELECT COUNT(*) FROM sys.partition_schemes s
30 | WHERE s.name = @Name AND (
31 | s.data_space_id IN (SELECT data_space_id FROM sys.indexes) OR
32 | s.data_space_id IN (SELECT lob_data_space_id FROM sys.tables) OR
33 | s.data_space_id IN (SELECT filestream_data_space_id FROM sys.tables))
34 | ", new Dictionary() { { "Name", Name.Object } }) == 0;
35 | }
36 |
37 | public override void Drop(IDbConnection connection)
38 | {
39 | connection.ExecuteSql(String.Format(@"DROP PARTITION SCHEME {0}", Name.ObjectFormatted));
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Installer/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Insight.Database.Schema.Installer")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Insight.Database.Schema.Installer")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("c1acb259-f9b3-448c-bdad-f603c76a34da")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Insight.Database.Schema
5 | 2.0.0
6 | Insight.Database.Schema
7 | Jon Wagner
8 | A database installer engine that automatically handles most installation and upgrade issues, such as script ordering, and table and procedure updates. Easier than EntityFramework code migrations.
9 | en-US
10 | http://github.com/jonwagner/Insight.Database.Schema
11 | http://opensource.org/licenses/ms-pl.html
12 | Insight orm sql sqlserver schema installer code migration
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Insight.Database.Schema.Tests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Insight.Database.Schema.Tests")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("312d080e-0720-49c2-a794-0cfceb43ace2")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Sample/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Insight.Database.Schema.Sample")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Insight.Database.Schema.Sample")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("f756c9f5-1f18-4268-8e8f-a3e79794464d")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Verifier/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Insight.Database.Schema.Verifier")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Insight.Database.Schema.Verifier")]
13 | [assembly: AssemblyCopyright("Copyright © 2012")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("47d3bb7c-f81e-4dbd-8d06-9ae28f85f54a")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/PrimaryKey.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class PrimaryKey : SchemaImpl
11 | {
12 | public PrimaryKey(string name, string sql) : base(name, sql, 3)
13 | {
14 | }
15 |
16 | public override bool Exists(IDbConnection connection)
17 | {
18 | return 0 < connection.ExecuteScalarSql(String.Format(@"SELECT COUNT(*)
19 | FROM sys.indexes i
20 | JOIN sys.tables t ON (i.object_id = t.object_id)
21 | JOIN sys.schemas s ON (t.schema_id = s.schema_id)
22 | WHERE s.Name = '{0}' AND t.name = '{1}' AND i.name = '{2}'",
23 | Name.Schema,
24 | Name.Table,
25 | Name.Object));
26 | }
27 |
28 | public override bool CanDrop(SchemaInstaller.InstallContext context, IDbConnection connection)
29 | {
30 | // azure can't drop the clustered index, so we have to warn if we are attempting to modify that
31 | if (context.IsAzure)
32 | {
33 | if (Sql.IndexOf("NONCLUSTERED", StringComparison.OrdinalIgnoreCase) == -1 && Sql.IndexOf("CLUSTERED", StringComparison.OrdinalIgnoreCase) != -1)
34 | return false;
35 | }
36 |
37 | return 0 == connection.ExecuteScalarSql(String.Format(@"SELECT COUNT(*)
38 | FROM sys.xml_indexes i
39 | WHERE i.object_id = OBJECT_ID('{0}')",
40 | Name.SchemaQualifiedTable));
41 | }
42 |
43 | public override void Drop(IDbConnection connection)
44 | {
45 | connection.ExecuteSql(String.Format(@"ALTER TABLE {0} DROP CONSTRAINT {1}",
46 | Name.SchemaQualifiedTable,
47 | Name.ObjectFormatted));
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Default.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class Default : SchemaImpl
11 | {
12 | public Default(string name, string sql) : base(name, sql, 3)
13 | {
14 | }
15 |
16 | public override bool Exists(IDbConnection connection)
17 | {
18 | return 0 < connection.ExecuteScalarSql(String.Format(@"SELECT COUNT(*)
19 | FROM sys.default_constraints d
20 | JOIN sys.schemas s ON (d.schema_id = s.schema_id)
21 | JOIN sys.objects o ON (d.parent_object_id = o.object_id)
22 | JOIN sys.columns c ON (c.object_id = o.object_id AND c.column_id = d.parent_column_id)
23 | WHERE s.Name = '{0}' AND o.name = '{1}' AND c.name = '{2}'",
24 | Name.Schema,
25 | Name.Table,
26 | Name.Object));
27 | }
28 |
29 | public override void Drop(IDbConnection connection)
30 | {
31 | connection.ExecuteSql(String.Format(@"
32 | -- ALTER TABLE DROP DEFAULT ON COLUMN
33 | DECLARE @Name[nvarchar](256)
34 | SELECT @Name = d.name
35 | FROM sys.default_constraints d
36 | JOIN sys.schemas s ON (d.schema_id = s.schema_id)
37 | JOIN sys.objects o ON (d.parent_object_id = o.object_id)
38 | JOIN sys.columns c ON (c.object_id = o.object_id AND c.column_id = d.parent_column_id)
39 | WHERE s.name = '{0}' AND o.name = '{1}' AND c.name = '{2}'
40 | DECLARE @sql[nvarchar](MAX) = 'ALTER TABLE {3} DROP CONSTRAINT [' + @Name + ']'
41 | EXEC sp_executesql @sql
42 | ",
43 | Name.Schema,
44 | Name.Table,
45 | Name.Object,
46 | Name.SchemaQualifiedTable));
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/AutoProc.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace Insight.Database.Schema.Implementation
9 | {
10 | class AutoProc : SchemaImpl
11 | {
12 | public AutoProc(string name, string sql) : base(name, sql, 2)
13 | {
14 | }
15 |
16 | public override void Install(IDbConnection connection, IEnumerable objects)
17 | {
18 | // for auto-procs, convert the comment into a list of stored procedures
19 | var sql = new Insight.Database.Schema.AutoProc(Name.Original, new SqlColumnDefinitionProvider(connection), objects).Sql;
20 | if (sql.Length == 0)
21 | return;
22 |
23 | foreach (string s in _goSplit.Split(sql).Where(piece => !String.IsNullOrWhiteSpace(piece)))
24 | connection.ExecuteSql(s);
25 | }
26 |
27 | public override bool Exists(IDbConnection connection)
28 | {
29 | return new Insight.Database.Schema.AutoProc(Name.Original, null, null).GetProcs().All(tuple =>
30 | {
31 | switch (tuple.Item1)
32 | {
33 | case Insight.Database.Schema.AutoProc.ProcTypes.Table:
34 | case Insight.Database.Schema.AutoProc.ProcTypes.IdTable:
35 | return new UserDefinedType(tuple.Item2, null).Exists(connection);
36 |
37 | default:
38 | return new StoredProcedure(tuple.Item2, null).Exists(connection);
39 | }
40 | });
41 | }
42 |
43 | public override void Drop(IDbConnection connection)
44 | {
45 | var sql = new Insight.Database.Schema.AutoProc(Name.Original, new SqlColumnDefinitionProvider(connection), null).DropSql;
46 |
47 | foreach (string s in _goSplit.Split(sql).Where(piece => !String.IsNullOrWhiteSpace(piece)))
48 | connection.ExecuteSql(s);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/packages/Moq.4.0.10827/License.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2007. Clarius Consulting, Manas Technology Solutions, InSTEDD
2 | http://code.google.com/p/moq/
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms,
6 | with or without modification, are permitted provided
7 | that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the
10 | above copyright notice, this list of conditions and
11 | the following disclaimer.
12 |
13 | * Redistributions in binary form must reproduce
14 | the above copyright notice, this list of conditions
15 | and the following disclaimer in the documentation
16 | and/or other materials provided with the distribution.
17 |
18 | * Neither the name of Clarius Consulting, Manas Technology Solutions or InSTEDD nor the
19 | names of its contributors may be used to endorse
20 | or promote products derived from this software
21 | without specific prior written permission.
22 |
23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
24 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
28 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 | SUCH DAMAGE.
37 |
38 | [This is the BSD license, see
39 | http://www.opensource.org/licenses/bsd-license.php]
--------------------------------------------------------------------------------
/Insight.Database.Schema/ColumnDefinition.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Insight.Database.Schema
7 | {
8 | ///
9 | /// Represents a column in the database.
10 | ///
11 | /// This class is framework code and is not intended to be used by external code.
12 | public class ColumnDefinition
13 | {
14 | ///
15 | /// The name of the column.
16 | ///
17 | public string Name { get; set; }
18 |
19 | ///
20 | /// The type of the column, including the precision/size.
21 | ///
22 | public string SqlType { get; set; }
23 |
24 | ///
25 | /// True if the column is a key field.
26 | ///
27 | public bool IsKey { get; set; }
28 |
29 | ///
30 | /// True if the column is not updatable.
31 | ///
32 | public bool IsReadOnly { get; set; }
33 |
34 | ///
35 | /// True if the column is an identity.
36 | ///
37 | public bool IsIdentity { get; set; }
38 |
39 | ///
40 | /// True if the column is a rowversion.
41 | ///
42 | public bool IsRowVersion { get; set; }
43 |
44 | ///
45 | /// True if the column is nullable on update.
46 | ///
47 | public bool IsUpdateNullable { get; set; }
48 |
49 | ///
50 | /// True if the column has a default
51 | ///
52 | public bool HasDefault { get; set; }
53 |
54 | ///
55 | /// The name of the column formatted properly for use as a SQL column.
56 | ///
57 | public string ColumnName { get { return SqlParser.FormatSqlName(Name); } }
58 |
59 | ///
60 | /// The name of the column formatted properly for use as a SQL parameter.
61 | ///
62 | public string ParameterName { get { return "@" + Name; } }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/runFile.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/SchemaEventArgs.cs:
--------------------------------------------------------------------------------
1 | #region Using directives
2 |
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 |
7 | #endregion
8 |
9 | namespace Insight.Database.Schema
10 | {
11 | ///
12 | /// Arguments for a Schema change event
13 | ///
14 | public class SchemaEventArgs : EventArgs
15 | {
16 | ///
17 | /// The type of Schema event
18 | ///
19 | /// The type of Schema event
20 | public SchemaEventType EventType { get { return _eventType; } }
21 | private SchemaEventType _eventType;
22 |
23 | ///
24 | /// The name of the schema object
25 | ///
26 | /// The type of Schema event
27 | public string ObjectName { get { return _objectName; } }
28 | private string _objectName;
29 |
30 | ///
31 | /// The schema object being updated.
32 | ///
33 | /// The type of Schema event
34 | /// This is null for a drop object event
35 | public SchemaObject SchemaObject { get { return _schemaObject; } }
36 | private SchemaObject _schemaObject;
37 |
38 | ///
39 | /// In the case of a DropFailed event, the exception that was thrown.
40 | ///
41 | /// The exception that was thrown.
42 | public Exception Exception { get; internal set; }
43 |
44 | internal SchemaEventArgs (SchemaEventType eventType, string objectName)
45 | {
46 | _eventType = eventType;
47 | _objectName = objectName;
48 | }
49 |
50 | internal SchemaEventArgs (SchemaEventType eventType, SchemaObject schemaObject)
51 | {
52 | _eventType = eventType;
53 | _schemaObject = schemaObject;
54 | _objectName = schemaObject.Name;
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/LambdaComparer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Insight.Database.Schema
8 | {
9 | ///
10 | /// Implements IEqualityComparer with a lambda expression.
11 | ///
12 | /// The type to compare.
13 | class LambdaComparer : IEqualityComparer
14 | {
15 | private readonly Func _expression;
16 |
17 | public LambdaComparer(Func lambda)
18 | {
19 | _expression = lambda;
20 | }
21 |
22 | public bool Equals(T x, T y)
23 | {
24 | return _expression(x, y);
25 | }
26 |
27 | public int GetHashCode(T obj)
28 | {
29 | return 0;
30 | }
31 | }
32 |
33 | static class LambdaComparerExtensions
34 | {
35 | ///
36 | /// Returns all items in the first collection except the ones in the second collection that match the lambda condition.
37 | ///
38 | /// The type.
39 | /// The first list.
40 | /// The second list.
41 | /// The filter expression.
42 | /// The filtered list.
43 | public static IEnumerable Except(this IEnumerable listA, IEnumerable listB, Func lambda)
44 | {
45 | return listA.Except(listB, new LambdaComparer(lambda));
46 | }
47 |
48 | ///
49 | /// Returns all items in the first collection that intersect the ones in the second collection that match the lambda condition.
50 | ///
51 | /// The type.
52 | /// The first list.
53 | /// The second list.
54 | /// The filter expression.
55 | /// The filtered list.
56 | public static IEnumerable Intersect(this IEnumerable listA, IEnumerable listB, Func lambda)
57 | {
58 | return listA.Intersect(listB, new LambdaComparer(lambda));
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/nunit-console.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
22 |
24 |
25 |
26 |
29 |
31 |
32 |
33 |
34 |
37 |
39 |
40 |
41 |
42 |
45 |
47 |
48 |
49 |
50 |
53 |
55 |
56 |
57 |
58 |
61 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/nunit-agent.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
22 |
24 |
25 |
26 |
29 |
31 |
32 |
33 |
34 |
37 |
39 |
40 |
41 |
42 |
45 |
47 |
48 |
49 |
50 |
53 |
55 |
56 |
57 |
58 |
61 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/nunit-console-x86.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
22 |
24 |
25 |
26 |
29 |
31 |
32 |
33 |
34 |
37 |
39 |
40 |
41 |
42 |
45 |
47 |
48 |
49 |
50 |
53 |
55 |
56 |
57 |
58 |
61 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/nunit-agent-x86.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
22 |
24 |
25 |
26 |
29 |
31 |
32 |
33 |
34 |
37 |
39 |
40 |
41 |
42 |
45 |
47 |
48 |
49 |
50 |
53 |
55 |
56 |
57 |
58 |
61 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Tests/DatabaseTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using NUnit.Framework;
7 | using System.Transactions;
8 | using System.Configuration;
9 | using System.Data.SqlClient;
10 |
11 | namespace Insight.Database.Schema.Tests
12 | {
13 | ///
14 | /// Test create/drop database.
15 | ///
16 | [TestFixture]
17 | public class DatabaseTests : BaseInstallerTest
18 | {
19 | #region DatabaseExists Tests
20 | [Test]
21 | public void DatabaseExistsReturnsTrueForMaster([ValueSource("ConnectionStrings")] string connectionString)
22 | {
23 | SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectionString);
24 | builder.InitialCatalog = "master";
25 |
26 | Assert.True(SchemaInstaller.DatabaseExists(builder.ConnectionString));
27 | }
28 |
29 | [Test]
30 | public void DatabaseExistsReturnsTrueForInvalid([ValueSource("ConnectionStrings")] string connectionString)
31 | {
32 | SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectionString);
33 | builder.InitialCatalog = "fhjasjkl";
34 |
35 | Assert.False(SchemaInstaller.DatabaseExists(builder.ConnectionString));
36 | }
37 | #endregion
38 |
39 | #region Create Tests
40 | [Test]
41 | public void TestCreateDatabase([ValueSource("ConnectionStrings")] string connectionString)
42 | {
43 | TestWithDrop(connectionString, () =>
44 | {
45 | // drop the database if it already exists
46 | if (SchemaInstaller.DatabaseExists(connectionString))
47 | SchemaInstaller.DropDatabase(connectionString);
48 |
49 | // create the database
50 | Assert.True(SchemaInstaller.CreateDatabase(connectionString));
51 |
52 | // make sure the database exises
53 | Assert.True(SchemaInstaller.DatabaseExists(connectionString));
54 |
55 | // create the database again, it should return false
56 | Assert.False(SchemaInstaller.CreateDatabase(connectionString));
57 | });
58 | }
59 | #endregion
60 |
61 | #region Drop Tests
62 | [Test]
63 | public void TestDropDatabase([ValueSource("ConnectionStrings")] string connectionString)
64 | {
65 | TestWithDrop(connectionString, () =>
66 | {
67 | // create the database if it doesn't exist
68 | if (!SchemaInstaller.DatabaseExists(connectionString))
69 | SchemaInstaller.CreateDatabase(connectionString);
70 |
71 | // drop the database
72 | Assert.True(SchemaInstaller.DropDatabase(connectionString));
73 |
74 | // make sure the database doesn't exist
75 | Assert.False(SchemaInstaller.DatabaseExists(connectionString));
76 |
77 | // drop the database again, it should return false
78 | Assert.False(SchemaInstaller.DropDatabase(connectionString));
79 | });
80 | }
81 | #endregion
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Tests/BaseInstallerTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Configuration;
5 | using System.Data;
6 | using System.Data.Common;
7 | using System.Data.SqlClient;
8 | using System.Linq;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 | using System.Transactions;
12 |
13 | namespace Insight.Database.Schema.Tests
14 | {
15 | ///
16 | /// Base test case support classes
17 | ///
18 | public class BaseInstallerTest
19 | {
20 | ///
21 | /// The list of connection strings that will be used to run tests.
22 | ///
23 | protected IEnumerable ConnectionStrings { get { return _connectionStrings; } }
24 | private static readonly ReadOnlyCollection _connectionStrings = new ReadOnlyCollection(
25 | ConfigurationManager.ConnectionStrings.OfType()
26 | .Where(c => c.Name.Contains("Test"))
27 | .Select(c => c.ConnectionString)
28 | .ToList());
29 |
30 | ///
31 | /// The schema group to use for the test cases.
32 | ///
33 | protected static string TestSchemaGroup = "test";
34 |
35 | ///
36 | /// Run a test and clean up the databases when complete.
37 | ///
38 | /// The connection string for the database.
39 | /// The test to run.
40 | protected static void TestWithDrop(string connectionString, Action action)
41 | {
42 | try
43 | {
44 | action();
45 | }
46 | finally
47 | {
48 | SchemaInstaller.DropDatabase(connectionString);
49 | }
50 | }
51 |
52 | ///
53 | /// Run a test and clean up the databases when complete.
54 | ///
55 | /// The connection string for the database.
56 | /// The test to run.
57 | internal static void TestWithRollback(string connectionString, Action action)
58 | {
59 | // make sure the database exists
60 | if (!SchemaInstaller.DatabaseExists(connectionString))
61 | SchemaInstaller.CreateDatabase(connectionString);
62 |
63 | // do all of the work in a transaction so we can clean up our changes
64 | using (TransactionScope transaction = new TransactionScope())
65 | using (SqlConnection connection = new SqlConnection(connectionString))
66 | using (RecordingDbConnection recordingConnection = new RecordingDbConnection(connection))
67 | {
68 | recordingConnection.Open();
69 | try
70 | {
71 | action(recordingConnection);
72 | }
73 | finally
74 | {
75 | Console.WriteLine("== BEGIN SCRIPT ============================");
76 | Console.WriteLine(recordingConnection.ScriptLog.ToString());
77 | Console.WriteLine("== END SCRIPT ============================");
78 | }
79 | }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Installer/Insight.Database.Schema.Installer.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {5873421C-3B4C-478C-84F9-5D64A60E8C5C}
8 | Exe
9 | Properties
10 | Insight.Database.Schema.Installer
11 | InsightInstaller
12 | v4.5
13 | 512
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | {fbd1c65f-9054-42c7-ba0e-48a922c4c747}
53 | Insight.Database.Schema
54 |
55 |
56 |
57 |
64 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/SchemaException.cs:
--------------------------------------------------------------------------------
1 | #region Using directives
2 |
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Runtime.Serialization;
6 | using System.Text;
7 | using System.Globalization;
8 |
9 | #endregion
10 |
11 | namespace Insight.Database.Schema
12 | {
13 | #region SchemaParsingException Class
14 | ///
15 | /// Represents errors in parsing a SQL script
16 | ///
17 | [Serializable]
18 | public class SchemaException : Exception
19 | {
20 | ///
21 | /// Construct a SchemaException
22 | ///
23 | public SchemaException ()
24 | {
25 | }
26 |
27 | ///
28 | /// Construct a SchemaException with a message
29 | ///
30 | /// The exception error message
31 | public SchemaException (string message) : base (message)
32 | {
33 | }
34 |
35 | ///
36 | /// Construct a SchemaException with a message
37 | ///
38 | /// The exception error message
39 | /// The base exception
40 | public SchemaException (string message, Exception innerException) : base (message, innerException)
41 | {
42 | }
43 |
44 | ///
45 | /// Construct a SchemaException with a message and the error sql
46 | ///
47 | /// The exception error message
48 | /// The sql script that could not be parsed
49 | public SchemaException(string message, string sql)
50 | : base(String.Format(CultureInfo.InvariantCulture, message, sql))
51 | {
52 | _sql = sql;
53 | }
54 |
55 | ///
56 | /// Construct a SchemaException with a message and the error sql
57 | ///
58 | /// Serialization information
59 | /// Serialization context
60 | protected SchemaException(SerializationInfo info, StreamingContext context)
61 | : base(info, context)
62 | {
63 | }
64 |
65 | ///
66 | /// The SQL script that caused the error
67 | ///
68 | ///
69 | public string Sql { get { return _sql; } }
70 | private string _sql;
71 |
72 | ///
73 | /// Implements the serialization of the Exception data.
74 | ///
75 | /// The information object to append to.
76 | /// The streaming context to write to.
77 | public override void GetObjectData(SerializationInfo info, StreamingContext context)
78 | {
79 | base.GetObjectData(info, context);
80 |
81 | // add the SQL that was being parsed
82 | info.AddValue("_sql", _sql);
83 | }
84 | }
85 | #endregion
86 | }
87 |
--------------------------------------------------------------------------------
/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.1
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Insight.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Insight.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/SchemaParsingException.cs:
--------------------------------------------------------------------------------
1 | #region Using directives
2 |
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Runtime.Serialization;
6 | using System.Text;
7 | using System.Globalization;
8 |
9 | #endregion
10 |
11 | namespace Insight.Database.Schema
12 | {
13 | #region SchemaParsingException Class
14 | ///
15 | /// Represents errors in parsing a SQL script
16 | ///
17 | [Serializable]
18 | public class SchemaParsingException : Exception
19 | {
20 | ///
21 | /// Construct a SchemaParsingException
22 | ///
23 | public SchemaParsingException ()
24 | {
25 | }
26 |
27 | ///
28 | /// Construct a SchemaParsingException with a message
29 | ///
30 | /// The exception error message
31 | public SchemaParsingException (string message) : base (message)
32 | {
33 | }
34 |
35 | ///
36 | /// Construct a SchemaParsingException with a message
37 | ///
38 | /// The exception error message
39 | /// The base exception
40 | public SchemaParsingException (string message, Exception innerException) : base (message, innerException)
41 | {
42 | }
43 |
44 | ///
45 | /// Construct a SchemaParsingException with a message and the error sql
46 | ///
47 | /// The exception error message
48 | /// The sql script that could not be parsed
49 | public SchemaParsingException(string message, string sql)
50 | : base(String.Format(CultureInfo.InvariantCulture, message, sql))
51 | {
52 | _sql = sql;
53 | }
54 |
55 | ///
56 | /// Construct a SchemaParsingException with a message and the error sql
57 | ///
58 | /// Serialization information
59 | /// Serialization context
60 | protected SchemaParsingException (SerializationInfo info, StreamingContext context) : base (info, context)
61 | {
62 | }
63 |
64 | ///
65 | /// The SQL script that caused the error
66 | ///
67 | ///
68 | public string Sql { get { return _sql; } }
69 | private string _sql;
70 |
71 | ///
72 | /// Implements the serialization of the Exception data.
73 | ///
74 | /// The information object to append to.
75 | /// The streaming context to write to.
76 | public override void GetObjectData(SerializationInfo info, StreamingContext context)
77 | {
78 | base.GetObjectData(info, context);
79 |
80 | // add the SQL that was being parsed
81 | info.AddValue("_sql", _sql);
82 | }
83 | }
84 | #endregion
85 | }
86 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/pnunit-agent.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
30 |
32 |
33 |
34 |
37 |
39 |
40 |
41 |
42 |
45 |
47 |
48 |
49 |
50 |
53 |
55 |
56 |
57 |
58 |
61 |
63 |
64 |
65 |
66 |
69 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/pnunit-launcher.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
30 |
32 |
33 |
34 |
37 |
39 |
40 |
41 |
42 |
45 |
47 |
48 |
49 |
50 |
53 |
55 |
56 |
57 |
58 |
61 |
63 |
64 |
65 |
66 |
69 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/.hgtags:
--------------------------------------------------------------------------------
1 | 5e4ddcbfbd2b78a560b84f5b30050f2a9121dd88 Version 1.0.1
2 | 4031ecdd1c02d5bc9e5ae359992dd69a4fb04769 Version 1.0.2
3 | ecfad38b4cb6b4f720546fdafc2b4d858af43195 Version 1.0.3
4 | b111e60e44f736a5f7cfab0c2c6001cdee96da90 Version 1.0.4
5 | 249b78592d69d3d4bf070857807ff8c1b3e2cf62 Version 1.0.5
6 | b4d4eb5d3fe91f85df9c8d8b008bff40afd0aeec Version 1.0.6
7 | c83e1e89bdf810e269436a0290e38b6a0594f279 Version 1.0.7
8 | 7a9cd869b1b2ddd672bc33a9b5a76ae2e3c8bfd8 Version 1.0.8
9 | e41312b456e7ec8b5bc6fd8c6d77a35e8783766f Version 1.0.9
10 | d13f0a41b69846edca2b1f37b729049df9f2264b Version 1.0.10
11 | b5ed27bcd0705acdf57af68a7073279b4dc5b3c1 Version 1.0.11
12 | 0526eb76242696298e9ee4140ff9eea930856772 Version 1.0.12
13 | c8e7af9dd7e29e12adcd0f0a32d744dc2a6e5f38 Version 1.0.13
14 | a55d3a5abbead8b6a222daad1921252da8222bec Version 1.0.14
15 | 821c59d83416b824038f8f0312e28f91afeeb74a Version 1.0.15
16 | cfc4ae0885260dfe00be704de22bb2b1c7f1fb3f Version 1.0.16
17 | dfea6a3b42be9fb52d7de7d0bda731d2f4137a73 Version 1.0.17
18 | 44b192ae01c12cc9c309504c72a0cab8f1227faf Version 1.0.18
19 | ae730615c5a53cbb98908f598c25ee4073458d10 Version 1.0.19
20 | 973f89697b7653236ba78dbbde8be0ce76445902 Version 1.0.20
21 | 5698a3a9f7609806b1925a18da81824aa3986b04 Version 1.0.21
22 | a65e3d0066462ae0fc858a53195c5a65b14edc27 Version 1.0.22
23 | 8d98491b2f793730669d8971771daa3c43c5e582 Version 1.0.23
24 | 8b684124731be34a8499e575fe23d522985ebce4 Version 1.0.24
25 | 545bdf79747805133639757cba896b0e33142833 Version 1.0.25
26 | 79e0d34d8d0e70843edb8396e9e130fb6db6a9c9 Version 1.0.26
27 | dee91b2c2c5866a12d3c926984430903acaf9080 Version 1.0.27
28 | 303a7b6ad3eebfd5b486b6cbbf7b3e6dfd94ec85 Version 1.0.28
29 | c5d5721657b812666dd875aaa9d2ae56f90a43ff Version 1.0.29
30 | 3dbf693e4d056fbe7ba8d6c129ed4d357ba65878 Version 1.0.30
31 | 894fca4c726217d2ed7f977b1acd9b78a8f55fa7 Version 1.0.31
32 | 192d936e8baf8d0a9d5003bc728236e59a4f9342 Version 1.0.32
33 | a843eee6ff188897dc986e53326ea043488f472d Version 1.0.33
34 | d6d50fd5174010533232bcdbeece355cd50626d7 Version 1.0.35
35 | 1913031ca15d7138611af06a506abe12bee09214 Version 1.0.36
36 | 70182d27f26da78e07180864a6bffc864c8dd5ef Version 1.0.37
37 | eec9b7a2237049340aeff9cc7bc289a18e2c3e06 Version 1.0.38
38 | 7675ce28cb3bc9f1e2582d1b3662de49c0fc2d48 Version 1.0.39
39 | 213b9ec5fd91c2383140c4b64ab9153136c839ad Version 1.0.40
40 | 3851adb2c0f52ccf40e40e974d797fe5a69b8bb5 Version 1.0.41
41 | bae702c80195555e8284a150d0c7d66606331799 Version 1.0.42
42 | 8b41b58cda9172fc4219ec0ef6d8261e1c1208a6 Version 1.0.43
43 | 70a69b1fce4b8b91aa490018fbb180b61ff0e52b Version 1.0.44
44 | ab6f5fc8a811b0dbae74936264cea19e59b7847f Version 1.0.45
45 | 2d0297caf946905400cc1e124b86a35d7eb49efa Version 1.0.46
46 | 26620351f1e89ace8378da67da946495c0249f34 Version 1.0.47
47 | 8c1e7b850f46da3cb81d784d67ba0b6c5de2bbbc Version 1.0.48
48 | d5ef0f4380c409776397699f8b0b351b91611bad Version 1.0.49
49 | dd129be56543fd83a795a461d9ee1ef78a350423 Version 1.0.50
50 | bc5490b578b131a1aa066cd1afa766031f45d044 Version 1.0.51
51 | 812358c282b49b125feab7b0ce28c789d93067d4 Version 1.0.52
52 | cb26259f8e436dbc73962dd53ec232d57eae1383 Version 1.0.53
53 | 8fde7d2b4756511c8d394657362bd0c0349ef2e8 Version 1.0.54
54 | d2c4e22631b01fc03582c7e3e2565fadca5ca43f Version 1.0.55
55 | 6be85245f52c318ef6d7ca638284c9b32a2ec108 Version 1.0.56
56 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/ConnectionExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Data.Common;
5 | using System.Dynamic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Insight.Database.Schema
11 | {
12 | internal static class ConnectionExtensions
13 | {
14 | public static bool IsAzure(this string connectionString)
15 | {
16 | return connectionString.Contains("windows.net");
17 | }
18 | public static bool IsAzure(this IDbConnection connection)
19 | {
20 | return connection.ConnectionString.IsAzure();
21 | }
22 |
23 | public static DbConnection Unwrap(this DbConnection connection)
24 | {
25 | RecordingDbConnection recording = connection as RecordingDbConnection;
26 | if (recording != null)
27 | return recording.InnerConnection.Unwrap();
28 |
29 | return connection;
30 | }
31 |
32 | public static int ExecuteSql(this IDbConnection connection, string sql)
33 | {
34 | var cmd = connection.CreateCommand();
35 | cmd.CommandText = sql;
36 | cmd.CommandType = CommandType.Text;
37 |
38 | return cmd.ExecuteNonQuery();
39 | }
40 |
41 | public static T ExecuteScalarSql(this IDbConnection connection, string sql, IDictionary parameters = null)
42 | {
43 | var cmd = connection.CreateCommand();
44 | cmd.CommandText = sql;
45 | cmd.CommandType = CommandType.Text;
46 |
47 | if (parameters != null)
48 | CreateParameters(parameters, cmd);
49 |
50 | return (T)cmd.ExecuteScalar();
51 | }
52 |
53 | public static IDataReader GetReaderSql(this IDbConnection connection, string sql)
54 | {
55 | var cmd = connection.CreateCommand();
56 | cmd.CommandText = sql;
57 | cmd.CommandType = CommandType.Text;
58 |
59 | return cmd.ExecuteReader();
60 | }
61 |
62 | public static IList QuerySql(this IDbConnection connection, string sql, IDictionary parameters)
63 | {
64 | var cmd = connection.CreateCommand();
65 | cmd.CommandText = sql;
66 | cmd.CommandType = CommandType.Text;
67 |
68 | CreateParameters(parameters, cmd);
69 |
70 | var results = new List();
71 |
72 | using (var reader = cmd.ExecuteReader())
73 | {
74 | while (reader.Read())
75 | {
76 | var expando = new FastExpando();
77 | var dict = (IDictionary)expando;
78 | for (int i = 0; i < reader.FieldCount; i++)
79 | {
80 | object value = reader.GetValue(i);
81 | if (value == DBNull.Value)
82 | value = null;
83 | dict[reader.GetName(i)] = value;
84 | }
85 | results.Add(expando);
86 | }
87 | }
88 |
89 | return results;
90 | }
91 |
92 | private static void CreateParameters(IDictionary parameters, IDbCommand cmd)
93 | {
94 | if (parameters == null)
95 | return;
96 |
97 | foreach (var pair in parameters)
98 | {
99 | var p = cmd.CreateParameter();
100 | p.ParameterName = "@" + pair.Key;
101 | if (pair.Value != null)
102 | p.Value = pair.Value;
103 | else
104 | p.Value = DBNull.Value;
105 | cmd.Parameters.Add(p);
106 | }
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Singularizer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Text.RegularExpressions;
6 |
7 | namespace Insight.Database.Schema
8 | {
9 | ///
10 | /// Converts plural table names to singular function names.
11 | ///
12 | class Singularizer
13 | {
14 | ///
15 | /// Words that should stay the same.
16 | ///
17 | private static readonly IList Unpluralizables =
18 | new List
19 | {
20 | "EQUIPMENT",
21 | "INFORMATION",
22 | "RICE",
23 | "MONEY",
24 | "SPECIES",
25 | "SERIES",
26 | "FISH",
27 | "SHEEP",
28 | "DEER"
29 | };
30 |
31 | ///
32 | /// Mappings from plural to single.
33 | ///
34 | private static readonly IDictionary Singularizations =
35 | new Dictionary
36 | {
37 | // Start with the rarest cases, and move to the most common
38 | {"people", "Person"},
39 | {"oxen", "Ox"},
40 | {"children", "Child"},
41 | {"feet", "Foot"},
42 | {"teeth", "Tooth"},
43 | {"geese", "Goose"},
44 | // and now the more standard rules.
45 | {"wives?", "wife"},
46 | {"(.*)lves?", "$1lf"},
47 | // ie, wolf, wife
48 | {"(.*)men$", "$1man"},
49 | {"(.+[aeiou])ys$", "$1y"},
50 | {"(.+[^aeiou])ies$", "$1y"},
51 | {"(.+z)zes$", "$1"},
52 | {"(.+)zes$", "$1ze"},
53 | {"([m|l])ice$", "$1ouse"},
54 | {"matrices", @"Matrix"},
55 | {"indices", @"Index"},
56 | {"(.+[^aeiou])ices$","$1ice"},
57 | {"(.*)ices", @"$1ex"},
58 | // ie, matrix, index
59 | {"(octop|vir)i$", "$1us"},
60 | {"(.+(ase))s$", @"$1"},
61 | {"(.+(s|x|sh|ch))es$", @"$1"},
62 | {"(.+)s", @"$1"}
63 | };
64 |
65 | ///
66 | /// Converts a word to its plural form or keeps it the same.
67 | ///
68 | /// The word to singularize.
69 | /// The singular form of the word.
70 | public static string Singularize(string word)
71 | {
72 | if (Unpluralizables.Contains(word.ToUpperInvariant()))
73 | {
74 | return word;
75 | }
76 |
77 | foreach (var singularization in Singularizations)
78 | {
79 | if (Regex.IsMatch(word, singularization.Key, RegexOptions.IgnoreCase))
80 | {
81 | return Regex.Replace(word, singularization.Key, singularization.Value, RegexOptions.IgnoreCase);
82 | }
83 | }
84 |
85 | return word;
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/nunit.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
36 |
38 |
39 |
40 |
43 |
45 |
46 |
47 |
48 |
51 |
53 |
54 |
55 |
56 |
59 |
61 |
62 |
63 |
64 |
67 |
69 |
70 |
71 |
72 |
75 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/nunit-x86.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
36 |
38 |
39 |
40 |
43 |
45 |
46 |
47 |
48 |
51 |
53 |
54 |
55 |
56 |
59 |
61 |
62 |
63 |
64 |
67 |
69 |
70 |
71 |
72 |
75 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/SqlName.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Text.RegularExpressions;
6 |
7 | namespace Insight.Database.Schema
8 | {
9 | public class SqlName : IEquatable
10 | {
11 | public string Original { get; private set; }
12 | public string Schema { get; private set; }
13 | public string Table { get; private set; }
14 | public string Object { get; private set; }
15 |
16 | public string SchemaFormatted { get { return SqlParser.FormatSqlName(Schema); } }
17 | public string TableFormatted { get { return SqlParser.FormatSqlName(Table); } }
18 | public string ObjectFormatted { get { return SqlParser.FormatSqlName(Object); } }
19 |
20 | public string SchemaQualifiedTable
21 | {
22 | get
23 | {
24 | if (!String.IsNullOrWhiteSpace(Schema))
25 | return SchemaFormatted + "." + TableFormatted;
26 | else
27 | return TableFormatted;
28 | }
29 | }
30 |
31 | public string SchemaQualifiedObject
32 | {
33 | get
34 | {
35 | if (!String.IsNullOrWhiteSpace(Schema))
36 | return SchemaFormatted + "." + ObjectFormatted;
37 | else
38 | return ObjectFormatted;
39 | }
40 | }
41 |
42 | public string FullName
43 | {
44 | get
45 | {
46 | string name = SchemaQualifiedTable;
47 | if (Table != Object)
48 | name += "." + ObjectFormatted;
49 |
50 | return name ?? Original;
51 | }
52 | }
53 |
54 | public SqlName(string fullName, int expectedParts)
55 | {
56 | Original = fullName;
57 |
58 | var split = SplitSqlName(fullName);
59 | if (split.Length < expectedParts)
60 | {
61 | fullName = "[dbo]." + fullName;
62 | split = SplitSqlName(fullName);
63 | }
64 |
65 | // in some special cases (autoproc, permissions), we just need the original
66 | if (split.Length > expectedParts)
67 | return;
68 |
69 | if (split.Length == 1)
70 | {
71 | Table = split[0];
72 | Object = split[0];
73 | }
74 | else if (split.Length == 2)
75 | {
76 | Schema = split[0];
77 | Table = split[1];
78 | Object = split[1];
79 | }
80 | else if (split.Length == 3)
81 | {
82 | Schema = split[0];
83 | Table = split[1];
84 | Object = split[2];
85 | }
86 |
87 | if (split.Length > 1 && String.IsNullOrWhiteSpace(Schema))
88 | Schema = "dbo";
89 |
90 | Schema = SqlParser.UnformatSqlName(Schema);
91 | Table = SqlParser.UnformatSqlName(Table);
92 | Object = SqlParser.UnformatSqlName(Object);
93 | }
94 |
95 | private static string[] SplitSqlName(string fullName)
96 | {
97 | var split = Regex.Matches(fullName, @"(\[[^\]]+\])|([\w\d]+)").OfType().Select(m => m.Value).ToArray();
98 | return split;
99 | }
100 |
101 | public SqlName Append(string objectName)
102 | {
103 | if (Table != Object) throw new InvalidOperationException("Cannot get a child of an object that is not a table");
104 |
105 | SqlName child = (SqlName)MemberwiseClone();
106 | child.Object = SqlParser.UnformatSqlName(objectName);
107 |
108 | return child;
109 | }
110 |
111 | public bool Equals(SqlName other)
112 | {
113 | return String.Compare(Schema, other.Schema, StringComparison.OrdinalIgnoreCase) == 0 &&
114 | String.Compare(Table, other.Table, StringComparison.OrdinalIgnoreCase) == 0 &&
115 | String.Compare(Object, other.Object, StringComparison.OrdinalIgnoreCase) == 0;
116 | }
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Sample/Insight.Database.Schema.Sample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {C4468859-9F7A-41DF-A6DC-94118F6BAE8D}
9 | Exe
10 | Properties
11 | Insight.Database.Schema.Sample
12 | Insight.Database.Schema.Sample
13 | v4.5
14 |
15 |
16 | 512
17 |
18 |
19 | x86
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 | false
28 |
29 |
30 | x86
31 | pdbonly
32 | true
33 | bin\Release\
34 | TRACE
35 | prompt
36 | 4
37 | false
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | {FBD1C65F-9054-42C7-BA0E-48A922C4C747}
58 | Insight.Database.Schema
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
84 |
--------------------------------------------------------------------------------
/Build.psake.ps1:
--------------------------------------------------------------------------------
1 | $psake.use_exit_on_error = $true
2 |
3 | #########################################
4 | # to build a new version
5 | # 1. git tag 1.0.x
6 | # 2. build package
7 | #########################################
8 |
9 | properties {
10 | $baseDir = $psake.build_script_dir
11 |
12 | $version = git describe --abbrev=0 --tags
13 | $changeset = (git log -1 $version --pretty=format:%H)
14 | $assemblyversion = $version.Split('-', 2)[0]
15 |
16 | $outputDir = "$baseDir\Build\Output"
17 | $net40Path = "$baseDir\Insight.Database.Schema\bin\NET40"
18 |
19 | $framework = "$env:systemroot\Microsoft.NET\Framework\v4.0.30319\"
20 | $msbuild = $framework + "msbuild.exe"
21 | $configuration = "Release"
22 | $nuget = "nuget.exe"
23 | $nunit = Get-ChildItem "$baseDir\packages" -Recurse -Include nunit-console.exe
24 | }
25 |
26 | Task default -depends Build
27 | Task Build -depends Build40,Build45
28 | Task Test -depends Test40,Test45
29 |
30 | function Replace-Version {
31 | param (
32 | [string] $Path
33 | )
34 |
35 | (Get-Content $Path) |
36 | % { $_ -replace "\[assembly: AssemblyVersion\(`"(\d+\.?)*`"\)\]","[assembly: AssemblyVersion(`"$assemblyversion`")]" } |
37 | % { $_ -replace "\[assembly: AssemblyFileVersion\(`"(\d+\.?)*`"\)\]","[assembly: AssemblyFileVersion(`"$assemblyversion`")]" } |
38 | Set-Content $Path
39 | }
40 |
41 | function ReplaceVersions {
42 | Get-ChildItem $baseDir -Include AssemblyInfo.cs -Recurse |% { Replace-Version $_.FullName }
43 | }
44 |
45 | function RestoreVersions {
46 | Get-ChildItem $baseDir -Include AssemblyInfo.cs -Recurse |% {
47 | git checkout $_.FullName
48 | }
49 | }
50 |
51 | function Wipe-Folder {
52 | param (
53 | [string] $Path
54 | )
55 |
56 | if (Test-Path $Path) { Remove-Item $Path -Recurse }
57 | New-Item -Path $Path -ItemType Directory | Out-Null
58 | }
59 |
60 | Task Build40 {
61 | ReplaceVersions
62 |
63 | try {
64 | # build the NET40 binaries
65 | Exec {
66 | Invoke-Expression "$msbuild $baseDir\Insight.sln /p:Configuration=$configuration /p:TargetFrameworkVersion=v4.0 /p:DefineConstants=```"NODBASYNC``;CODE_ANALYSIS```" '/t:Clean;Build'"
67 | }
68 |
69 | # copy the binaries to the net40 folder
70 | Wipe-Folder $net40Path
71 | Copy-Item $baseDir\Insight.Database.Schema\bin\Release\*.* $net40Path
72 | Copy-Item $baseDir\Insight.Database.Schema.Tests\bin\Release\*.* $net40Path
73 | Copy-Item $baseDir\Insight.Database.Schema.Installer\bin\Release\*.* $net40Path
74 | }
75 | finally {
76 | RestoreVersions
77 | }
78 | }
79 |
80 | Task Build45 {
81 | ReplaceVersions
82 |
83 | try {
84 | # build the NET45 binaries
85 | Exec {
86 | Invoke-Expression "$msbuild $baseDir\Insight.sln '/p:Configuration=$configuration' '/t:Clean;Build'"
87 | }
88 | }
89 | finally {
90 | RestoreVersions
91 | }
92 | }
93 |
94 | Task Test40 -depends Build40 {
95 | Exec {
96 | Invoke-Expression "$nunit $net40Path\Insight.Database.Schema.Tests.dll"
97 | }
98 | }
99 |
100 | Task Test45 -depends Build45 {
101 | Exec {
102 | Invoke-Expression "$nunit $baseDir\Insight.Database.Schema.Tests\bin\$configuration\Insight.Database.Schema.Tests.dll"
103 | }
104 | }
105 |
106 | Task Package -depends Test {
107 | Wipe-Folder $outputDir
108 |
109 | # package nuget
110 | Exec {
111 | Invoke-Expression "$nuget pack $baseDir\Insight.Database.Schema.nuspec -OutputDirectory $outputDir -Version $version -NoPackageAnalysis"
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/packages/NUnit.2.6.0.12054/tools/NUnitTests.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
25 |
26 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
54 |
55 |
60 |
61 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Tests/SqlParserTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Text.RegularExpressions;
6 | using System.Threading.Tasks;
7 | using NUnit.Framework;
8 | using System.IO;
9 |
10 | namespace Insight.Database.Schema.Tests
11 | {
12 | [TestFixture]
13 | public class SqlParserTests
14 | {
15 | #region Parser Tests
16 | ///
17 | /// Make sure that all forms of SQL names are detected properly.
18 | ///
19 | ///
20 | [Test]
21 | public void TestSqlNameParsing([Values (
22 | "type::[AccountsTableType]",
23 | "type::[dbo].[AccountsTableType]",
24 | "dbo.Accounts",
25 | "Accounts",
26 | "foo.dbo.Accounts",
27 | "[Foo].dbo.Accounts"
28 | )] string name)
29 | {
30 | Regex regex = new Regex(SqlParser.SqlNameExpression, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.ExplicitCapture | RegexOptions.Compiled);
31 |
32 | Match m = regex.Match(name);
33 | Assert.IsTrue(m.Success);
34 | Assert.AreEqual(m.Value, name);
35 | }
36 |
37 | ///
38 | /// Make sure that we throw exceptions for all of the SQL we don't support.
39 | ///
40 | /// The sql to check.
41 | [Test]
42 | public void TestUnsupportedSql([Values(
43 | "ALTER TABLE Foo ADD CONSTRAINT CHECK (id > 0)", // unnamed explicit check constraints
44 | "CREATE TABLE Foo (id int, CHECK (id > 0))", // unnamed inline check constraints
45 | "ALTER TABLE Foo ADD PRIMARY KEY (ID)", // unnamed explicit primary key
46 | "CREATE TABLE Foo (id int, PRIMARY KEY (ID))", // unnamed inline primary key
47 | "ALTER TABLE Foo ADD FOREIGN KEY (ID)", // unnamed explicit foreign key
48 | "CREATE TABLE Foo (id int, FOREIGN KEY (ID))", // unnamed inline foreign key
49 | ""
50 | )] string sql)
51 | {
52 | if (sql == "") return;
53 |
54 | Assert.Throws(() => new SchemaObject(sql));
55 | }
56 | #endregion
57 |
58 | #region Schema Tests
59 | ///
60 | /// Test that when everything after the last GO is a comment or whitespace, the last section is ignored.
61 | /// UNLESS it's an autoproc, which can be embedded in comments.
62 | ///
63 | [Test]
64 | public void TestTrailingWhiteSpaceAndComments()
65 | {
66 | AssertScriptCount(1, "CREATE PROC Foo AS SELECT 1");
67 | AssertScriptCount(1, "CREATE PROC Foo AS SELECT 1 \n GO ");
68 | AssertScriptCount(1, "CREATE PROC Foo AS SELECT 1 \n GO \n");
69 | AssertScriptCount(1, "CREATE PROC Foo AS SELECT 1 \n GO \n \n");
70 | AssertScriptCount(1, "CREATE PROC Foo AS SELECT 1 \n GO --comment");
71 | AssertScriptCount(1, "CREATE PROC Foo AS SELECT 1 \n GO \n --comment");
72 | AssertScriptCount(1, "CREATE PROC Foo AS SELECT 1 \n GO \n --comment \n");
73 | AssertScriptCount(2, "CREATE PROC Foo AS SELECT 1 \n GO \n --comment \n CREATE PROC Goo AS SELECT 1 \n GO");
74 |
75 | // autoprocs are purely comment-based, so we need to make sure they work
76 | AssertScriptCount(1, "-- AUTOPROC Beer All");
77 | AssertScriptCount(2, "-- AUTOPROC Beer All \n GO \n -- AUTOPROC Glasses All");
78 | AssertScriptCount(2, "CREATE PROC Foo AS SELECT 1 \n GO \n -- AUTOPROC Beer All");
79 | AssertScriptCount(2, "CREATE PROC Foo AS SELECT 1 \n GO \n -- AUTOPROC Beer All");
80 | }
81 |
82 | private void AssertScriptCount(int count, string sql)
83 | {
84 | StringReader reader = new StringReader(sql);
85 | SchemaObjectCollection c = new SchemaObjectCollection();
86 | c.Load(reader);
87 | Assert.AreEqual(count, c.Count);
88 | }
89 | #endregion
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Tests/Insight.Database.Schema.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {AA0C2EDB-9659-418D-BCA4-3CBF16B90336}
8 | Library
9 | Properties
10 | Insight.Database.Schema.Tests
11 | Insight.Database.Schema.Tests
12 | v4.5
13 | 512
14 | ..\
15 | true
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 | ..\packages\Moq.4.0.10827\lib\NET40\Moq.dll
37 |
38 |
39 | ..\packages\NUnit.2.6.0.12054\lib\nunit.framework.dll
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | Always
64 |
65 |
66 |
67 |
68 |
69 | {fbd1c65f-9054-42c7-ba0e-48a922c4c747}
70 | Insight.Database.Schema
71 |
72 |
73 |
74 |
81 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/SchemaEventLogger.cs:
--------------------------------------------------------------------------------
1 | #region Using directives
2 |
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Globalization;
6 | using System.Text;
7 |
8 | using Insight.Database.Schema.Properties;
9 | #endregion
10 |
11 | namespace Insight.Database.Schema
12 | {
13 | #region SchemaEventLogger Class
14 | ///
15 | /// Logs events from a schema installer.
16 | ///
17 | public abstract class SchemaEventLogger
18 | {
19 | #region Constructors
20 | ///
21 | /// Construct an event logger
22 | ///
23 | protected SchemaEventLogger ()
24 | {
25 | _onSchemaChange = new EventHandler (OnSchemaChange);
26 | }
27 |
28 | ///
29 | /// Construct an event logger and attach it to a schema installer.
30 | ///
31 | /// The installer to monitor
32 | protected SchemaEventLogger (SchemaInstaller installer) : this()
33 | {
34 | Attach (installer);
35 | }
36 | #endregion
37 |
38 | #region Attach/Detach Methods
39 | ///
40 | /// Attach to the events of a SchemaInstaller
41 | ///
42 | /// The installer to attach to
43 | public void Attach (SchemaInstaller installer)
44 | {
45 | if (installer == null) throw new ArgumentNullException("installer");
46 |
47 | installer.DroppingObject += _onSchemaChange;
48 | installer.CreatingObject += _onSchemaChange;
49 | installer.CreatedObject += _onSchemaChange;
50 | installer.DropFailed += _onSchemaChange;
51 | }
52 |
53 | ///
54 | /// Detach from the events of a SchemaInstaller
55 | ///
56 | /// The installer to detach from
57 | public void Detach (SchemaInstaller installer)
58 | {
59 | if (installer == null) throw new ArgumentNullException("installer");
60 |
61 | installer.DroppingObject -= _onSchemaChange;
62 | installer.CreatingObject -= _onSchemaChange;
63 | installer.CreatedObject -= _onSchemaChange;
64 | installer.DropFailed -= _onSchemaChange;
65 | }
66 |
67 | private EventHandler _onSchemaChange;
68 | #endregion
69 |
70 | #region Event Handlers
71 | ///
72 | /// Called when a schema event is received
73 | ///
74 | /// The schema event
75 | public abstract void LogSchemaChange (SchemaEventArgs se);
76 |
77 | private void OnSchemaChange (object sender, SchemaEventArgs se)
78 | {
79 | LogSchemaChange (se);
80 | }
81 | #endregion
82 |
83 | #region Support Methods
84 | ///
85 | /// Format a schema event into a string
86 | ///
87 | /// The schema event to format
88 | /// The formatted event
89 | protected static string FormatEventArgs (SchemaEventArgs se)
90 | {
91 | if (se == null) throw new ArgumentNullException("se");
92 |
93 | string eventName;
94 | switch (se.EventType)
95 | {
96 | case SchemaEventType.BeforeDrop:
97 | eventName = Resources.Dropping;
98 | break;
99 | case SchemaEventType.BeforeCreate:
100 | eventName = Resources.Creating;
101 | break;
102 | case SchemaEventType.AfterCreate:
103 | eventName = Resources.Created;
104 | break;
105 | case SchemaEventType.DropFailed:
106 | return String.Format(CultureInfo.CurrentCulture, "Drop Failed: {0} {1}", se.ObjectName, se.Exception.Message);
107 |
108 | default:
109 | eventName = Enum.Format (typeof (SchemaEventType), se.EventType, "G");
110 | break;
111 | }
112 |
113 | return String.Format (CultureInfo.CurrentCulture, "{0} {1}", eventName, se.ObjectName);
114 | }
115 | #endregion
116 | }
117 | #endregion
118 | }
119 |
--------------------------------------------------------------------------------
/Insight.Database.Schema.Verifier/Insight.Database.Schema.Verifier.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {1EFC149D-87EA-437F-AA75-3AC1FA178CFA}
8 | Exe
9 | Properties
10 | Insight.Database.Schema.Verifier
11 | Insight.Database.Schema.Verifier
12 | v4.5
13 | 512
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 | False
37 | ..\..\..\..\Program Files (x86)\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.ConnectionInfo.dll
38 |
39 |
40 | False
41 | ..\..\..\..\Program Files (x86)\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.Management.Sdk.Sfc.dll
42 |
43 |
44 | False
45 | ..\..\..\..\Program Files (x86)\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.Smo.dll
46 |
47 |
48 | False
49 | ..\..\..\..\Program Files (x86)\Microsoft SQL Server\110\SDK\Assemblies\Microsoft.SqlServer.SmoExtended.dll
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | {fbd1c65f-9054-42c7-ba0e-48a922c4c747}
69 | Insight.Database.Schema
70 |
71 |
72 |
73 |
80 |
--------------------------------------------------------------------------------
/Insight.Database.Schema/Implementation/Permission.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Globalization;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Text.RegularExpressions;
8 |
9 | namespace Insight.Database.Schema.Implementation
10 | {
11 | class Permission : SchemaImpl
12 | {
13 | public Permission(string name, string sql) : base(name, sql, 1)
14 | {
15 | }
16 |
17 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1505:AvoidUnmaintainableCode"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
18 | public override bool Exists(IDbConnection connection)
19 | {
20 | // check permissions by querying the permissions table
21 | Match m = Regex.Match(Name.Original, String.Format(CultureInfo.InvariantCulture, @"(?\w+)\s+ON\s+(?