using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace BLAIzor.Migrations { /// public partial class CollectionAdministrationUpdate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropColumn( name: "PointId", table: "MenuItems"); migrationBuilder.DropColumn( name: "QdrantPointId", table: "MenuItems"); migrationBuilder.AddColumn( name: "ContentGroupId", table: "MenuItems", type: "int", nullable: true); migrationBuilder.AddColumn( name: "ParentId", table: "MenuItems", type: "int", nullable: true); migrationBuilder.AddColumn( name: "Slug", table: "MenuItems", type: "nvarchar(max)", nullable: true); migrationBuilder.CreateTable( name: "ContentGroups", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), SiteInfoId = table.Column(type: "int", nullable: false), Name = table.Column(type: "nvarchar(max)", nullable: false), Slug = table.Column(type: "nvarchar(max)", nullable: false), Type = table.Column(type: "nvarchar(max)", nullable: false), VectorSize = table.Column(type: "int", nullable: false), EmbeddingModel = table.Column(type: "nvarchar(max)", nullable: false), Version = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), LastUpdated = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ContentGroupId = table.Column(type: "int", nullable: false), Title = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: false), Content = table.Column(type: "nvarchar(max)", nullable: false), Language = table.Column(type: "nvarchar(max)", nullable: false), Tags = table.Column(type: "nvarchar(max)", nullable: false), IsPublished = table.Column(type: "bit", nullable: false), Version = table.Column(type: "int", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), LastUpdated = table.Column(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(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ContentItemId = table.Column(type: "int", nullable: false), QdrantPointId = table.Column(type: "nvarchar(max)", nullable: false), ChunkIndex = table.Column(type: "int", nullable: false), VectorHash = table.Column(type: "nvarchar(max)", nullable: true), CreatedAt = table.Column(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); } /// 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( name: "PointId", table: "MenuItems", type: "int", nullable: false, defaultValue: 0); migrationBuilder.AddColumn( name: "QdrantPointId", table: "MenuItems", type: "uniqueidentifier", nullable: true); } } }