using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace ServiceStationsDataBaseImplement.Migrations { /// public partial class InitMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Clients", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), FIO = table.Column(type: "nvarchar(max)", nullable: false), Password = table.Column(type: "nvarchar(max)", nullable: false), Login = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Clients", x => x.Id); }); migrationBuilder.CreateTable( name: "Executors", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Email = table.Column(type: "nvarchar(max)", nullable: false), Password = table.Column(type: "nvarchar(max)", nullable: false), FIO = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Executors", x => x.Id); }); migrationBuilder.CreateTable( name: "Tasks", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Tasks", x => x.Id); }); migrationBuilder.CreateTable( name: "Works", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Date = table.Column(type: "datetime2", nullable: false), Price = table.Column(type: "float", nullable: false), ExecutorId = table.Column(type: "int", nullable: false), TaskId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Works", x => x.Id); table.ForeignKey( name: "FK_Works_Executors_ExecutorId", column: x => x.ExecutorId, principalTable: "Executors", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "WorksClients", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), WorkId = table.Column(type: "int", nullable: false), ClientId = table.Column(type: "int", nullable: false), PointCount = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_WorksClients", x => x.Id); table.ForeignKey( name: "FK_WorksClients_Clients_ClientId", column: x => x.ClientId, principalTable: "Clients", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_WorksClients_Works_WorkId", column: x => x.WorkId, principalTable: "Works", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Works_ExecutorId", table: "Works", column: "ExecutorId"); migrationBuilder.CreateIndex( name: "IX_WorksClients_ClientId", table: "WorksClients", column: "ClientId"); migrationBuilder.CreateIndex( name: "IX_WorksClients_WorkId", table: "WorksClients", column: "WorkId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Tasks"); migrationBuilder.DropTable( name: "WorksClients"); migrationBuilder.DropTable( name: "Clients"); migrationBuilder.DropTable( name: "Works"); migrationBuilder.DropTable( name: "Executors"); } } }