84 lines
3.8 KiB
C#
84 lines
3.8 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Hutopy.Modules.Contents.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Initial : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.EnsureSchema(
|
|
name: "Content");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Albums",
|
|
schema: "Content",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, computedColumnSql: "\"DeletedAt\" IS NOT NULL", stored: true),
|
|
Title = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
|
CreatedBy = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
|
|
DeletedBy = table.Column<Guid>(type: "uuid", nullable: true),
|
|
DeletedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Albums", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "AlbumPhotos",
|
|
schema: "Content",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
IsDeleted = table.Column<bool>(type: "boolean", nullable: false, computedColumnSql: "\"DeletedAt\" IS NOT NULL", stored: true),
|
|
AlbumId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
OriginalUrl = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
|
|
ThumbnailUrl = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
|
|
Caption = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
Order = table.Column<int>(type: "integer", nullable: false),
|
|
CreatedBy = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"),
|
|
DeletedBy = table.Column<Guid>(type: "uuid", nullable: true),
|
|
DeletedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_AlbumPhotos", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_AlbumPhotos_Albums_AlbumId",
|
|
column: x => x.AlbumId,
|
|
principalSchema: "Content",
|
|
principalTable: "Albums",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_AlbumPhotos_AlbumId",
|
|
schema: "Content",
|
|
table: "AlbumPhotos",
|
|
column: "AlbumId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "AlbumPhotos",
|
|
schema: "Content");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Albums",
|
|
schema: "Content");
|
|
}
|
|
}
|
|
}
|