InkForge/shared/migrations/InkForge.Sqlite/Migrations/20240401_Initial.cs

93 lines
3.4 KiB
C#
Raw Normal View History

2024-02-07 22:44:37 +01:00
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace InkForge.Sqlite.Migrations
{
/// <inheritdoc />
2024-05-02 21:44:13 +02:00
public partial class _20240401_Initial : Migration
2024-02-07 22:44:37 +01:00
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Blobs",
columns: table => new
{
2024-05-02 21:44:13 +02:00
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Value = table.Column<byte[]>(type: "BLOB", nullable: false)
2024-02-07 22:44:37 +01:00
},
constraints: table =>
{
table.PrimaryKey("PK_Blobs", x => x.Id);
});
migrationBuilder.CreateTable(
2024-05-02 21:44:13 +02:00
name: "Metadata",
2024-02-07 22:44:37 +01:00
columns: table => new
{
2024-05-02 21:44:13 +02:00
Id = table.Column<string>(type: "TEXT", nullable: false),
Value = table.Column<string>(type: "TEXT", nullable: false)
2024-02-07 22:44:37 +01:00
},
constraints: table =>
{
2024-05-02 21:44:13 +02:00
table.PrimaryKey("PK_Metadata", x => x.Id);
2024-02-07 22:44:37 +01:00
});
migrationBuilder.CreateTable(
2024-05-02 21:44:13 +02:00
name: "Notes",
2024-02-07 22:44:37 +01:00
columns: table => new
{
2024-05-02 21:44:13 +02:00
Id = table.Column<int>(type: "INTEGER", nullable: false),
2024-02-07 22:44:37 +01:00
Value_Created = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
2024-05-02 21:44:13 +02:00
Value_ContentId = table.Column<int>(type: "INTEGER", nullable: false),
Value_Deleted = table.Column<DateTimeOffset>(type: "TEXT", nullable: true),
2024-02-07 22:44:37 +01:00
Value_Name = table.Column<string>(type: "TEXT", nullable: false),
Value_Updated = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
2024-05-02 21:44:13 +02:00
ParentId = table.Column<int>(type: "INTEGER", nullable: true)
2024-02-07 22:44:37 +01:00
},
constraints: table =>
{
2024-05-02 21:44:13 +02:00
table.PrimaryKey("PK_Notes", x => x.Id);
2024-02-07 22:44:37 +01:00
table.ForeignKey(
2024-05-02 21:44:13 +02:00
name: "FK_Notes_Blobs_Value_ContentId",
2024-02-07 22:44:37 +01:00
column: x => x.Value_ContentId,
principalTable: "Blobs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
2024-05-02 21:44:13 +02:00
name: "FK_Notes_Notes_ParentId",
column: x => x.ParentId,
2024-02-07 22:44:37 +01:00
principalTable: "Notes",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
2024-05-02 21:44:13 +02:00
name: "IX_Notes_ParentId",
2024-02-07 22:44:37 +01:00
table: "Notes",
2024-05-02 21:44:13 +02:00
column: "ParentId");
2024-02-07 22:44:37 +01:00
migrationBuilder.CreateIndex(
2024-05-02 21:44:13 +02:00
name: "IX_Notes_Value_ContentId",
table: "Notes",
column: "Value_ContentId",
2024-02-07 22:44:37 +01:00
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
2024-05-02 21:44:13 +02:00
name: "Metadata");
2024-02-07 22:44:37 +01:00
migrationBuilder.DropTable(
name: "Notes");
migrationBuilder.DropTable(
name: "Blobs");
}
}
}