using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace lxc_songlist.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "SiteSettings", columns: table => new { Key = table.Column(type: "character varying(80)", maxLength: 80, nullable: false), Value = table.Column(type: "character varying(500)", maxLength: 500, nullable: false), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_SiteSettings", x => x.Key); }); migrationBuilder.CreateTable( name: "Songs", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Title = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), NormalizedTitle = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), IsHidden = table.Column(type: "boolean", 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_Songs", x => x.Id); }); migrationBuilder.CreateTable( name: "Tags", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), NormalizedName = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Tags", x => x.Id); }); migrationBuilder.CreateTable( name: "SongTags", columns: table => new { SongId = table.Column(type: "integer", nullable: false), TagId = table.Column(type: "integer", nullable: false), CreatedByViewer = table.Column(type: "boolean", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_SongTags", x => new { x.SongId, x.TagId }); table.ForeignKey( name: "FK_SongTags_Songs_SongId", column: x => x.SongId, principalTable: "Songs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_SongTags_Tags_TagId", column: x => x.TagId, principalTable: "Tags", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Songs_NormalizedTitle", table: "Songs", column: "NormalizedTitle", unique: true); migrationBuilder.CreateIndex( name: "IX_SongTags_TagId", table: "SongTags", column: "TagId"); migrationBuilder.CreateIndex( name: "IX_Tags_NormalizedName", table: "Tags", column: "NormalizedName", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "SiteSettings"); migrationBuilder.DropTable( name: "SongTags"); migrationBuilder.DropTable( name: "Songs"); migrationBuilder.DropTable( name: "Tags"); } } }