252 lines
12 KiB
C#
252 lines
12 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Musify.Infrastructure.Persistence.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class FirstMigration : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "ProcessExecution",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CorrelationId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
ConversationId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
MessageId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
ProcessName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
StartedDateTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
FinishedDateTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
ErrorMessage = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ProcessExecution", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Tracks",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Title = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
NormalizedTitle = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
OriginalPictureName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
|
SmallPictureName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
|
MediumPictureName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
|
LargePictureName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
|
OriginalAudioName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
|
AudioFolderName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
|
CreatedDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Tracks", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Upload",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Bucket = table.Column<string>(type: "text", nullable: false),
|
|
Key = table.Column<string>(type: "text", nullable: false),
|
|
ContentType = table.Column<string>(type: "text", nullable: false),
|
|
CreatedTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
State = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Upload", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "User",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_User", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "ProcessStepExecution",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ProcessExecutionId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
StepName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
|
ComponentType = table.Column<int>(type: "integer", nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
Attempt = table.Column<int>(type: "integer", nullable: false),
|
|
StartedDateTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
FinishedDateTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
ErrorMessage = table.Column<string>(type: "character varying(2048)", maxLength: 2048, nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ProcessStepExecution", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ProcessStepExecution_ProcessExecution_ProcessExecutionId",
|
|
column: x => x.ProcessExecutionId,
|
|
principalTable: "ProcessExecution",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PlayLists",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
NormalizedName = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
Description = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
|
OriginalPictureName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
|
SmallPictureName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
|
MediumPictureName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
|
LargePictureName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
|
CreatedDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PlayLists", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_PlayLists_User_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "User",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "UserHasTrack",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
UserId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
TrackId = table.Column<Guid>(type: "uuid", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_UserHasTrack", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_UserHasTrack_Tracks_TrackId",
|
|
column: x => x.TrackId,
|
|
principalTable: "Tracks",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_UserHasTrack_User_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "User",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PlayListHasTrack",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
PlayListId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
TrackId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Position = table.Column<int>(type: "integer", nullable: false),
|
|
AddedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PlayListHasTrack", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_PlayListHasTrack_PlayLists_PlayListId",
|
|
column: x => x.PlayListId,
|
|
principalTable: "PlayLists",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_PlayListHasTrack_Tracks_TrackId",
|
|
column: x => x.TrackId,
|
|
principalTable: "Tracks",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PlayListHasTrack_PlayListId",
|
|
table: "PlayListHasTrack",
|
|
column: "PlayListId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PlayListHasTrack_TrackId",
|
|
table: "PlayListHasTrack",
|
|
column: "TrackId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PlayLists_UserId",
|
|
table: "PlayLists",
|
|
column: "UserId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ProcessExecution_CorrelationId_ProcessName",
|
|
table: "ProcessExecution",
|
|
columns: new[] { "CorrelationId", "ProcessName" });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ProcessStepExecution_ProcessExecutionId_StepName",
|
|
table: "ProcessStepExecution",
|
|
columns: new[] { "ProcessExecutionId", "StepName" });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_UserHasTrack_TrackId",
|
|
table: "UserHasTrack",
|
|
column: "TrackId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_UserHasTrack_UserId",
|
|
table: "UserHasTrack",
|
|
column: "UserId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "PlayListHasTrack");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ProcessStepExecution");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Upload");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "UserHasTrack");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PlayLists");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ProcessExecution");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Tracks");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "User");
|
|
}
|
|
}
|
|
}
|