360 lines
19 KiB
C#
360 lines
19 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace Musify.Infrastructure.Persistence.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitialCreate : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "InboxState",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
MessageId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ConsumerId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
LockId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
RowVersion = table.Column<byte[]>(type: "bytea", rowVersion: true, nullable: true),
|
|
Received = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
ReceiveCount = table.Column<int>(type: "integer", nullable: false),
|
|
ExpirationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
Consumed = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
Delivered = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
LastSequenceNumber = table.Column<long>(type: "bigint", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_InboxState", x => x.Id);
|
|
table.UniqueConstraint("AK_InboxState_MessageId_ConsumerId", x => new { x.MessageId, x.ConsumerId });
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "OutboxState",
|
|
columns: table => new
|
|
{
|
|
OutboxId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
LockId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
RowVersion = table.Column<byte[]>(type: "bytea", rowVersion: true, nullable: true),
|
|
Created = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
Delivered = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
LastSequenceNumber = table.Column<long>(type: "bigint", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_OutboxState", x => x.OutboxId);
|
|
});
|
|
|
|
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),
|
|
LifeCycleStatus = 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<long>(type: "bigint", 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: "OutboxMessage",
|
|
columns: table => new
|
|
{
|
|
SequenceNumber = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
EnqueueTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
SentTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
Headers = table.Column<string>(type: "text", nullable: true),
|
|
Properties = table.Column<string>(type: "text", nullable: true),
|
|
InboxMessageId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
InboxConsumerId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
OutboxId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
MessageId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
ContentType = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
|
MessageType = table.Column<string>(type: "text", nullable: false),
|
|
Body = table.Column<string>(type: "text", nullable: false),
|
|
ConversationId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
CorrelationId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
InitiatorId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
RequestId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
SourceAddress = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
DestinationAddress = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
ResponseAddress = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
FaultAddress = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
ExpirationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_OutboxMessage", x => x.SequenceNumber);
|
|
table.ForeignKey(
|
|
name: "FK_OutboxMessage_InboxState_InboxMessageId_InboxConsumerId",
|
|
columns: x => new { x.InboxMessageId, x.InboxConsumerId },
|
|
principalTable: "InboxState",
|
|
principalColumns: new[] { "MessageId", "ConsumerId" });
|
|
table.ForeignKey(
|
|
name: "FK_OutboxMessage_OutboxState_OutboxId",
|
|
column: x => x.OutboxId,
|
|
principalTable: "OutboxState",
|
|
principalColumn: "OutboxId");
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "PlayLists",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
UserId = table.Column<long>(type: "bigint", 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),
|
|
LifeCycleStatus = table.Column<int>(type: "integer", 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: "UploadIntents",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
UserId = table.Column<long>(type: "bigint", nullable: false),
|
|
Bucket = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
|
|
Key = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: false),
|
|
ObjectName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
|
|
ContentType = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
|
|
ExpectedSizeBytes = table.Column<long>(type: "bigint", nullable: true),
|
|
Purpose = table.Column<int>(type: "integer", nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
ExpiresAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_UploadIntents", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_UploadIntents_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<long>(type: "bigint", 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_InboxState_Delivered",
|
|
table: "InboxState",
|
|
column: "Delivered");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_OutboxMessage_EnqueueTime",
|
|
table: "OutboxMessage",
|
|
column: "EnqueueTime");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_OutboxMessage_ExpirationTime",
|
|
table: "OutboxMessage",
|
|
column: "ExpirationTime");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_OutboxMessage_InboxMessageId_InboxConsumerId_SequenceNumber",
|
|
table: "OutboxMessage",
|
|
columns: new[] { "InboxMessageId", "InboxConsumerId", "SequenceNumber" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_OutboxMessage_OutboxId_SequenceNumber",
|
|
table: "OutboxMessage",
|
|
columns: new[] { "OutboxId", "SequenceNumber" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_OutboxState_Created",
|
|
table: "OutboxState",
|
|
column: "Created");
|
|
|
|
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_UploadIntents_UserId",
|
|
table: "UploadIntents",
|
|
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: "OutboxMessage");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PlayListHasTrack");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Upload");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "UploadIntents");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "UserHasTrack");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "InboxState");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "OutboxState");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "PlayLists");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Tracks");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "User");
|
|
}
|
|
}
|
|
}
|