using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Data.Migrations
{
///
public partial class AddNotesAndNoteHistory : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Notes",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Title = table.Column(type: "TEXT", maxLength: 200, nullable: false),
Content = table.Column(type: "TEXT", nullable: true),
CreatedAt = table.Column(type: "TEXT", nullable: false),
UpdatedAt = table.Column(type: "TEXT", nullable: false),
CreatedBy = table.Column(type: "TEXT", maxLength: 255, nullable: true),
LastModifiedBy = table.Column(type: "TEXT", maxLength: 255, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Notes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "NoteHistories",
columns: table => new
{
Id = table.Column(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
NoteId = table.Column(type: "INTEGER", nullable: false),
Title = table.Column(type: "TEXT", maxLength: 200, nullable: false),
Content = table.Column(type: "TEXT", nullable: true),
ModifiedBy = table.Column(type: "TEXT", maxLength: 255, nullable: true),
ModifiedAt = table.Column(type: "TEXT", nullable: false),
ChangeType = table.Column(type: "TEXT", maxLength: 50, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_NoteHistories", x => x.Id);
table.ForeignKey(
name: "FK_NoteHistories_Notes_NoteId",
column: x => x.NoteId,
principalTable: "Notes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_NoteHistories_ModifiedAt",
table: "NoteHistories",
column: "ModifiedAt");
migrationBuilder.CreateIndex(
name: "IX_NoteHistories_NoteId",
table: "NoteHistories",
column: "NoteId");
migrationBuilder.CreateIndex(
name: "IX_NoteHistories_NoteId_ModifiedAt",
table: "NoteHistories",
columns: new[] { "NoteId", "ModifiedAt" });
migrationBuilder.CreateIndex(
name: "IX_Notes_CreatedAt",
table: "Notes",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_Notes_Title",
table: "Notes",
column: "Title");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "NoteHistories");
migrationBuilder.DropTable(
name: "Notes");
}
}
}