using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace HackerNet.Infrastructure.Migrations { public partial class CreateLinkAndComment : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Links", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), Url = table.Column(type: "TEXT", maxLength: 250, nullable: false), Description = table.Column(type: "TEXT", nullable: false), CreatedAt = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Links", x => x.Id); }); migrationBuilder.CreateTable( name: "Comments", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), LinkId = table.Column(type: "TEXT", nullable: false), Content = table.Column(type: "TEXT", nullable: false), CreatedAt = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Comments", x => x.Id); table.ForeignKey( name: "FK_Comments_Links_LinkId", column: x => x.LinkId, principalTable: "Links", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Comments_LinkId", table: "Comments", column: "LinkId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Comments"); migrationBuilder.DropTable( name: "Links"); } } }