215 lines
8.5 KiB
C#
215 lines
8.5 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace BLAIzor.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class CollectionAdministrationUpdate : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropColumn(
|
|
name: "PointId",
|
|
table: "MenuItems");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "QdrantPointId",
|
|
table: "MenuItems");
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "ContentGroupId",
|
|
table: "MenuItems",
|
|
type: "int",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "ParentId",
|
|
table: "MenuItems",
|
|
type: "int",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "Slug",
|
|
table: "MenuItems",
|
|
type: "nvarchar(max)",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ContentGroups",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
SiteInfoId = table.Column<int>(type: "int", nullable: false),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Slug = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Type = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
VectorSize = table.Column<int>(type: "int", nullable: false),
|
|
EmbeddingModel = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Version = table.Column<int>(type: "int", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
LastUpdated = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ContentGroups", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ContentGroups_SiteInfos_SiteInfoId",
|
|
column: x => x.SiteInfoId,
|
|
principalTable: "SiteInfos",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ContentItems",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ContentGroupId = table.Column<int>(type: "int", nullable: false),
|
|
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Content = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Language = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Tags = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
IsPublished = table.Column<bool>(type: "bit", nullable: false),
|
|
Version = table.Column<int>(type: "int", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
LastUpdated = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ContentItems", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ContentItems_ContentGroups_ContentGroupId",
|
|
column: x => x.ContentGroupId,
|
|
principalTable: "ContentGroups",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ContentChunks",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ContentItemId = table.Column<int>(type: "int", nullable: false),
|
|
QdrantPointId = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
ChunkIndex = table.Column<int>(type: "int", nullable: false),
|
|
VectorHash = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ContentChunks", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ContentChunks_ContentItems_ContentItemId",
|
|
column: x => x.ContentItemId,
|
|
principalTable: "ContentItems",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_MenuItems_ContentGroupId",
|
|
table: "MenuItems",
|
|
column: "ContentGroupId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_MenuItems_ParentId",
|
|
table: "MenuItems",
|
|
column: "ParentId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ContentChunks_ContentItemId",
|
|
table: "ContentChunks",
|
|
column: "ContentItemId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ContentGroups_SiteInfoId",
|
|
table: "ContentGroups",
|
|
column: "SiteInfoId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ContentItems_ContentGroupId",
|
|
table: "ContentItems",
|
|
column: "ContentGroupId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_MenuItems_ContentGroups_ContentGroupId",
|
|
table: "MenuItems",
|
|
column: "ContentGroupId",
|
|
principalTable: "ContentGroups",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.NoAction);
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_MenuItems_MenuItems_ParentId",
|
|
table: "MenuItems",
|
|
column: "ParentId",
|
|
principalTable: "MenuItems",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_MenuItems_ContentGroups_ContentGroupId",
|
|
table: "MenuItems");
|
|
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_MenuItems_MenuItems_ParentId",
|
|
table: "MenuItems");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ContentChunks");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ContentItems");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ContentGroups");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_MenuItems_ContentGroupId",
|
|
table: "MenuItems");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_MenuItems_ParentId",
|
|
table: "MenuItems");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "ContentGroupId",
|
|
table: "MenuItems");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "ParentId",
|
|
table: "MenuItems");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "Slug",
|
|
table: "MenuItems");
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "PointId",
|
|
table: "MenuItems",
|
|
type: "int",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.AddColumn<Guid>(
|
|
name: "QdrantPointId",
|
|
table: "MenuItems",
|
|
type: "uniqueidentifier",
|
|
nullable: true);
|
|
}
|
|
}
|
|
}
|