71 lines
2.5 KiB
C#
71 lines
2.5 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Mizuki.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Initialmigration : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Users",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
Username = table.Column<string>(type: "TEXT", nullable: false),
|
|
PasswordHash = table.Column<string>(type: "TEXT", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Users", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Uploads",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
Filename = table.Column<string>(type: "TEXT", nullable: false),
|
|
OriginalFilename = table.Column<string>(type: "TEXT", nullable: false),
|
|
SizeInBytes = table.Column<long>(type: "INTEGER", nullable: false),
|
|
TimeOfUpload = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
|
|
AuthorId = table.Column<Guid>(type: "TEXT", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Uploads", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Uploads_Users_AuthorId",
|
|
column: x => x.AuthorId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Uploads_AuthorId",
|
|
table: "Uploads",
|
|
column: "AuthorId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Uploads_Filename",
|
|
table: "Uploads",
|
|
column: "Filename",
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Uploads");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Users");
|
|
}
|
|
}
|
|
}
|