Add 'backend/' from commit '040cfd7a75423d4e6136e58a67b40579af4ee966'
git-subtree-dir: backend git-subtree-mainline:ab911955edgit-subtree-split:040cfd7a75
This commit is contained in:
@@ -0,0 +1,197 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Data.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Initial : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.EnsureSchema(
|
||||
name: "Content");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Creators",
|
||||
schema: "Content",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
CreatedBy = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
Name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
|
||||
Title = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Creators", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Colors",
|
||||
schema: "Content",
|
||||
columns: table => new
|
||||
{
|
||||
CreatorId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Primary = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
Secondary = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
Background = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
Surface = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
Error = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
OnPrimary = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
OnSecondary = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
OnBackground = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
OnSurface = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false),
|
||||
OnError = table.Column<string>(type: "character varying(9)", maxLength: 9, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Colors", x => x.CreatorId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Colors_Creators_CreatorId",
|
||||
column: x => x.CreatorId,
|
||||
principalSchema: "Content",
|
||||
principalTable: "Creators",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Contents",
|
||||
schema: "Content",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", 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),
|
||||
Title = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
|
||||
Description = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: false),
|
||||
HtmlFileUrl = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true),
|
||||
Urls = table.Column<string[]>(type: "text[]", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Contents", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Contents_Creators_CreatedBy",
|
||||
column: x => x.CreatedBy,
|
||||
principalSchema: "Content",
|
||||
principalTable: "Creators",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Images",
|
||||
schema: "Content",
|
||||
columns: table => new
|
||||
{
|
||||
CreatorId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Banner = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
||||
Logo = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Images", x => x.CreatorId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Images_Creators_CreatorId",
|
||||
column: x => x.CreatorId,
|
||||
principalSchema: "Content",
|
||||
principalTable: "Creators",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Socials",
|
||||
schema: "Content",
|
||||
columns: table => new
|
||||
{
|
||||
CreatorId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
FacebookUrl = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
||||
InstagramUrl = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
||||
XUrl = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
||||
LinkedInUrl = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
||||
TikTokUrl = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
||||
YoutubeUrl = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
||||
RedditUrl = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
|
||||
WebsiteUrl = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Socials", x => x.CreatorId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Socials_Creators_CreatorId",
|
||||
column: x => x.CreatorId,
|
||||
principalSchema: "Content",
|
||||
principalTable: "Creators",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Reactions",
|
||||
schema: "Content",
|
||||
columns: table => new
|
||||
{
|
||||
ContentId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Reaction = table.Column<int>(type: "integer", nullable: false),
|
||||
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
UserName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Reactions", x => new { x.ContentId, x.Id });
|
||||
table.ForeignKey(
|
||||
name: "FK_Reactions_Contents_ContentId",
|
||||
column: x => x.ContentId,
|
||||
principalSchema: "Content",
|
||||
principalTable: "Contents",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Contents_CreatedBy",
|
||||
schema: "Content",
|
||||
table: "Contents",
|
||||
column: "CreatedBy");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Colors",
|
||||
schema: "Content");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Images",
|
||||
schema: "Content");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Reactions",
|
||||
schema: "Content");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Socials",
|
||||
schema: "Content");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Contents",
|
||||
schema: "Content");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Creators",
|
||||
schema: "Content");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user