Skip to content

Commit b464a39

Browse files
authored
Merge pull request #2 from HabboIlany/feature/fix-migrations
Migrations now work using Package Manager Console
2 parents e69e174 + 593841b commit b464a39

7 files changed

Lines changed: 199 additions & 68 deletions

File tree

TurboSamplePlugin.DesignTime/TurboSamplePlugin.DesignTime.csproj

Lines changed: 0 additions & 18 deletions
This file was deleted.

TurboSamplePlugin.sln

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ VisualStudioVersion = 17.8.34322.80
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TurboSamplePlugin", "TurboSamplePlugin\TurboSamplePlugin.csproj", "{24B90E2F-1A81-4D24-B47A-2DCAF8CA62BF}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TurboSamplePlugin.DesignTime", "TurboSamplePlugin.DesignTime\TurboSamplePlugin.DesignTime.csproj", "{5EE7777B-A29F-4FF2-A030-1BA27FBBF17F}"
9-
EndProject
108
Global
119
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1210
Debug|Any CPU = Debug|Any CPU
@@ -29,18 +27,6 @@ Global
2927
{24B90E2F-1A81-4D24-B47A-2DCAF8CA62BF}.Release|x64.Build.0 = Release|Any CPU
3028
{24B90E2F-1A81-4D24-B47A-2DCAF8CA62BF}.Release|x86.ActiveCfg = Release|Any CPU
3129
{24B90E2F-1A81-4D24-B47A-2DCAF8CA62BF}.Release|x86.Build.0 = Release|Any CPU
32-
{5EE7777B-A29F-4FF2-A030-1BA27FBBF17F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33-
{5EE7777B-A29F-4FF2-A030-1BA27FBBF17F}.Debug|Any CPU.Build.0 = Debug|Any CPU
34-
{5EE7777B-A29F-4FF2-A030-1BA27FBBF17F}.Debug|x64.ActiveCfg = Debug|Any CPU
35-
{5EE7777B-A29F-4FF2-A030-1BA27FBBF17F}.Debug|x64.Build.0 = Debug|Any CPU
36-
{5EE7777B-A29F-4FF2-A030-1BA27FBBF17F}.Debug|x86.ActiveCfg = Debug|Any CPU
37-
{5EE7777B-A29F-4FF2-A030-1BA27FBBF17F}.Debug|x86.Build.0 = Debug|Any CPU
38-
{5EE7777B-A29F-4FF2-A030-1BA27FBBF17F}.Release|Any CPU.ActiveCfg = Release|Any CPU
39-
{5EE7777B-A29F-4FF2-A030-1BA27FBBF17F}.Release|Any CPU.Build.0 = Release|Any CPU
40-
{5EE7777B-A29F-4FF2-A030-1BA27FBBF17F}.Release|x64.ActiveCfg = Release|Any CPU
41-
{5EE7777B-A29F-4FF2-A030-1BA27FBBF17F}.Release|x64.Build.0 = Release|Any CPU
42-
{5EE7777B-A29F-4FF2-A030-1BA27FBBF17F}.Release|x86.ActiveCfg = Release|Any CPU
43-
{5EE7777B-A29F-4FF2-A030-1BA27FBBF17F}.Release|x86.Build.0 = Release|Any CPU
4430
EndGlobalSection
4531
GlobalSection(SolutionProperties) = preSolution
4632
HideSolutionNode = FALSE

TurboSamplePlugin/Database/Migrations/20260205210952_Init.Designer.cs

Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using Microsoft.EntityFrameworkCore.Metadata;
3+
using Microsoft.EntityFrameworkCore.Migrations;
4+
5+
#nullable disable
6+
7+
namespace TurboSamplePlugin.Migrations
8+
{
9+
/// <inheritdoc />
10+
public partial class Init : Migration
11+
{
12+
/// <inheritdoc />
13+
protected override void Up(MigrationBuilder migrationBuilder)
14+
{
15+
migrationBuilder.AlterDatabase()
16+
.Annotation("MySql:CharSet", "utf8mb4");
17+
18+
migrationBuilder.CreateTable(
19+
name: "tsp_sample_entities",
20+
columns: table => new
21+
{
22+
id = table.Column<int>(type: "int", nullable: false)
23+
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
24+
created_at = table.Column<DateTime>(type: "datetime(6)", nullable: false)
25+
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
26+
updated_at = table.Column<DateTime>(type: "datetime(6)", nullable: false)
27+
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn),
28+
deleted_at = table.Column<DateTime>(type: "datetime(6)", nullable: true)
29+
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn)
30+
},
31+
constraints: table =>
32+
{
33+
table.PrimaryKey("PK_tsp_sample_entities", x => x.id);
34+
})
35+
.Annotation("MySql:CharSet", "utf8mb4");
36+
}
37+
38+
/// <inheritdoc />
39+
protected override void Down(MigrationBuilder migrationBuilder)
40+
{
41+
migrationBuilder.DropTable(
42+
name: "tsp_sample_entities");
43+
}
44+
}
45+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// <auto-generated />
2+
using System;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.EntityFrameworkCore.Infrastructure;
5+
using Microsoft.EntityFrameworkCore.Metadata;
6+
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
7+
using TurboSamplePlugin.Database;
8+
9+
#nullable disable
10+
11+
namespace TurboSamplePlugin.Migrations
12+
{
13+
[DbContext(typeof(SampleDbContext))]
14+
partial class SampleDbContextModelSnapshot : ModelSnapshot
15+
{
16+
protected override void BuildModel(ModelBuilder modelBuilder)
17+
{
18+
#pragma warning disable 612, 618
19+
modelBuilder
20+
.HasAnnotation("ProductVersion", "9.0.8")
21+
.HasAnnotation("Relational:MaxIdentifierLength", 64);
22+
23+
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
24+
25+
modelBuilder.Entity("TurboSamplePlugin.Database.SampleEntity", b =>
26+
{
27+
b.Property<int>("Id")
28+
.ValueGeneratedOnAdd()
29+
.HasColumnType("int")
30+
.HasColumnName("id");
31+
32+
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
33+
34+
b.Property<DateTime>("CreatedAt")
35+
.ValueGeneratedOnAdd()
36+
.HasColumnType("datetime(6)")
37+
.HasColumnName("created_at");
38+
39+
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<DateTime>("CreatedAt"));
40+
41+
b.Property<DateTime?>("DeletedAt")
42+
.ValueGeneratedOnAddOrUpdate()
43+
.HasColumnType("datetime(6)")
44+
.HasColumnName("deleted_at");
45+
46+
MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property<DateTime?>("DeletedAt"));
47+
48+
b.Property<DateTime>("UpdatedAt")
49+
.ValueGeneratedOnAddOrUpdate()
50+
.HasColumnType("datetime(6)")
51+
.HasColumnName("updated_at");
52+
53+
MySqlPropertyBuilderExtensions.UseMySqlComputedColumn(b.Property<DateTime>("UpdatedAt"));
54+
55+
b.HasKey("Id");
56+
57+
b.ToTable("tsp_sample_entities");
58+
});
59+
#pragma warning restore 612, 618
60+
}
61+
}
62+
}

