diff options
author | crupest <crupest@outlook.com> | 2020-06-14 00:21:25 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-06-14 00:21:25 +0800 |
commit | 4cfb50d40384e5dea1805f8d6fc5ab38cd32d93b (patch) | |
tree | c9395a11fa6ccefe6a03e81c7b837e28b2e3e97a /Timeline/Migrations/20200613161127_AddTimelineUniqueId.cs | |
parent | 2f8ffdb2db682b1c1407313816def20fde58d35f (diff) | |
download | timeline-4cfb50d40384e5dea1805f8d6fc5ab38cd32d93b.tar.gz timeline-4cfb50d40384e5dea1805f8d6fc5ab38cd32d93b.tar.bz2 timeline-4cfb50d40384e5dea1805f8d6fc5ab38cd32d93b.zip |
refactor(back): Use a better way to handle unique id in timeline.
Diffstat (limited to 'Timeline/Migrations/20200613161127_AddTimelineUniqueId.cs')
-rw-r--r-- | Timeline/Migrations/20200613161127_AddTimelineUniqueId.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Timeline/Migrations/20200613161127_AddTimelineUniqueId.cs b/Timeline/Migrations/20200613161127_AddTimelineUniqueId.cs new file mode 100644 index 00000000..badd33ea --- /dev/null +++ b/Timeline/Migrations/20200613161127_AddTimelineUniqueId.cs @@ -0,0 +1,37 @@ +using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace Timeline.Migrations
+{
+ public partial class AddTimelineUniqueId : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.Sql(
+@"
+ALTER TABLE timelines RENAME TO timelines_backup;
+
+CREATE TABLE timelines (
+ id INTEGER NOT NULL CONSTRAINT PK_timelines PRIMARY KEY AUTOINCREMENT,
+ unique_id BLOB NOT NULL DEFAULT (randomblob(16)),
+ name TEXT NULL,
+ description TEXT NULL,
+ owner INTEGER NOT NULL,
+ visibility INTEGER NOT NULL,
+ create_time TEXT NOT NULL, current_post_local_id INTEGER NOT NULL DEFAULT 0,
+ CONSTRAINT FK_timelines_users_owner FOREIGN KEY (owner) REFERENCES users (id) ON DELETE CASCADE
+);
+
+INSERT INTO timelines (id, name, description, owner, visibility, create_time)
+ SELECT id, name, description, owner, visibility, create_time FROM timelines_backup;
+
+DROP TABLE timelines_backup;
+"
+ );
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ }
+ }
+}
|