Files
openarchival/OpenArchival.DataAccess/Migrations/20251020174037_BlogPostModel.cs

149 lines
6.8 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using NpgsqlTypes;
#nullable disable
namespace OpenArchival.DataAccess.Migrations
{
/// <inheritdoc />
public partial class BlogPostModel : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "BlogPosts",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Title = table.Column<string>(type: "text", nullable: false),
Content = table.Column<string>(type: "text", nullable: false),
CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
ModifiedTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
ContentSearchVector = table.Column<NpgsqlTsVector>(type: "tsvector", nullable: false)
.Annotation("Npgsql:TsVectorConfig", "english")
.Annotation("Npgsql:TsVectorProperties", new[] { "Content" }),
TitleSearchVector = table.Column<NpgsqlTsVector>(type: "tsvector", nullable: false)
.Annotation("Npgsql:TsVectorConfig", "english")
.Annotation("Npgsql:TsVectorProperties", new[] { "Title" }),
TagsSearchString = table.Column<string>(type: "text", nullable: false),
TagsSearchVector = table.Column<NpgsqlTsVector>(type: "tsvector", nullable: false)
.Annotation("Npgsql:TsVectorConfig", "english")
.Annotation("Npgsql:TsVectorProperties", new[] { "TagsSearchString" }),
AllSearchString = table.Column<string>(type: "text", nullable: false),
AllSearchVector = table.Column<NpgsqlTsVector>(type: "tsvector", nullable: false)
.Annotation("Npgsql:TsVectorConfig", "english")
.Annotation("Npgsql:TsVectorProperties", new[] { "AllSearchString" })
},
constraints: table =>
{
table.PrimaryKey("PK_BlogPosts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ArtifactGroupingBlogPost",
columns: table => new
{
ArtifactGroupingsId = table.Column<int>(type: "integer", nullable: false),
BlogPostsId = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ArtifactGroupingBlogPost", x => new { x.ArtifactGroupingsId, x.BlogPostsId });
table.ForeignKey(
name: "FK_ArtifactGroupingBlogPost_ArtifactGroupings_ArtifactGrouping~",
column: x => x.ArtifactGroupingsId,
principalTable: "ArtifactGroupings",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ArtifactGroupingBlogPost_BlogPosts_BlogPostsId",
column: x => x.BlogPostsId,
principalTable: "BlogPosts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "BlogPostTags",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
BlogPostId = table.Column<int>(type: "integer", nullable: true),
BlogPostTagId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_BlogPostTags", x => x.Id);
table.ForeignKey(
name: "FK_BlogPostTags_BlogPostTags_BlogPostTagId",
column: x => x.BlogPostTagId,
principalTable: "BlogPostTags",
principalColumn: "Id");
table.ForeignKey(
name: "FK_BlogPostTags_BlogPosts_BlogPostId",
column: x => x.BlogPostId,
principalTable: "BlogPosts",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_ArtifactGroupingBlogPost_BlogPostsId",
table: "ArtifactGroupingBlogPost",
column: "BlogPostsId");
migrationBuilder.CreateIndex(
name: "IX_BlogPosts_AllSearchVector",
table: "BlogPosts",
column: "AllSearchVector")
.Annotation("Npgsql:IndexMethod", "GIN");
migrationBuilder.CreateIndex(
name: "IX_BlogPosts_ContentSearchVector",
table: "BlogPosts",
column: "ContentSearchVector")
.Annotation("Npgsql:IndexMethod", "GIN");
migrationBuilder.CreateIndex(
name: "IX_BlogPosts_TagsSearchVector",
table: "BlogPosts",
column: "TagsSearchVector")
.Annotation("Npgsql:IndexMethod", "GIN");
migrationBuilder.CreateIndex(
name: "IX_BlogPosts_TitleSearchVector",
table: "BlogPosts",
column: "TitleSearchVector")
.Annotation("Npgsql:IndexMethod", "GIN");
migrationBuilder.CreateIndex(
name: "IX_BlogPostTags_BlogPostId",
table: "BlogPostTags",
column: "BlogPostId");
migrationBuilder.CreateIndex(
name: "IX_BlogPostTags_BlogPostTagId",
table: "BlogPostTags",
column: "BlogPostTagId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ArtifactGroupingBlogPost");
migrationBuilder.DropTable(
name: "BlogPostTags");
migrationBuilder.DropTable(
name: "BlogPosts");
}
}
}