Files
Musify/Infrastructure/Persistence/Migrations/20260513230601_FirstMigration.cs
T
2026-05-14 01:06:30 +02:00

200 lines
9.7 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: "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: true),
MediumPictureName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
LargePictureName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
OriginalAudioName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
AudioFolderName = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
PicturesProcessingStatus = table.Column<int>(type: "integer", nullable: false),
AudioTranscodeProcessingStatus = table.Column<int>(type: "integer", nullable: false),
RetryCount = table.Column<int>(type: "integer", nullable: false),
LastRetryAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
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),
Name = table.Column<string>(type: "character varying(48)", maxLength: 48, nullable: false),
NormalizedName = table.Column<string>(type: "character varying(48)", maxLength: 48, nullable: false),
FirstName = table.Column<string>(type: "character varying(48)", maxLength: 48, nullable: true),
SecondName = table.Column<string>(type: "character varying(48)", maxLength: 48, nullable: true),
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: "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_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: "Upload");
migrationBuilder.DropTable(
name: "UserHasTrack");
migrationBuilder.DropTable(
name: "PlayLists");
migrationBuilder.DropTable(
name: "Tracks");
migrationBuilder.DropTable(
name: "User");
}
}
}