using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Musify.Infrastructure.Persistence.Migrations { /// public partial class FirstMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "ProcessExecution", columns: table => new { Id = table.Column(type: "uuid", nullable: false), CorrelationId = table.Column(type: "uuid", nullable: true), ConversationId = table.Column(type: "uuid", nullable: true), MessageId = table.Column(type: "uuid", nullable: true), ProcessName = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), Status = table.Column(type: "integer", nullable: false), StartedDateTime = table.Column(type: "timestamp with time zone", nullable: false), FinishedDateTime = table.Column(type: "timestamp with time zone", nullable: true), ErrorMessage = table.Column(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(type: "uuid", nullable: false), Title = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), NormalizedTitle = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), OriginalPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), SmallPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), MediumPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), LargePictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), OriginalAudioName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), AudioFolderName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), CreatedDate = table.Column(type: "timestamp with time zone", nullable: false), UpdatedDate = table.Column(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(type: "uuid", nullable: false), Bucket = table.Column(type: "text", nullable: false), Key = table.Column(type: "text", nullable: false), ContentType = table.Column(type: "text", nullable: false), CreatedTime = table.Column(type: "timestamp with time zone", nullable: false), State = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Upload", x => x.Id); }); migrationBuilder.CreateTable( name: "User", columns: table => new { Id = table.Column(type: "uuid", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), UpdatedAt = table.Column(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(type: "uuid", nullable: false), ProcessExecutionId = table.Column(type: "uuid", nullable: false), StepName = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), ComponentType = table.Column(type: "integer", nullable: false), Status = table.Column(type: "integer", nullable: false), Attempt = table.Column(type: "integer", nullable: false), StartedDateTime = table.Column(type: "timestamp with time zone", nullable: false), FinishedDateTime = table.Column(type: "timestamp with time zone", nullable: true), ErrorMessage = table.Column(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(type: "uuid", nullable: false), UserId = table.Column(type: "uuid", nullable: false), Name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), NormalizedName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), Description = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), OriginalPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), SmallPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), MediumPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), LargePictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), CreatedDate = table.Column(type: "timestamp with time zone", nullable: false), UpdatedDate = table.Column(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(type: "uuid", nullable: false), UserId = table.Column(type: "uuid", nullable: false), TrackId = table.Column(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(type: "uuid", nullable: false), PlayListId = table.Column(type: "uuid", nullable: false), TrackId = table.Column(type: "uuid", nullable: false), Position = table.Column(type: "integer", nullable: false), AddedAt = table.Column(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"); } /// 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"); } } }