using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Musify.Infrastructure.Persistence.Migrations { /// public partial class AddMixes : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Mixes", columns: table => new { Id = table.Column(type: "uuid", nullable: false), UserId = table.Column(type: "bigint", nullable: false), Title = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), Subtitle = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), GeneratedOn = table.Column(type: "date", nullable: false), Position = table.Column(type: "integer", 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_Mixes", x => x.Id); table.ForeignKey( name: "FK_Mixes_User_UserId", column: x => x.UserId, principalTable: "User", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "MixItems", columns: table => new { Id = table.Column(type: "uuid", nullable: false), MixId = table.Column(type: "uuid", nullable: false), Position = table.Column(type: "integer", nullable: false), Source = table.Column(type: "integer", nullable: false), TrackId = table.Column(type: "uuid", nullable: true), VideoId = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), Title = table.Column(type: "character varying(300)", maxLength: 300, nullable: true), Artist = table.Column(type: "character varying(300)", maxLength: 300, nullable: true), ThumbnailUrl = table.Column(type: "character varying(512)", maxLength: 512, nullable: true), DurationSeconds = table.Column(type: "integer", nullable: false), IsExplicit = table.Column(type: "boolean", nullable: false) }, constraints: table => { table.PrimaryKey("PK_MixItems", x => x.Id); table.ForeignKey( name: "FK_MixItems_Mixes_MixId", column: x => x.MixId, principalTable: "Mixes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_MixItems_Tracks_TrackId", column: x => x.TrackId, principalTable: "Tracks", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Mixes_UserId_Position", table: "Mixes", columns: new[] { "UserId", "Position" }); migrationBuilder.CreateIndex( name: "IX_MixItems_MixId_Position", table: "MixItems", columns: new[] { "MixId", "Position" }); migrationBuilder.CreateIndex( name: "IX_MixItems_TrackId", table: "MixItems", column: "TrackId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "MixItems"); migrationBuilder.DropTable( name: "Mixes"); } } }