From 05ccb4d8f1bbe3fb64e117136b4a89bcfb0b0b33 Mon Sep 17 00:00:00 2001 From: crupest Date: Tue, 27 Oct 2020 19:21:35 +0800 Subject: Split front and back end. --- Timeline/Migrations/20200306110049_AddDataTable.cs | 87 ---------------------- 1 file changed, 87 deletions(-) delete mode 100644 Timeline/Migrations/20200306110049_AddDataTable.cs (limited to 'Timeline/Migrations/20200306110049_AddDataTable.cs') diff --git a/Timeline/Migrations/20200306110049_AddDataTable.cs b/Timeline/Migrations/20200306110049_AddDataTable.cs deleted file mode 100644 index e33bf4c9..00000000 --- a/Timeline/Migrations/20200306110049_AddDataTable.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Timeline.Migrations -{ - public partial class AddDataTable : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "data", - columns: table => new - { - id = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), - tag = table.Column(nullable: false), - data = table.Column(nullable: false), - @ref = table.Column(name: "ref", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_data", x => x.id); - }); - - migrationBuilder.CreateIndex( - name: "IX_data_tag", - table: "data", - column: "tag", - unique: true); - - migrationBuilder.Sql(@" -ALTER TABLE user_avatars - RENAME TO user_avatars_backup; - -CREATE TABLE user_avatars ( - id INTEGER NOT NULL - CONSTRAINT PK_user_avatars PRIMARY KEY AUTOINCREMENT, - data_tag TEXT, - type TEXT, - last_modified TEXT NOT NULL, - user INTEGER NOT NULL, - CONSTRAINT FK_user_avatars_users_user FOREIGN KEY ( - user - ) - REFERENCES users (id) ON DELETE CASCADE -); - -INSERT INTO user_avatars (id, data_tag, type, last_modified, user) - SELECT id, etag, type, last_modified, user FROM user_avatars_backup; - -INSERT OR IGNORE INTO data (tag, data, ref) - SELECT etag, data, 0 FROM user_avatars_backup; - -UPDATE data -SET ref = (SELECT COUNT (*) - FROM user_avatars_backup AS a - WHERE a.etag == data.tag); - -DROP TABLE user_avatars_backup; - -CREATE UNIQUE INDEX IX_user_avatars_user ON user_avatars (user); - "); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "data"); - - migrationBuilder.DropColumn( - name: "data_tag", - table: "user_avatars"); - - migrationBuilder.AddColumn( - name: "data", - table: "user_avatars", - type: "BLOB", - nullable: true); - - migrationBuilder.AddColumn( - name: "etag", - table: "user_avatars", - type: "TEXT", - nullable: true); - } - } -} -- cgit v1.2.3