using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace song_of_the_day.DataMigrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Songs", columns: table => new { SongId = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false), Artist = table.Column(type: "text", nullable: false), Url = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Songs", x => x.SongId); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { UserId = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), SignalId = table.Column(type: "text", nullable: false), Name = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.UserId); }); migrationBuilder.CreateTable( name: "SongSuggestions", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), UserId = table.Column(type: "integer", nullable: false), SongId = table.Column(type: "integer", nullable: false), Date = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_SongSuggestions", x => x.Id); table.ForeignKey( name: "FK_SongSuggestions_Songs_SongId", column: x => x.SongId, principalTable: "Songs", principalColumn: "SongId", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_SongSuggestions_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "UserId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_SongSuggestions_SongId", table: "SongSuggestions", column: "SongId"); migrationBuilder.CreateIndex( name: "IX_SongSuggestions_UserId", table: "SongSuggestions", column: "UserId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "SongSuggestions"); migrationBuilder.DropTable( name: "Songs"); migrationBuilder.DropTable( name: "Users"); } } }