using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Blahblah.FlowerStory.Server.Migrations { /// public partial class InitialDb : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "tokens", columns: table => new { tid = table.Column(type: "TEXT", nullable: false), uid = table.Column(type: "INTEGER", nullable: false), logondate = table.Column(type: "INTEGER", nullable: false), activedate = table.Column(type: "INTEGER", nullable: false), expiredate = table.Column(type: "INTEGER", nullable: false), expiresecs = table.Column(type: "INTEGER", nullable: false), verifycode = table.Column(type: "TEXT", nullable: true), clientapp = table.Column(type: "TEXT", nullable: true), deviceid = table.Column(type: "TEXT", nullable: true), clientagent = table.Column(type: "TEXT", nullable: true) }, constraints: table => { table.PrimaryKey("PK_tokens", x => x.tid); }); migrationBuilder.CreateTable( name: "users", columns: table => new { uid = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), id = table.Column(type: "TEXT", nullable: false), password = table.Column(type: "TEXT", nullable: false), level = table.Column(type: "INTEGER", nullable: false), regdate = table.Column(type: "INTEGER", nullable: false), activedate = table.Column(type: "INTEGER", nullable: true), name = table.Column(type: "TEXT", nullable: false), email = table.Column(type: "TEXT", nullable: true), mobile = table.Column(type: "TEXT", nullable: true), avatar = table.Column(type: "BLOB", nullable: true) }, constraints: table => { table.PrimaryKey("PK_users", x => x.uid); }); migrationBuilder.CreateTable( name: "flowers", columns: table => new { fid = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), uid = table.Column(type: "INTEGER", nullable: false), categoryid = table.Column(type: "INTEGER", nullable: false), name = table.Column(type: "TEXT", nullable: false), datebuy = table.Column(type: "INTEGER", nullable: false), cost = table.Column(type: "real", nullable: true), purchase = table.Column(type: "TEXT", nullable: true), memo = table.Column(type: "TEXT", nullable: true), latitude = table.Column(type: "REAL", nullable: true), longitude = table.Column(type: "REAL", nullable: true) }, constraints: table => { table.PrimaryKey("PK_flowers", x => x.fid); table.ForeignKey( name: "FK_flowers_users_uid", column: x => x.uid, principalTable: "users", principalColumn: "uid", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "records", columns: table => new { rid = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), uid = table.Column(type: "INTEGER", nullable: false), fid = table.Column(type: "INTEGER", nullable: false), eid = table.Column(type: "INTEGER", nullable: false), date = table.Column(type: "INTEGER", nullable: false), byuid = table.Column(type: "INTEGER", nullable: true), byname = table.Column(type: "TEXT", nullable: true), memo = table.Column(type: "TEXT", nullable: true), latitude = table.Column(type: "REAL", nullable: true), longitude = table.Column(type: "REAL", nullable: true) }, constraints: table => { table.PrimaryKey("PK_records", x => x.rid); table.ForeignKey( name: "FK_records_flowers_fid", column: x => x.fid, principalTable: "flowers", principalColumn: "fid", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_records_users_uid", column: x => x.uid, principalTable: "users", principalColumn: "uid", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "photos", columns: table => new { pid = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), fid = table.Column(type: "INTEGER", nullable: true), rid = table.Column(type: "INTEGER", nullable: true), filetype = table.Column(type: "TEXT", nullable: false), filename = table.Column(type: "TEXT", nullable: false), path = table.Column(type: "TEXT", nullable: false), dateupload = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_photos", x => x.pid); table.ForeignKey( name: "FK_photos_flowers_fid", column: x => x.fid, principalTable: "flowers", principalColumn: "fid"); table.ForeignKey( name: "FK_photos_records_rid", column: x => x.rid, principalTable: "records", principalColumn: "rid"); }); migrationBuilder.CreateIndex( name: "IX_flowers_uid", table: "flowers", column: "uid"); migrationBuilder.CreateIndex( name: "IX_photos_fid", table: "photos", column: "fid"); migrationBuilder.CreateIndex( name: "IX_photos_rid", table: "photos", column: "rid"); migrationBuilder.CreateIndex( name: "IX_records_fid", table: "records", column: "fid"); migrationBuilder.CreateIndex( name: "IX_records_uid", table: "records", column: "uid"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "photos"); migrationBuilder.DropTable( name: "tokens"); migrationBuilder.DropTable( name: "records"); migrationBuilder.DropTable( name: "flowers"); migrationBuilder.DropTable( name: "users"); } } }