From 118fb9b15ba62837a0befaad0aaea156b0488aea Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 12 Feb 2021 22:16:04 +0800 Subject: feat: Add post data database schema migration. --- .../Timeline/Migrations/20210212141443_PostData.cs | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 BackEnd/Timeline/Migrations/20210212141443_PostData.cs (limited to 'BackEnd/Timeline/Migrations/20210212141443_PostData.cs') diff --git a/BackEnd/Timeline/Migrations/20210212141443_PostData.cs b/BackEnd/Timeline/Migrations/20210212141443_PostData.cs new file mode 100644 index 00000000..5a0c6179 --- /dev/null +++ b/BackEnd/Timeline/Migrations/20210212141443_PostData.cs @@ -0,0 +1,90 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Timeline.Migrations +{ + public partial class PostData : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "content_type", + table: "timeline_posts", + type: "TEXT", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT"); + + migrationBuilder.AddColumn( + name: "deleted", + table: "timeline_posts", + type: "INTEGER", + nullable: false, + defaultValue: false); + + migrationBuilder.CreateTable( + name: "migrations", + columns: table => new + { + id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + name = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_migrations", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "timeline_post_data", + columns: table => new + { + id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + post = table.Column(type: "INTEGER", nullable: false), + index = table.Column(type: "INTEGER", nullable: false), + kind = table.Column(type: "TEXT", nullable: false), + data_tag = table.Column(type: "TEXT", nullable: false), + last_updated = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_timeline_post_data", x => x.id); + table.ForeignKey( + name: "FK_timeline_post_data_timeline_posts_post", + column: x => x.post, + principalTable: "timeline_posts", + principalColumn: "id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_timeline_post_data_post", + table: "timeline_post_data", + column: "post"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "migrations"); + + migrationBuilder.DropTable( + name: "timeline_post_data"); + + migrationBuilder.DropColumn( + name: "deleted", + table: "timeline_posts"); + + migrationBuilder.AlterColumn( + name: "content_type", + table: "timeline_posts", + type: "TEXT", + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + } + } +} -- cgit v1.2.3