Skip to content

Commit

Permalink
Add Initial Migration
Browse files Browse the repository at this point in the history
  • Loading branch information
philgei committed Nov 25, 2024
1 parent e937673 commit 1745758
Show file tree
Hide file tree
Showing 6 changed files with 297 additions and 7 deletions.
10 changes: 5 additions & 5 deletions AdLerBackend.API/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
"ASPNETCORE_ENVIRONMENT": "Production",
"ASPNETCORE_ADLER_MOODLEURL": "http://localhost:8085",
"ASPNETCORE_ADLER_HTTPPORT": 3000,
"ASPNETCORE_DBPASSWORD": "placeholder",
"ASPNETCORE_DBUSER": "placeholder",
"ASPNETCORE_DBNAME": "placeholder",
"ASPNETCORE_DBHOST": "placeholder",
"ASPNETCORE_DBPORT": "placeholder",
"ASPNETCORE_DBPASSWORD": "b",
"ASPNETCORE_DBUSER": "adler_backend",
"ASPNETCORE_DBNAME": "adler_backend",
"ASPNETCORE_DBHOST": "localhost",
"ASPNETCORE_DBPORT": "3306",
"ASPNETCORE_ADLER_ADLERENGINEURL": "http://localhost:8087"
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 82 additions & 0 deletions AdLerBackend.Infrastructure/Migrations/20241125115430_Initial.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace AdLerBackend.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "PlayerData",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false),
PlayerGender = table.Column<int>(type: "INTEGER", nullable: false),
PlayerWorldColor = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PlayerData", x => x.Id);
});

migrationBuilder.CreateTable(
name: "Worlds",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
LmsWorldId = table.Column<int>(type: "INTEGER", nullable: false),
AuthorId = table.Column<int>(type: "INTEGER", nullable: false),
AtfJson = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Worlds", x => x.Id);
});

migrationBuilder.CreateTable(
name: "H5PLocationEntity",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Path = table.Column<string>(type: "TEXT", nullable: false),
ElementId = table.Column<int>(type: "INTEGER", nullable: true),
WorldEntityId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_H5PLocationEntity", x => x.Id);
table.ForeignKey(
name: "FK_H5PLocationEntity_Worlds_WorldEntityId",
column: x => x.WorldEntityId,
principalTable: "Worlds",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});

migrationBuilder.CreateIndex(
name: "IX_H5PLocationEntity_WorldEntityId",
table: "H5PLocationEntity",
column: "WorldEntityId");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "H5PLocationEntity");

migrationBuilder.DropTable(
name: "PlayerData");

migrationBuilder.DropTable(
name: "Worlds");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// <auto-generated />
using System;
using AdLerBackend.Infrastructure.Repositories;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

#nullable disable

namespace AdLerBackend.Infrastructure.Migrations
{
[DbContext(typeof(DevelopmentContext))]
partial class DevelopmentContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.10");

modelBuilder.Entity("AdLerBackend.Domain.Entities.H5PLocationEntity", b =>
{
b.Property<int?>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasAnnotation("SqlServer:IdentityIncrement", 1)
.HasAnnotation("SqlServer:IdentitySeed", 1L)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

b.Property<int?>("ElementId")
.HasColumnType("INTEGER");

b.Property<string>("Path")
.IsRequired()
.HasColumnType("TEXT");

b.Property<int?>("WorldEntityId")
.HasColumnType("INTEGER");

b.HasKey("Id");

b.HasIndex("WorldEntityId");

b.ToTable("H5PLocationEntity");
});

modelBuilder.Entity("AdLerBackend.Domain.Entities.PlayerData.PlayerData", b =>
{
b.Property<int?>("Id")
.HasColumnType("INTEGER");

b.Property<int>("PlayerGender")
.HasColumnType("INTEGER");

b.Property<int>("PlayerWorldColor")
.HasColumnType("INTEGER");

b.HasKey("Id");

b.ToTable("PlayerData");
});

modelBuilder.Entity("AdLerBackend.Domain.Entities.WorldEntity", b =>
{
b.Property<int?>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");

b.Property<string>("AtfJson")
.IsRequired()
.HasColumnType("TEXT");

b.Property<int>("AuthorId")
.HasColumnType("INTEGER");

b.Property<int>("LmsWorldId")
.HasColumnType("INTEGER");

b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");

b.HasKey("Id");

b.ToTable("Worlds");
});

modelBuilder.Entity("AdLerBackend.Domain.Entities.H5PLocationEntity", b =>
{
b.HasOne("AdLerBackend.Domain.Entities.WorldEntity", null)
.WithMany("H5PFilesInCourse")
.HasForeignKey("WorldEntityId")
.OnDelete(DeleteBehavior.Cascade);
});

modelBuilder.Entity("AdLerBackend.Domain.Entities.WorldEntity", b =>
{
b.Navigation("H5PFilesInCourse");
});
#pragma warning restore 612, 618
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed class DevelopmentContext : BaseAdLerBackendDbContext
public DevelopmentContext(DbContextOptions options, IConfiguration configuration) : base(options)
{
_configuration = configuration;
Database.EnsureCreated();
Database.Migrate();
}

protected override void OnConfiguring(DbContextOptionsBuilder options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public sealed class ProductionContext : BaseAdLerBackendDbContext
public ProductionContext(DbContextOptions options, IOptions<BackendConfig> confguration) : base(options)
{
_backendConfig = confguration.Value;
Database.EnsureCreated();
}

protected override void OnConfiguring(DbContextOptionsBuilder options)
Expand Down

0 comments on commit 1745758

Please sign in to comment.