Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
roji committed Jun 29, 2016
2 parents 44154a1 + f520c31 commit aca36a2
Show file tree
Hide file tree
Showing 132 changed files with 2,140 additions and 2,569 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<build-type xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" uuid="f579f33b-8663-4da8-ac92-c95c2362e10f" xsi:noNamespaceSchemaLocation="http://www.jetbrains.com/teamcity/schemas/9.0/project-config.xsd">
<name>Build</name>
<description />
<settings>
<options>
<option name="artifactRules" value="src\Npgsql.EntityFrameworkCore.PostgreSQL\bin\Release\*.nupkg&#xA;src\Npgsql.EntityFrameworkCore.PostgreSQL.Design\bin\Release\*.nupkg" />
<option name="checkoutMode" value="ON_AGENT" />
</options>
<parameters>
<param name="env.Test__Npgsql__DefaultConnection" value="Server=localhost;Port=5495;Username=npgsql_tests;Password=npgsql_tests" />
</parameters>
<build-runners>
<runner id="RUNNER_19" name="Set build number" type="simpleRunner">
<parameters>
<param name="command.executable" value="teamcity_set_version.cmd" />
<param name="command.parameters" value="%build.counter%" />
<param name="teamcity.step.mode" value="default" />
</parameters>
</runner>
<runner id="RUNNER_25" name="Build Debug" type="simpleRunner">
<parameters>
<param name="script.content"><![CDATA[set KOREBUILD_DOTNET_PACK_OPTIONS=--version-suffix "%build.counter%"
set Configuration=Debug
build compile]]></param>
<param name="teamcity.step.mode" value="default" />
<param name="use.custom.script" value="true" />
</parameters>
</runner>
<runner id="RUNNER_26" name="Test" type="simpleRunner">
<parameters>
<param name="command.executable" value="build.cmd" />
<param name="command.parameters" value="test" />
<param name="teamcity.step.mode" value="default" />
</parameters>
</runner>
<runner id="RUNNER_27" name="Build Release" type="simpleRunner">
<parameters>
<param name="script.content"><![CDATA[set KOREBUILD_DOTNET_PACK_OPTIONS=--version-suffix "%build.counter%"
set Configuration=Release
build compile]]></param>
<param name="teamcity.step.mode" value="default" />
<param name="use.custom.script" value="true" />
</parameters>
</runner>
<runner id="RUNNER_28" name="Publish nugets to myget" type="jb.nuget.publish">
<parameters>
<param name="nuget.path" value="?NuGet.CommandLine.DEFAULT" />
<param name="nuget.publish.files"><![CDATA[src/Npgsql.EntityFrameworkCore.PostgreSQL/bin/Release/*.nupkg
src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/bin/Release/*.nupkg]]></param>
<param name="nuget.publish.source" value="https://www.myget.org/F/npgsql-unstable" />
<param name="nugetCustomPath" value="?NuGet.CommandLine.DEFAULT" />
<param name="nugetPathSelector" value="?NuGet.CommandLine.DEFAULT" />
<param name="secure:nuget.api.key" value="zxxca89988ce5b6f9ad529c572cd56e162ccda4fdff046b0cdb8bff3560c8e35dcbda3e64637e4ca2f1" />
<param name="teamcity.step.mode" value="default" />
</parameters>
</runner>
</build-runners>
<vcs-settings>
<vcs-entry-ref root-id="NpgsqlEntityFrameworkCorePostgreSQL_Github" />
</vcs-settings>
<requirements />
<build-triggers>
<build-trigger id="vcsTrigger" type="vcsTrigger">
<parameters>
<param name="branchFilter" value="+:*" />
<param name="quietPeriodMode" value="DO_NOT_USE" />
</parameters>
</build-trigger>
</build-triggers>
<cleanup />
</settings>
</build-type>

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<versionedSettings rootId="NpgsqlEntityFrameworkCorePostgreSQL_Github" enabled="true" showChanges="false" buildSettings="PREFER_VCS" />
</settings>

11 changes: 11 additions & 0 deletions .teamcity/NpgsqlEntityFrameworkCorePostgreSQL/project-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" uuid="ba94274f-bb0e-4ed9-851e-90e4a25cd698" xsi:noNamespaceSchemaLocation="http://www.jetbrains.com/teamcity/schemas/9.0/project-config.xsd">
<name>Npgsql.EntityFrameworkCore.PostgreSQL</name>
<description>Entity Framework Core for PostgreSQL</description>
<parameters>
<param name="env.Test__Npgsql__DefaultConnection" value="Server=localhost;Port=5495;Username=npgsql_tests;Password=npgsql_tests;PersistSecurityInfo=true" />
<param name="GitVersion.NuGetVersion" value="" />
</parameters>
<cleanup />
</project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<vcs-root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" uuid="efb1b201-49da-44ec-962d-16fa17997599" type="jetbrains.git" xsi:noNamespaceSchemaLocation="http://www.jetbrains.com/teamcity/schemas/9.0/project-config.xsd">
<name>Github</name>
<param name="agentCleanFilesPolicy" value="ALL_UNTRACKED" />
<param name="agentCleanPolicy" value="ALWAYS" />
<param name="authMethod" value="PASSWORD" />
<param name="branch" value="dev" />
<param name="ignoreKnownHosts" value="true" />
<param name="secure:password" value="zxx9b1a45147d7e64e7775d03cbe80d301b" />
<param name="submoduleCheckout" value="CHECKOUT" />
<param name="teamcity:branchSpec"><![CDATA[+:refs/heads/(*)
# The following activates building PRs
+:refs/pull/*/merge]]></param>
<param name="url" value="https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL.git" />
<param name="useAlternates" value="true" />
<param name="username" value="npgsql-teamcity" />
<param name="usernameStyle" value="USERID" />
</vcs-root>

