mirror of
https://github.com/rjNemo/ticket_manager
synced 2026-06-06 00:36:39 +00:00
289 lines
12 KiB
C#
289 lines
12 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
namespace TicketManager.Migrations
|
|
{
|
|
public partial class Migration1 : Migration
|
|
{
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "AppUsers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(nullable: false),
|
|
FirstName = table.Column<string>(maxLength: 50, nullable: false),
|
|
LastName = table.Column<string>(maxLength: 50, nullable: false),
|
|
Presentation = table.Column<string>(maxLength: 200, nullable: true),
|
|
Email = table.Column<string>(nullable: true),
|
|
Phone = table.Column<string>(nullable: true),
|
|
CreationDate = table.Column<DateTime>(nullable: false),
|
|
Picture = table.Column<string>(nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AppUsers", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Projects",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Title = table.Column<string>(maxLength: 50, nullable: false),
|
|
Description = table.Column<string>(maxLength: 200, nullable: true),
|
|
CreationDate = table.Column<DateTime>(nullable: false),
|
|
EndingDate = table.Column<DateTime>(nullable: false),
|
|
Status = table.Column<int>(nullable: false),
|
|
ManagerId = table.Column<Guid>(nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Projects", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Projects_AppUsers_ManagerId",
|
|
column: x => x.ManagerId,
|
|
principalTable: "AppUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Assignments",
|
|
columns: table => new
|
|
{
|
|
UserId = table.Column<Guid>(nullable: false),
|
|
ProjectId = table.Column<int>(nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Assignments", x => new { x.ProjectId, x.UserId });
|
|
table.ForeignKey(
|
|
name: "FK_Assignments_Projects_ProjectId",
|
|
column: x => x.ProjectId,
|
|
principalTable: "Projects",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Assignments_AppUsers_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "AppUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Tickets",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Title = table.Column<string>(maxLength: 100, nullable: false),
|
|
Description = table.Column<string>(maxLength: 100, nullable: true),
|
|
CreationDate = table.Column<DateTime>(nullable: false),
|
|
EndingDate = table.Column<DateTime>(nullable: false),
|
|
Status = table.Column<int>(nullable: false),
|
|
Impact = table.Column<int>(nullable: false),
|
|
Difficulty = table.Column<int>(nullable: false),
|
|
Category = table.Column<int>(nullable: false),
|
|
CreatorId = table.Column<Guid>(nullable: false),
|
|
ProjectId = table.Column<int>(nullable: true),
|
|
AppUserId = table.Column<Guid>(nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Tickets", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Tickets_AppUsers_AppUserId",
|
|
column: x => x.AppUserId,
|
|
principalTable: "AppUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_Tickets_Projects_ProjectId",
|
|
column: x => x.ProjectId,
|
|
principalTable: "Projects",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Activities",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Description = table.Column<string>(nullable: true),
|
|
UpdateDate = table.Column<DateTime>(nullable: false),
|
|
ActivityType = table.Column<int>(nullable: false),
|
|
TaskId = table.Column<int>(nullable: false),
|
|
AppUserId = table.Column<Guid>(nullable: true),
|
|
ProjectId = table.Column<int>(nullable: true),
|
|
TicketId = table.Column<int>(nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Activities", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Activities_AppUsers_AppUserId",
|
|
column: x => x.AppUserId,
|
|
principalTable: "AppUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_Activities_Projects_ProjectId",
|
|
column: x => x.ProjectId,
|
|
principalTable: "Projects",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_Activities_Tickets_TicketId",
|
|
column: x => x.TicketId,
|
|
principalTable: "Tickets",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Files",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
FileName = table.Column<string>(nullable: true),
|
|
Location = table.Column<string>(nullable: true),
|
|
Description = table.Column<string>(nullable: true),
|
|
Size = table.Column<int>(nullable: false),
|
|
Format = table.Column<string>(nullable: true),
|
|
AddedById = table.Column<Guid>(nullable: true),
|
|
UserId = table.Column<int>(nullable: false),
|
|
ProjectId = table.Column<int>(nullable: true),
|
|
TicketId = table.Column<int>(nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Files", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Files_AppUsers_AddedById",
|
|
column: x => x.AddedById,
|
|
principalTable: "AppUsers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_Files_Projects_ProjectId",
|
|
column: x => x.ProjectId,
|
|
principalTable: "Projects",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
table.ForeignKey(
|
|
name: "FK_Files_Tickets_TicketId",
|
|
column: x => x.TicketId,
|
|
principalTable: "Tickets",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Notes",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
Title = table.Column<string>(nullable: true),
|
|
Description = table.Column<string>(nullable: true),
|
|
CreationDate = table.Column<DateTime>(nullable: false),
|
|
TicketId = table.Column<int>(nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Notes", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Notes_Tickets_TicketId",
|
|
column: x => x.TicketId,
|
|
principalTable: "Tickets",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Activities_AppUserId",
|
|
table: "Activities",
|
|
column: "AppUserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Activities_ProjectId",
|
|
table: "Activities",
|
|
column: "ProjectId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Activities_TicketId",
|
|
table: "Activities",
|
|
column: "TicketId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Assignments_UserId",
|
|
table: "Assignments",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Files_AddedById",
|
|
table: "Files",
|
|
column: "AddedById");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Files_ProjectId",
|
|
table: "Files",
|
|
column: "ProjectId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Files_TicketId",
|
|
table: "Files",
|
|
column: "TicketId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Notes_TicketId",
|
|
table: "Notes",
|
|
column: "TicketId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Projects_ManagerId",
|
|
table: "Projects",
|
|
column: "ManagerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Tickets_AppUserId",
|
|
table: "Tickets",
|
|
column: "AppUserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Tickets_ProjectId",
|
|
table: "Tickets",
|
|
column: "ProjectId");
|
|
}
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Activities");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Assignments");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Files");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Notes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Tickets");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Projects");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "AppUsers");
|
|
}
|
|
}
|
|
}
|