using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace TaskTracker.Infrastructure.Migrations
{
///
public partial class InitialCreate : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AppMappings",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Pattern = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false),
MatchType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false),
Category = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false),
FriendlyName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AppMappings", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Tasks",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false),
Description = table.Column(type: "nvarchar(max)", nullable: true),
Status = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false),
Category = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true),
CreatedAt = table.Column(type: "datetime2", nullable: false),
StartedAt = table.Column(type: "datetime2", nullable: true),
CompletedAt = table.Column(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Tasks", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ContextEvents",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
WorkTaskId = table.Column(type: "int", nullable: true),
Source = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false),
AppName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false),
WindowTitle = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: false),
Url = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true),
Timestamp = table.Column(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ContextEvents", x => x.Id);
table.ForeignKey(
name: "FK_ContextEvents_Tasks_WorkTaskId",
column: x => x.WorkTaskId,
principalTable: "Tasks",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Notes",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
WorkTaskId = table.Column(type: "int", nullable: false),
Content = table.Column(type: "nvarchar(max)", nullable: false),
Type = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Notes", x => x.Id);
table.ForeignKey(
name: "FK_Notes_Tasks_WorkTaskId",
column: x => x.WorkTaskId,
principalTable: "Tasks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "AppMappings",
columns: new[] { "Id", "Category", "FriendlyName", "MatchType", "Pattern" },
values: new object[,]
{
{ 1, "Engineering", "SolidWorks", "ProcessName", "SLDWORKS" },
{ 2, "Email", "Outlook", "ProcessName", "OUTLOOK" },
{ 3, "General", "Notepad", "ProcessName", "notepad" },
{ 4, "LaserCutting", "PEP System", "UrlContains", "pep" },
{ 5, "Engineering", "SolidWorks", "TitleContains", "solidworks" }
});
migrationBuilder.CreateIndex(
name: "IX_ContextEvents_Timestamp",
table: "ContextEvents",
column: "Timestamp");
migrationBuilder.CreateIndex(
name: "IX_ContextEvents_WorkTaskId",
table: "ContextEvents",
column: "WorkTaskId");
migrationBuilder.CreateIndex(
name: "IX_Notes_WorkTaskId",
table: "Notes",
column: "WorkTaskId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AppMappings");
migrationBuilder.DropTable(
name: "ContextEvents");
migrationBuilder.DropTable(
name: "Notes");
migrationBuilder.DropTable(
name: "Tasks");
}
}
}