6 changes: 0 additions & 6 deletions GitVersionConfig.yaml

This file was deleted.

43 changes: 43 additions & 0 deletions bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

if [ "$#" -ne 1 ]; then
echo "usage: bump.sh <version>"
exit 1
fi

v=$1
if [[ $v == *"-" ]]; then
echo "Version must not end with -"
exit 1
fi

echo "echo ##teamcity[buildNumber '$v-%1']" > teamcity_set_version.cmd

if [[ $v == *"-"* ]]; then
# Prerelease version

without_prerelease=`echo $v | cut -d- -f1`

sed -i 's/^\(\s*\)"version": "[^"]*"/\1"version": "'$v'-*"/' src/Npgsql.EntityFrameworkCore.PostgreSQL/project.json
sed -i 's/^\(\s*\)"version": "[^"]*"/\1"version": "'$v'-*"/' src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/project.json

sed -i 's/AssemblyVersion("[^"]*")/AssemblyVersion("'$without_prerelease'")/' src/Shared/CommonAssemblyInfo.cs
sed -i 's/AssemblyFileVersion("[^"]*")/AssemblyFileVersion("'$without_prerelease'")/' src/Shared/CommonAssemblyInfo.cs
sed -i 's/AssemblyInformationalVersion("[^"]*")/AssemblyInformationalVersion("'$v'")/' src/Shared/CommonAssemblyInfo.cs
else
# Release version

sed -i 's/^\(\s*\)"version": "[^"]*"/\1"version": "'$v'"/' src/Npgsql.EntityFrameworkCore.PostgreSQL/project.json
sed -i 's/^\(\s*\)"version": "[^"]*"/\1"version": "'$v'"/' src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/project.json

sed -i 's/AssemblyVersion("[^"]*")/AssemblyVersion("'$v'")/' src/Shared/CommonAssemblyInfo.cs
sed -i 's/AssemblyFileVersion("[^"]*")/AssemblyFileVersion("'$v'")/' src/Shared/CommonAssemblyInfo.cs
sed -i 's/AssemblyInformationalVersion("[^"]*")/AssemblyInformationalVersion("'$v'")/' src/Shared/CommonAssemblyInfo.cs
fi

git add teamcity_set_version.cmd
git add src/Npgsql.EntityFrameworkCore.PostgreSQL/project.json
git add src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/project.json
git add src/Shared/CommonAssemblyInfo.cs

