using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace USEntryCoach.Server.Migrations { /// public partial class Initial : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Blogs", columns: table => new { BlogId = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Url = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Blogs", x => x.BlogId); }); migrationBuilder.CreateTable( name: "Posts", columns: table => new { PostId = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Title = table.Column(type: "text", nullable: false), Content = table.Column(type: "text", nullable: false), BlogId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Posts", x => x.PostId); table.ForeignKey( name: "FK_Posts_Blogs_BlogId", column: x => x.BlogId, principalTable: "Blogs", principalColumn: "BlogId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Posts_BlogId", table: "Posts", column: "BlogId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Posts"); migrationBuilder.DropTable( name: "Blogs"); } } }