using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace LawFirmDatabase.Migrations { /// public partial class InitMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Customers", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Login = table.Column(type: "nvarchar(max)", nullable: false), Password = table.Column(type: "nvarchar(max)", nullable: false), Name = table.Column(type: "nvarchar(max)", nullable: false), Surname = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Customers", x => x.Id); }); migrationBuilder.CreateTable( name: "Cases", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), CustomerId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Cases", x => x.Id); table.ForeignKey( name: "FK_Cases_Customers_CustomerId", column: x => x.CustomerId, principalTable: "Customers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Payments", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Sum = table.Column(type: "decimal (10,2)", nullable: false), CaseId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Payments", x => x.Id); table.ForeignKey( name: "FK_Payments_Cases_CaseId", column: x => x.CaseId, principalTable: "Cases", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Items", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), Price = table.Column(type: "decimal (10,2)", nullable: false), PaymentId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Items", x => x.Id); table.ForeignKey( name: "FK_Items_Payments_PaymentId", column: x => x.PaymentId, principalTable: "Payments", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Services", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), Price = table.Column(type: "decimal (10,2)", nullable: false), ItemId = table.Column(type: "int", nullable: false), CaseId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Services", x => x.Id); table.ForeignKey( name: "FK_Services_Cases_CaseId", column: x => x.CaseId, principalTable: "Cases", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Services_Items_ItemId", column: x => x.ItemId, principalTable: "Items", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Cases_CustomerId", table: "Cases", column: "CustomerId"); migrationBuilder.CreateIndex( name: "IX_Items_PaymentId", table: "Items", column: "PaymentId"); migrationBuilder.CreateIndex( name: "IX_Payments_CaseId", table: "Payments", column: "CaseId"); migrationBuilder.CreateIndex( name: "IX_Services_CaseId", table: "Services", column: "CaseId"); migrationBuilder.CreateIndex( name: "IX_Services_ItemId", table: "Services", column: "ItemId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Services"); migrationBuilder.DropTable( name: "Items"); migrationBuilder.DropTable( name: "Payments"); migrationBuilder.DropTable( name: "Cases"); migrationBuilder.DropTable( name: "Customers"); } } }