using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Musify.Infrastructure.Persistence.Migrations { /// public partial class AddAlbums : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Albums", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Title = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), NormalizedTitle = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), Description = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), ReleaseYear = table.Column(type: "integer", nullable: true), OriginalPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), SmallPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), MediumPictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), LargePictureName = table.Column(type: "character varying(64)", maxLength: 64, nullable: true), LifeCycleStatus = 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_Albums", x => x.Id); }); migrationBuilder.CreateTable( name: "AlbumHasTrack", columns: table => new { Id = table.Column(type: "uuid", nullable: false), AlbumId = table.Column(type: "uuid", nullable: false), TrackId = table.Column(type: "uuid", nullable: false), TrackNumber = table.Column(type: "integer", nullable: false), AddedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_AlbumHasTrack", x => x.Id); table.ForeignKey( name: "FK_AlbumHasTrack_Albums_AlbumId", column: x => x.AlbumId, principalTable: "Albums", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_AlbumHasTrack_Tracks_TrackId", column: x => x.TrackId, principalTable: "Tracks", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "UserAlbums", columns: table => new { Id = table.Column(type: "uuid", nullable: false), OwnerUserId = table.Column(type: "bigint", nullable: false) }, constraints: table => { table.PrimaryKey("PK_UserAlbums", x => x.Id); table.ForeignKey( name: "FK_UserAlbums_Albums_Id", column: x => x.Id, principalTable: "Albums", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_UserAlbums_User_OwnerUserId", column: x => x.OwnerUserId, principalTable: "User", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_AlbumHasTrack_AlbumId_TrackId", table: "AlbumHasTrack", columns: new[] { "AlbumId", "TrackId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_AlbumHasTrack_TrackId", table: "AlbumHasTrack", column: "TrackId"); migrationBuilder.CreateIndex( name: "IX_UserAlbums_OwnerUserId", table: "UserAlbums", column: "OwnerUserId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AlbumHasTrack"); migrationBuilder.DropTable( name: "UserAlbums"); migrationBuilder.DropTable( name: "Albums"); } } }