-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
243 additions
and
31 deletions.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
...meworkCore.PostgreSQL.Design/Migrations/Design/NpgsqlCSharpMigrationOperationGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Internal; | ||
using Microsoft.EntityFrameworkCore.Migrations.Operations; | ||
using Microsoft.EntityFrameworkCore.Storage; | ||
using Microsoft.EntityFrameworkCore.Utilities; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Migrations.Design | ||
{ | ||
public class NpgsqlCSharpMigrationOperationGenerator : CSharpMigrationOperationGenerator | ||
{ | ||
readonly CSharpHelper _code; | ||
|
||
public NpgsqlCSharpMigrationOperationGenerator( | ||
[NotNull] CSharpHelper codeHelper, | ||
[NotNull] IDatabaseProviderServices providerServices | ||
) : base(codeHelper) | ||
{ | ||
_code = codeHelper; | ||
} | ||
|
||
protected override void Generate([NotNull] MigrationOperation operation, [NotNull] IndentedStringBuilder builder) | ||
{ | ||
Check.NotNull(operation, nameof(operation)); | ||
Check.NotNull(builder, nameof(builder)); | ||
|
||
var asCreateExtensionOperation = operation as NpgsqlCreatePostgresExtensionOperation; | ||
if (asCreateExtensionOperation != null) | ||
{ | ||
Generate(asCreateExtensionOperation, builder); | ||
return; | ||
} | ||
|
||
var asDropExtensionOperation = operation as NpgsqlDropPostgresExtensionOperation; | ||
if (asDropExtensionOperation != null) | ||
{ | ||
Generate(asDropExtensionOperation, builder); | ||
return; | ||
} | ||
|
||
throw new InvalidOperationException(DesignCoreStrings.UnknownOperation(operation.GetType())); | ||
} | ||
|
||
protected virtual void Generate([NotNull] NpgsqlCreatePostgresExtensionOperation operation, [NotNull] IndentedStringBuilder builder) | ||
{ | ||
Check.NotNull(operation, nameof(operation)); | ||
Check.NotNull(builder, nameof(builder)); | ||
|
||
builder.Append(".CreatePostgresExtension("); | ||
|
||
if (operation.Schema == null && operation.Version == null) | ||
{ | ||
builder.Append(_code.Literal(operation.Name)); | ||
} | ||
else | ||
{ | ||
using (builder.Indent()) | ||
{ | ||
builder | ||
.Append("name: ") | ||
.Append(_code.Literal(operation.Name)); | ||
|
||
if (operation.Schema != null) | ||
{ | ||
builder | ||
.AppendLine(",") | ||
.Append("schema: ") | ||
.Append(_code.Literal(operation.Schema)); | ||
} | ||
|
||
if (operation.Version != null) | ||
{ | ||
builder | ||
.AppendLine(",") | ||
.Append("version: ") | ||
.Append(_code.Literal(operation.Version)); | ||
} | ||
} | ||
} | ||
builder.Append(")"); | ||
|
||
Annotations(operation.GetAnnotations(), builder); | ||
} | ||
|
||
protected virtual void Generate([NotNull] NpgsqlDropPostgresExtensionOperation operation, [NotNull] IndentedStringBuilder builder) | ||
{ | ||
Check.NotNull(operation, nameof(operation)); | ||
Check.NotNull(builder, nameof(builder)); | ||
|
||
builder | ||
.Append(".DropPostgresExtension(") | ||
.Append(_code.Literal(operation.Name)) | ||
.Append(")"); | ||
|
||
Annotations(operation.GetAnnotations(), builder); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...FrameworkCore.PostgreSQL.Design/Npgsql.EntityFrameworkCore.PostgreSQL.Design.project.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
....EntityFrameworkCore.PostgreSQL.Design/Npgsql.EntityFrameworkCore.PostgreSQL.Design.xproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0.25420" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25420</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>180fc3ca-e92e-4b89-8a3a-81302f088f2e</ProjectGuid> | ||
<RootNamespace>Npgsql.EntityFrameworkCore.PostgreSQL.Design</RootNamespace> | ||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> | ||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/Npgsql.EntityFrameworkCore.PostgreSQL/Migrations/MigrationBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
using JetBrains.Annotations; | ||
using Microsoft.EntityFrameworkCore.Migrations.Operations; | ||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders; | ||
using Microsoft.EntityFrameworkCore.Utilities; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Migrations | ||
{ | ||
public static class MigrationBuilderExtensions | ||
{ | ||
static readonly string NpgsqlProviderName = typeof(MigrationBuilderExtensions).GetTypeInfo().Assembly.GetName().Name; | ||
|
||
public static OperationBuilder<NpgsqlCreatePostgresExtensionOperation> CreatePostgresExtension( | ||
this MigrationBuilder builder, | ||
[NotNull] string name, | ||
string schema = null, | ||
string version = null | ||
) | ||
{ | ||
Check.NotEmpty(name, nameof(name)); | ||
Check.NullButNotEmpty(schema, nameof(schema)); | ||
Check.NullButNotEmpty(version, nameof(schema)); | ||
|
||
var operation = new NpgsqlCreatePostgresExtensionOperation | ||
{ | ||
Name = name, | ||
Schema = schema, | ||
Version = version | ||
}; | ||
|
||
if (builder.ActiveProvider == NpgsqlProviderName) | ||
builder.Operations.Add(operation); | ||
|
||
return new OperationBuilder<NpgsqlCreatePostgresExtensionOperation>(operation); | ||
} | ||
|
||
public static OperationBuilder<NpgsqlDropPostgresExtensionOperation> DropPostgresExtension( | ||
this MigrationBuilder builder, | ||
[NotNull] string name | ||
) | ||
{ | ||
Check.NotEmpty(name, nameof(name)); | ||
|
||
var operation = new NpgsqlDropPostgresExtensionOperation { Name = name }; | ||
|
||
if (builder.ActiveProvider == NpgsqlProviderName) | ||
builder.Operations.Add(operation); | ||
|
||
return new OperationBuilder<NpgsqlDropPostgresExtensionOperation>(operation); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Npgsql.EntityFrameworkCore.PostgreSQL/Npgsql.EntityFrameworkCore.PostgreSQL.xproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0.25420" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25420</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>a6370fdf-2140-4780-9671-ffce9688a1ab</ProjectGuid> | ||
<RootNamespace>Npgsql.EntityFrameworkCore.PostgreSQL</RootNamespace> | ||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> | ||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
echo ##teamcity[buildNumber '1.0.0-%1'] | ||
echo ##teamcity[buildNumber '1.0.1-%1'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters