From 3fa9899e17df4b1012e8b645915ac15022b84f9b Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 21 Feb 2020 11:59:58 +0800 Subject: Migrate to use sqlite. --- .../20200105150407_Initialize.cs | 217 --------------------- 1 file changed, 217 deletions(-) delete mode 100644 Timeline/Migrations/DevelopmentDatabase/20200105150407_Initialize.cs (limited to 'Timeline/Migrations/DevelopmentDatabase/20200105150407_Initialize.cs') diff --git a/Timeline/Migrations/DevelopmentDatabase/20200105150407_Initialize.cs b/Timeline/Migrations/DevelopmentDatabase/20200105150407_Initialize.cs deleted file mode 100644 index c6efaa4b..00000000 --- a/Timeline/Migrations/DevelopmentDatabase/20200105150407_Initialize.cs +++ /dev/null @@ -1,217 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Timeline.Migrations.DevelopmentDatabase -{ - public partial class Initialize : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "users", - columns: table => new - { - id = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), - name = table.Column(maxLength: 26, nullable: false), - password = table.Column(nullable: false), - roles = table.Column(nullable: false), - version = table.Column(nullable: false, defaultValue: 0L) - .Annotation("Sqlite:Autoincrement", true) - }, - constraints: table => - { - table.PrimaryKey("PK_users", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "timelines", - columns: table => new - { - id = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), - name = table.Column(nullable: true), - description = table.Column(nullable: true), - owner = table.Column(nullable: false), - visibility = table.Column(nullable: false), - create_time = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_timelines", x => x.id); - table.ForeignKey( - name: "FK_timelines_users_owner", - column: x => x.owner, - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "user_avatars", - columns: table => new - { - id = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), - data = table.Column(nullable: true), - type = table.Column(nullable: true), - etag = table.Column(maxLength: 30, nullable: true), - last_modified = table.Column(nullable: false), - UserId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_user_avatars", x => x.id); - table.ForeignKey( - name: "FK_user_avatars_users_UserId", - column: x => x.UserId, - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "user_details", - columns: table => new - { - id = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), - nickname = table.Column(maxLength: 26, nullable: true), - UserId = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_user_details", x => x.id); - table.ForeignKey( - name: "FK_user_details_users_UserId", - column: x => x.UserId, - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "timeline_members", - columns: table => new - { - id = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), - user = table.Column(nullable: false), - timeline = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_timeline_members", x => x.id); - table.ForeignKey( - name: "FK_timeline_members_timelines_timeline", - column: x => x.timeline, - principalTable: "timelines", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_timeline_members_users_user", - column: x => x.user, - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "timeline_posts", - columns: table => new - { - id = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), - timeline = table.Column(nullable: false), - author = table.Column(nullable: false), - content = table.Column(nullable: true), - time = table.Column(nullable: false), - last_updated = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_timeline_posts", x => x.id); - table.ForeignKey( - name: "FK_timeline_posts_users_author", - column: x => x.author, - principalTable: "users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_timeline_posts_timelines_timeline", - column: x => x.timeline, - principalTable: "timelines", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_timeline_members_timeline", - table: "timeline_members", - column: "timeline"); - - migrationBuilder.CreateIndex( - name: "IX_timeline_members_user", - table: "timeline_members", - column: "user"); - - migrationBuilder.CreateIndex( - name: "IX_timeline_posts_author", - table: "timeline_posts", - column: "author"); - - migrationBuilder.CreateIndex( - name: "IX_timeline_posts_timeline", - table: "timeline_posts", - column: "timeline"); - - migrationBuilder.CreateIndex( - name: "IX_timelines_owner", - table: "timelines", - column: "owner"); - - migrationBuilder.CreateIndex( - name: "IX_user_avatars_UserId", - table: "user_avatars", - column: "UserId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_user_details_UserId", - table: "user_details", - column: "UserId", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_users_name", - table: "users", - column: "name", - unique: true); - - // Add a init user. Username is "administrator". Password is "crupest". - migrationBuilder.InsertData("users", new string[] { "name", "password", "roles" }, - new object[] { "administrator", "AQAAAAEAACcQAAAAENsspZrk8Wo+UuMyg6QuWJsNvRg6gVu4K/TumVod3h9GVLX9zDVuQQds3o7V8QWJ2w==", "user,admin" }); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "timeline_members"); - - migrationBuilder.DropTable( - name: "timeline_posts"); - - migrationBuilder.DropTable( - name: "user_avatars"); - - migrationBuilder.DropTable( - name: "user_details"); - - migrationBuilder.DropTable( - name: "timelines"); - - migrationBuilder.DropTable( - name: "users"); - } - } -} -- cgit v1.2.3