From ac769e656b122ff569c3f1534701b71e00fed586 Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 27 Oct 2020 19:21:35 +0800 Subject: Split front and back end. --- .../Migrations/20200229103848_AddPostLocalId.cs | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 BackEnd/Timeline/Migrations/20200229103848_AddPostLocalId.cs (limited to 'BackEnd/Timeline/Migrations/20200229103848_AddPostLocalId.cs') diff --git a/BackEnd/Timeline/Migrations/20200229103848_AddPostLocalId.cs b/BackEnd/Timeline/Migrations/20200229103848_AddPostLocalId.cs new file mode 100644 index 00000000..497b38a1 --- /dev/null +++ b/BackEnd/Timeline/Migrations/20200229103848_AddPostLocalId.cs @@ -0,0 +1,42 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Timeline.Migrations +{ + public partial class AddPostLocalId : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + migrationBuilder.AddColumn( + name: "current_post_local_id", + table: "timelines", + nullable: false, + defaultValue: 0L); + + migrationBuilder.AddColumn( + name: "local_id", + table: "timeline_posts", + nullable: false, + defaultValue: 0L); + + migrationBuilder.Sql(@" +UPDATE timeline_posts +SET local_id = (SELECT COUNT (*) + FROM timeline_posts AS p + WHERE p.timeline = timeline_posts.timeline + AND p.id <= timeline_posts.id); + +UPDATE timelines +SET current_post_local_id = (SELECT COUNT (*) + FROM timeline_posts AS p + WHERE p.timeline = timelines.id); + "); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} -- cgit v1.2.3