using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace TaskTrackerDatabase.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Organizations", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), OrganizationName = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Organizations", x => x.Id); }); migrationBuilder.CreateTable( name: "Projects", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ProjectName = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Projects", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), UserFIO = table.Column(type: "nvarchar(max)", nullable: false), Email = table.Column(type: "nvarchar(max)", nullable: false), Password = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "OrganizationProjects", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), OrganizationId = table.Column(type: "int", nullable: false), ProjectId = table.Column(type: "int", nullable: false), NumberEmployees = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_OrganizationProjects", x => x.Id); table.ForeignKey( name: "FK_OrganizationProjects_Organizations_OrganizationId", column: x => x.OrganizationId, principalTable: "Organizations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_OrganizationProjects_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Tasks", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ProjectId = table.Column(type: "int", nullable: false), UserId = table.Column(type: "int", nullable: false), Title = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: false), Status = table.Column(type: "int", nullable: false), DateCreate = table.Column(type: "datetime2", nullable: false), DateImplement = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Tasks", x => x.Id); table.ForeignKey( name: "FK_Tasks_Projects_ProjectId", column: x => x.ProjectId, principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Tasks_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_OrganizationProjects_OrganizationId", table: "OrganizationProjects", column: "OrganizationId"); migrationBuilder.CreateIndex( name: "IX_OrganizationProjects_ProjectId", table: "OrganizationProjects", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_Tasks_ProjectId", table: "Tasks", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_Tasks_UserId", table: "Tasks", column: "UserId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "OrganizationProjects"); migrationBuilder.DropTable( name: "Tasks"); migrationBuilder.DropTable( name: "Organizations"); migrationBuilder.DropTable( name: "Projects"); migrationBuilder.DropTable( name: "Users"); } } }