using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using NpgsqlTypes; #nullable disable namespace OpenArchival.DataAccess.Migrations { /// public partial class BlogPostModel : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "BlogPosts", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Title = table.Column(type: "text", nullable: false), Content = table.Column(type: "text", nullable: false), CreationTime = table.Column(type: "timestamp with time zone", nullable: false), ModifiedTime = table.Column(type: "timestamp with time zone", nullable: false), ContentSearchVector = table.Column(type: "tsvector", nullable: false) .Annotation("Npgsql:TsVectorConfig", "english") .Annotation("Npgsql:TsVectorProperties", new[] { "Content" }), TitleSearchVector = table.Column(type: "tsvector", nullable: false) .Annotation("Npgsql:TsVectorConfig", "english") .Annotation("Npgsql:TsVectorProperties", new[] { "Title" }), TagsSearchString = table.Column(type: "text", nullable: false), TagsSearchVector = table.Column(type: "tsvector", nullable: false) .Annotation("Npgsql:TsVectorConfig", "english") .Annotation("Npgsql:TsVectorProperties", new[] { "TagsSearchString" }), AllSearchString = table.Column(type: "text", nullable: false), AllSearchVector = table.Column(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(type: "integer", nullable: false), BlogPostsId = table.Column(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(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false), BlogPostId = table.Column(type: "integer", nullable: true), BlogPostTagId = table.Column(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"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "ArtifactGroupingBlogPost"); migrationBuilder.DropTable( name: "BlogPostTags"); migrationBuilder.DropTable( name: "BlogPosts"); } } }