TurboSamplePlugin.DesignTime/SampleDbContextFactory.cs renamed to TurboSamplePlugin/Database/SampleDbContextFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public SampleDbContext CreateDbContext(string[] args)
2222

2323
services.AddSingleton(_ =>
2424
JsonSerializer.Deserialize<PluginManifest>(
25-
File.ReadAllText("../TurboSamplePlugin/manifest.json")
25+
File.ReadAllText("../manifest.json")
2626
)!
2727
);
2828
services.AddSingleton<TablePrefixProvider>(sp =>

TurboSamplePlugin/TurboSamplePlugin.csproj

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,41 @@
77
<BuildProjectReferences>false</BuildProjectReferences>
88
</PropertyGroup>
99
<ItemGroup>
10-
<None
11-
Include="manifest.json"
12-
CopyToOutputDirectory="PreserveNewest"
13-
CopyToPublishDirectory="PreserveNewest"
14-
/>
10+
<None Include="manifest.json" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
1511
</ItemGroup>
1612
<ItemGroup>
13+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools">
14+
<PrivateAssets>all</PrivateAssets>
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
16+
</PackageReference>
1717
<PackageReference Include="Microsoft.Extensions.Hosting" />
1818
<PackageReference Include="Microsoft.Extensions.Logging" />
1919
<PackageReference Include="Microsoft.EntityFrameworkCore" />
2020
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" />
2121
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" />
2222
</ItemGroup>
2323
<ItemGroup>
24-
<ProjectReference
25-
Include="..\..\turbo-cloud\Turbo.Contracts\Turbo.Contracts.csproj"
26-
Private="false"
27-
ExcludeAssets="runtime"
28-
/>
29-
<ProjectReference
30-
Include="..\..\turbo-cloud\Turbo.Database\Turbo.Database.csproj"
31-
Private="false"
32-
ExcludeAssets="runtime"
33-
/>
34-
<ProjectReference
35-
Include="..\..\turbo-cloud\Turbo.Events\Turbo.Events.csproj"
36-
Private="false"
37-
ExcludeAssets="runtime"
38-
/>
39-
<ProjectReference
40-
Include="..\..\turbo-cloud\Turbo.Messages\Turbo.Messages.csproj"
41-
Private="false"
42-
ExcludeAssets="runtime"
43-
/>
44-
<ProjectReference
45-
Include="..\..\turbo-cloud\Turbo.Primitives\Turbo.Primitives.csproj"
46-
Private="false"
47-
ExcludeAssets="runtime"
48-
/>
49-
<ProjectReference
50-
Include="..\..\turbo-cloud\Turbo.Crypto\Turbo.Crypto.csproj"
51-
Private="false"
52-
ExcludeAssets="runtime"
53-
/>
24+
<Reference Include="Turbo.Contracts">
25+
<HintPath>..\..\turbo-cloud\Turbo.Contracts\bin\Debug\net9.0\Turbo.Contracts.dll</HintPath>
26+
</Reference>
27+
<Reference Include="Turbo.Crypto">
28+
<HintPath>..\..\turbo-cloud\Turbo.Crypto\bin\Debug\net9.0\Turbo.Crypto.dll</HintPath>
29+
</Reference>
30+
<Reference Include="Turbo.Database">
31+
<HintPath>..\..\turbo-cloud\Turbo.Database\bin\Debug\net9.0\Turbo.Database.dll</HintPath>
32+
</Reference>
33+
<Reference Include="Turbo.Events">
34+
<HintPath>..\..\turbo-cloud\Turbo.Events\bin\Debug\net9.0\Turbo.Events.dll</HintPath>
35+
</Reference>
36+
<Reference Include="Turbo.Messages">
37+
<HintPath>..\..\turbo-cloud\Turbo.Messages\bin\Debug\net9.0\Turbo.Messages.dll</HintPath>
38+
</Reference>
39+
<Reference Include="Turbo.Pipeline">
40+
<HintPath>..\..\turbo-cloud\Turbo.Pipeline\bin\Debug\net9.0\Turbo.Pipeline.dll</HintPath>
41+
</Reference>
42+
<Reference Include="Turbo.Primitives">
43+
<HintPath>..\..\turbo-cloud\Turbo.Primitives\bin\Debug\net9.0\Turbo.Primitives.dll</HintPath>
44+
</Reference>
5445
</ItemGroup>
5546

5647
</Project>

0 commit comments

Comments
 (0)