Files
WatchIt/WatchIt.Database/WatchIt.Database/Migrations/20240317125055_Migration1.cs
2024-03-17 13:55:29 +01:00

87 lines
3.9 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace WatchIt.Database.Migrations
{
/// <inheritdoc />
public partial class Migration1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AccountProfilePictures",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Image = table.Column<byte[]>(type: "bytea", maxLength: -1, nullable: false),
MimeType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
UploadDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("PK_AccountProfilePictures", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Accounts",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Username = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
Email = table.Column<string>(type: "character varying(320)", maxLength: 320, nullable: false),
Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: false),
AccountProfilePictureId = table.Column<Guid>(type: "uuid", nullable: false),
Password = table.Column<byte[]>(type: "bytea", maxLength: 1000, nullable: false),
LeftSalt = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
RightSalt = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
IsAdmin = table.Column<bool>(type: "boolean", nullable: false),
CreationDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
LastActive = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
},
constraints: table =>
{
table.PrimaryKey("PK_Accounts", x => x.Id);
table.ForeignKey(
name: "FK_Accounts_AccountProfilePictures_AccountProfilePictureId",
column: x => x.AccountProfilePictureId,
principalTable: "AccountProfilePictures",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AccountProfilePictures_Id",
table: "AccountProfilePictures",
column: "Id",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Accounts_AccountProfilePictureId",
table: "Accounts",
column: "AccountProfilePictureId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Accounts_Id",
table: "Accounts",
column: "Id",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Accounts");
migrationBuilder.DropTable(
name: "AccountProfilePictures");
}
}
}