-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue in EF core dotnet/efcore#12078 makes things worse
- Loading branch information
Showing
14 changed files
with
387 additions
and
4 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ obj | |
.suo | ||
/src/Flow.sln.DotSettings.user | ||
/src/.vs | ||
/src/.env |
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,12 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"dotnet-ef": { | ||
"version": "5.0.11", | ||
"commands": [ | ||
"dotnet-ef" | ||
] | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: "3.8" | ||
services: | ||
accounts-db: | ||
image: postgres | ||
restart: always | ||
volumes: | ||
- flow-storage-data:/var/lib/postgresql/data | ||
environment: | ||
- POSTGRES_DB=flow-dev | ||
- "POSTGRES_USER=${DEV_DB_USER}" | ||
- "POSTGRES_PASSWORD=${DEV_DB_PWD}" | ||
ports: | ||
- "${DEV_DB_PORT}:5432" | ||
|
||
volumes: | ||
flow-storage-data: |
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
18 changes: 18 additions & 0 deletions
18
src/l2/Flow.Infrastructure.Storage.Migrations/DesignTimeDbContextBuilderFactory.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,18 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Design; | ||
|
||
namespace Flow.Infrastructure.Storage.Migrations; | ||
|
||
internal class DesignTimeDbContextBuilderFactory : IDesignTimeDbContextFactory<FlowDbContext> | ||
{ | ||
public FlowDbContext CreateDbContext(string[] args) | ||
{ | ||
var options = new DbContextOptionsBuilder() | ||
.UseNpgsql( | ||
args.FirstOrDefault() ?? throw new InvalidOperationException("Connection string was not configured!"), | ||
o => o.MigrationsAssembly(typeof(DesignTimeDbContextBuilderFactory).Assembly.FullName)) | ||
.Options; | ||
|
||
return new FlowDbContext(options); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/l2/Flow.Infrastructure.Storage.Migrations/Flow.Infrastructure.Storage.Migrations.csproj
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,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Flow.Infrastructure.Storage\Flow.Infrastructure.Storage.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.11"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
114 changes: 114 additions & 0 deletions
114
src/l2/Flow.Infrastructure.Storage.Migrations/Migrations/20211106231710_initial.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
src/l2/Flow.Infrastructure.Storage.Migrations/Migrations/20211106231710_initial.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,66 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; | ||
|
||
namespace Flow.Infrastructure.Storage.Migrations.Migrations | ||
{ | ||
public partial class initial : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "AccountInfo", | ||
columns: table => new | ||
{ | ||
Name = table.Column<string>(type: "text", nullable: false), | ||
Bank = table.Column<string>(type: "text", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_AccountInfo", x => new { x.Name, x.Bank }); | ||
}); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "Transactions", | ||
columns: table => new | ||
{ | ||
Key = table.Column<long>(type: "bigint", nullable: false) | ||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), | ||
Overrides_Comment = table.Column<string>(type: "text", nullable: true), | ||
Overrides_Title = table.Column<string>(type: "text", nullable: true), | ||
Overrides_Category = table.Column<string>(type: "text", nullable: true), | ||
account_name = table.Column<string>(type: "text", nullable: false), | ||
bank_name = table.Column<string>(type: "text", nullable: false), | ||
Timestamp = table.Column<DateTime>(type: "timestamp without time zone", nullable: false), | ||
Amount = table.Column<decimal>(type: "numeric", nullable: false), | ||
Currency = table.Column<string>(type: "text", nullable: false), | ||
Category = table.Column<string>(type: "text", nullable: false), | ||
Title = table.Column<string>(type: "text", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_Transactions", x => x.Key); | ||
table.ForeignKey( | ||
name: "FK_Transactions_AccountInfo_account_name_bank_name", | ||
columns: x => new { x.account_name, x.bank_name }, | ||
principalTable: "AccountInfo", | ||
principalColumns: new[] { "Name", "Bank" }, | ||
onDelete: ReferentialAction.Cascade); | ||
}); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_Transactions_account_name_bank_name", | ||
table: "Transactions", | ||
columns: new[] { "account_name", "bank_name" }); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "Transactions"); | ||
|
||
migrationBuilder.DropTable( | ||
name: "AccountInfo"); | ||
} | ||
} | ||
} |
Oops, something went wrong.