using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Flaro.Data.Migrations
{
///
public partial class Initial : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AuthCodes",
columns: table => new
{
Id = table.Column(type: "TEXT", nullable: false),
Code = table.Column(type: "TEXT", maxLength: 16, nullable: false),
HandleFingerprint = table.Column(type: "TEXT", maxLength: 64, nullable: false),
DeviceName = table.Column(type: "TEXT", maxLength: 128, nullable: false),
DeviceId = table.Column(type: "TEXT", maxLength: 128, nullable: false),
CreatedAt = table.Column(type: "INTEGER", nullable: false),
ExpiresAt = table.Column(type: "INTEGER", nullable: false),
ApprovedByUserId = table.Column(type: "TEXT", nullable: true),
ConsumedAt = table.Column(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AuthCodes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Libraries",
columns: table => new
{
Id = table.Column(type: "TEXT", nullable: false),
Name = table.Column(type: "TEXT", maxLength: 128, nullable: false),
Kind = table.Column(type: "TEXT", maxLength: 32, nullable: false),
Path = table.Column(type: "TEXT", maxLength: 1024, nullable: false),
CreatedAt = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Libraries", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Settings",
columns: table => new
{
Key = table.Column(type: "TEXT", maxLength: 128, nullable: false),
Value = table.Column(type: "TEXT", maxLength: 4096, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Settings", x => x.Key);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column(type: "TEXT", nullable: false),
UserName = table.Column(type: "TEXT", maxLength: 64, nullable: false, collation: "NOCASE"),
PasswordHash = table.Column(type: "TEXT", maxLength: 256, nullable: false),
IsAdministrator = table.Column(type: "INTEGER", nullable: false),
CreatedAt = table.Column(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DeviceTokens",
columns: table => new
{
Id = table.Column(type: "TEXT", nullable: false),
UserId = table.Column(type: "TEXT", nullable: false),
TokenFingerprint = table.Column(type: "TEXT", maxLength: 64, nullable: false),
DeviceName = table.Column(type: "TEXT", maxLength: 128, nullable: false),
DeviceId = table.Column(type: "TEXT", maxLength: 128, nullable: false),
CreatedAt = table.Column(type: "INTEGER", nullable: false),
LastSeenAt = table.Column(type: "INTEGER", nullable: false),
RevokedAt = table.Column(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceTokens", x => x.Id);
table.ForeignKey(
name: "FK_DeviceTokens_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AuthCodes_Code",
table: "AuthCodes",
column: "Code");
migrationBuilder.CreateIndex(
name: "IX_AuthCodes_HandleFingerprint",
table: "AuthCodes",
column: "HandleFingerprint",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_DeviceTokens_TokenFingerprint",
table: "DeviceTokens",
column: "TokenFingerprint",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_DeviceTokens_UserId",
table: "DeviceTokens",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Users_UserName",
table: "Users",
column: "UserName",
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AuthCodes");
migrationBuilder.DropTable(
name: "DeviceTokens");
migrationBuilder.DropTable(
name: "Libraries");
migrationBuilder.DropTable(
name: "Settings");
migrationBuilder.DropTable(
name: "Users");
}
}
}