120 lines
5.2 KiB
C#
120 lines
5.2 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace OnProfNext.Server.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class FixProjectUserRelation : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Orders",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ProjectId = table.Column<int>(type: "int", nullable: false),
|
|
Auftragsnummer = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
|
|
Titel = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
|
|
Status = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false, defaultValue: "Geplant"),
|
|
Planstunden = table.Column<decimal>(type: "decimal(10,2)", precision: 10, scale: 2, nullable: false, defaultValue: 0m),
|
|
Iststunden = table.Column<decimal>(type: "decimal(10,2)", precision: 10, scale: 2, nullable: false, defaultValue: 0m),
|
|
Projektcode = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
MandantId = table.Column<int>(type: "int", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETUTCDATE()"),
|
|
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETUTCDATE()")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Orders", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Orders_Projects_ProjectId",
|
|
column: x => x.ProjectId,
|
|
principalTable: "Projects",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ProjectUsers",
|
|
columns: table => new
|
|
{
|
|
ProjectId = table.Column<int>(type: "int", nullable: false),
|
|
UserId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ProjectUsers", x => new { x.ProjectId, x.UserId });
|
|
table.ForeignKey(
|
|
name: "FK_ProjectUsers_Projects_ProjectId",
|
|
column: x => x.ProjectId,
|
|
principalTable: "Projects",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_ProjectUsers_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "OrderUsers",
|
|
columns: table => new
|
|
{
|
|
OrderId = table.Column<int>(type: "int", nullable: false),
|
|
UserId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_OrderUsers", x => new { x.OrderId, x.UserId });
|
|
table.ForeignKey(
|
|
name: "FK_OrderUsers_Orders_OrderId",
|
|
column: x => x.OrderId,
|
|
principalTable: "Orders",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_OrderUsers_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Orders_ProjectId",
|
|
table: "Orders",
|
|
column: "ProjectId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_OrderUsers_UserId",
|
|
table: "OrderUsers",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ProjectUsers_UserId",
|
|
table: "ProjectUsers",
|
|
column: "UserId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "OrderUsers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ProjectUsers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Orders");
|
|
}
|
|
}
|
|
}
|