git commit -m "Bump version to $v"
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
<AssemblyName>Npgsql.EntityFrameworkCore.PostgreSQL.Design</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<!-- The following stops VS from complaining about runtimes in project.json, see
https://github.com/Microsoft/msbuild/issues/394 -->
<CopyNuGetImplementations>false</CopyNuGetImplementations>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"dependencies" : {
"Microsoft.EntityFrameworkCore": "1.0.0",
"Microsoft.EntityFrameworkCore.Relational": "1.0.0",
"Microsoft.EntityFrameworkCore.Relational.Design": "1.0.0",
"Microsoft.Extensions.DependencyInjection": "1.0.0",
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0",
"Npgsql": "3.1.5"
},
"frameworks": {
"net451": {}
},
"runtimes": {
"win": {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
using Microsoft.EntityFrameworkCore.Storage.Internal;
using Microsoft.Extensions.DependencyInjection;

namespace Microsoft.EntityFrameworkCore.Scaffolding
namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal
{
public class NpgsqlDesignTimeServices
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,28 @@
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Scaffolding.Metadata;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.Logging;

namespace Microsoft.EntityFrameworkCore.Scaffolding
namespace Microsoft.EntityFrameworkCore.Scaffolding.Internal
{
public class NpgsqlScaffoldingModelFactory : RelationalScaffoldingModelFactory
{
public NpgsqlScaffoldingModelFactory(
[NotNull] ILoggerFactory loggerFactory,
[NotNull] IRelationalTypeMapper typeMapper,
[NotNull] IDatabaseModelFactory databaseModelFactory)
: base(loggerFactory, typeMapper, databaseModelFactory)
[NotNull] IDatabaseModelFactory databaseModelFactory,
[NotNull] CandidateNamingService candidateNamingService)
: base(loggerFactory, typeMapper, databaseModelFactory, candidateNamingService)
{
}

public override IModel Create(string connectionString, TableSelectionSet tableSelectionSet)
public override IModel Create(string connectionString, [CanBeNull] TableSelectionSet tableSelectionSet)
{
var model = base.Create(connectionString, tableSelectionSet);
model.Scaffolding().UseProviderMethodName = nameof(NpgsqlDbContextOptionsExtensions.UseNpgsql);
Expand Down
15 changes: 8 additions & 7 deletions src/Npgsql.EntityFrameworkCore.PostgreSQL.Design/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.0-rc2-release1",
"version": "1.0.0",
"packOptions": {
"authors": [ "Shay Rojansky" ],
"description": "Design-time Entity Framework Core Functionality for PostgreSQL",
Expand All @@ -18,12 +18,13 @@
}
},
"dependencies" : {
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-*",
"Microsoft.EntityFrameworkCore.Relational": "1.0.0-rc2-*",
"Microsoft.EntityFrameworkCore.Relational.Design": "1.0.0-rc2-*",
"Microsoft.Extensions.DependencyInjection": "1.0.0-rc2-*",
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc2-*",
"Npgsql.EntityFrameworkCore.PostgreSQL": "1.0.0-rc2-release1"
"Microsoft.EntityFrameworkCore": "1.0.0",
"Microsoft.EntityFrameworkCore.Relational": "1.0.0",
"Microsoft.EntityFrameworkCore.Relational.Design": "1.0.0",
"Microsoft.Extensions.DependencyInjection": "1.0.0",
"Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0",
"Npgsql.EntityFrameworkCore.PostgreSQL": "1.0.0",
"Npgsql": "3.1.5"
},
"frameworks": {
"net451": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public static IServiceCollection AddEntityFrameworkNpgsql([NotNull] this IServic
{
Check.NotNull(services, nameof(services));

services.TryAdd(new ServiceCollection()
.AddScoped<NpgsqlMigrationsModelDiffer>()
.AddScoped<IMigrationsModelDiffer, NpgsqlMigrationsModelDiffer>()
);

services.AddRelational();

services.TryAddEnumerable(ServiceDescriptor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

namespace Microsoft.EntityFrameworkCore.Infrastructure.Internal
{
public class NpgsqlModelSource : ModelSource
public class NpgsqlModelSource : RelationalModelSource
{
public NpgsqlModelSource(
[NotNull] IDbSetFinder setFinder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ protected virtual void EnsureUuidExtensionIfNeeded(IModel model)
from e in model.GetEntityTypes()
from p in e.GetProperties()
where p.ClrType.UnwrapNullableType() == typeof(Guid)
let defaultValueSql = (string)_relationalExtensions.For(p).DefaultValueSql
where defaultValueSql != null && defaultValueSql.Contains("uuid_generate")
let defaultValueSql = _relationalExtensions.For(p).DefaultValueSql
where _relationalExtensions.For(p).DefaultValueSql?.StartsWith("uuid_generate") == true ||
p.ValueGenerated == ValueGenerated.OnAdd
select p
).FirstOrDefault();

if (generatedUuidProperty != null &&
model.Npgsql().PostgresExtensions.All(e => e.Name != "uuid-ossp"))
{
ShowError(@"Database-generated UUIDs require the PostgreSQL uuid-ossp extension. Add .HasPostgresExtension(""uuid-ossp"") to your context's OnModelCreating.");
ShowError($@"Property {generatedUuidProperty.Name} on type {generatedUuidProperty.DeclaringEntityType.Name} is a database-generated uuid, which requires the PostgreSQL uuid-ossp extension. Add .HasPostgresExtension(""uuid-ossp"") to your context's OnModelCreating.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Microsoft.EntityFrameworkCore.Metadata.Internal
public static class NpgsqlAnnotationNames
{
public const string Prefix = "Npgsql:";
public const string Serial = "Serial";
public const string ValueGeneratedOnAdd = "ValueGeneratedOnAdd";
public const string DefaultSequenceName = "DefaultSequenceName";
public const string DefaultSequenceSchema = "DefaultSequenceSchema";
public const string SequenceName = "SequenceName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class NpgsqlFullAnnotationNames : RelationalFullAnnotationNames
protected NpgsqlFullAnnotationNames(string prefix)
: base(prefix)
{
Serial = prefix + NpgsqlAnnotationNames.Serial;
DefaultSequenceName = prefix + NpgsqlAnnotationNames.DefaultSequenceName;
DefaultSequenceSchema = prefix + NpgsqlAnnotationNames.DefaultSequenceSchema;
SequenceName = prefix + NpgsqlAnnotationNames.SequenceName;
Expand All @@ -40,7 +39,6 @@ protected NpgsqlFullAnnotationNames(string prefix)

public new static NpgsqlFullAnnotationNames Instance { get; } = new NpgsqlFullAnnotationNames(NpgsqlAnnotationNames.Prefix);

public readonly string Serial;
public readonly string DefaultSequenceName;
public readonly string DefaultSequenceSchema;
public readonly string SequenceName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,12 @@ public class NpgsqlMigrationsAnnotationProvider : MigrationsAnnotationProvider
{
public override IEnumerable<IAnnotation> For(IProperty property)
{
if (property.ValueGenerated == ValueGenerated.OnAdd &&
property.ClrType.IsIntegerForSerial()) {
yield return new Annotation(NpgsqlAnnotationNames.Prefix + NpgsqlAnnotationNames.Serial, true);
}

// TODO: Named sequences

// TODO: We don't support ValueGenerated.OnAddOrUpdate, so should we throw an exception?
// Other providers don't seem to...
// The migrations SQL generator gets the property's DefaultValue and DefaultValueSql.
// However, there's no way there to detect properties that have ValueGenerated.OnAdd
// *without* defining a default value; these should translate to SERIAL columns.
// So we add a custom annotation here to pass the information.
if (property.ValueGenerated == ValueGenerated.OnAdd)
yield return new Annotation(NpgsqlAnnotationNames.Prefix + NpgsqlAnnotationNames.ValueGeneratedOnAdd, true);
}

public override IEnumerable<IAnnotation> For(IIndex index)
Expand Down
Loading

0 comments on commit aca36a2

Please sign in to comment.