using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace SchoolAgainStudyDataBaseImplements.Migrations { /// public partial class NewMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Students", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false), Class = table.Column(type: "integer", nullable: false), Email = table.Column(type: "text", nullable: false), Login = table.Column(type: "text", nullable: false), Password = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Students", x => x.Id); }); migrationBuilder.CreateTable( name: "Teachers", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false), Post = table.Column(type: "text", nullable: false), Email = table.Column(type: "text", nullable: false), Login = table.Column(type: "text", nullable: false), Password = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Teachers", x => x.Id); }); migrationBuilder.CreateTable( name: "Interests", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Title = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), StudentId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Interests", x => x.Id); table.ForeignKey( name: "FK_Interests_Students_StudentId", column: x => x.StudentId, principalTable: "Students", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Products", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Title = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), DateCreate = table.Column(type: "timestamp with time zone", nullable: false), StudentId = table.Column(type: "integer", nullable: false), StudentName = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Products", x => x.Id); table.ForeignKey( name: "FK_Products_Students_StudentId", column: x => x.StudentId, principalTable: "Students", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Materials", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Title = table.Column(type: "text", nullable: false), SphereUse = table.Column(type: "text", nullable: false), TeacherId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Materials", x => x.Id); table.ForeignKey( name: "FK_Materials_Teachers_TeacherId", column: x => x.TeacherId, principalTable: "Teachers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Tasks", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Title = table.Column(type: "text", nullable: false), DateIssue = table.Column(type: "timestamp with time zone", nullable: false), DateDelivery = table.Column(type: "timestamp with time zone", nullable: false), TeacherId = table.Column(type: "integer", nullable: false), TeacherName = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Tasks", x => x.Id); table.ForeignKey( name: "FK_Tasks_Teachers_TeacherId", column: x => x.TeacherId, principalTable: "Teachers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Lessons", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Title = table.Column(type: "text", nullable: false), DateEvent = table.Column(type: "timestamp with time zone", nullable: false), ProductId = table.Column(type: "integer", nullable: false), ProductName = table.Column(type: "text", nullable: false), TeacherId = table.Column(type: "integer", nullable: false), TeacherName = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Lessons", x => x.Id); table.ForeignKey( name: "FK_Lessons_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Lessons_Teachers_TeacherId", column: x => x.TeacherId, principalTable: "Teachers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ProductInterests", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ProductId = table.Column(type: "integer", nullable: false), InterestId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ProductInterests", x => x.Id); table.ForeignKey( name: "FK_ProductInterests_Interests_InterestId", column: x => x.InterestId, principalTable: "Interests", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ProductInterests_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Diys", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Title = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), DateCreate = table.Column(type: "timestamp with time zone", nullable: false), TaskId = table.Column(type: "integer", nullable: false), TaskName = table.Column(type: "text", nullable: false), StudentId = table.Column(type: "integer", nullable: false), StudentName = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Diys", x => x.Id); table.ForeignKey( name: "FK_Diys_Students_StudentId", column: x => x.StudentId, principalTable: "Students", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Diys_Tasks_TaskId", column: x => x.TaskId, principalTable: "Tasks", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "TaskMaterials", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), TaskId = table.Column(type: "integer", nullable: false), MaterialId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TaskMaterials", x => x.Id); table.ForeignKey( name: "FK_TaskMaterials_Materials_MaterialId", column: x => x.MaterialId, principalTable: "Materials", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_TaskMaterials_Tasks_TaskId", column: x => x.TaskId, principalTable: "Tasks", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "LessonMaterials", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), LessonId = table.Column(type: "integer", nullable: false), MaterialId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_LessonMaterials", x => x.Id); table.ForeignKey( name: "FK_LessonMaterials_Lessons_LessonId", column: x => x.LessonId, principalTable: "Lessons", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_LessonMaterials_Materials_MaterialId", column: x => x.MaterialId, principalTable: "Materials", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "DiyInterests", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), DiyId = table.Column(type: "integer", nullable: false), InterestId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_DiyInterests", x => x.Id); table.ForeignKey( name: "FK_DiyInterests_Diys_DiyId", column: x => x.DiyId, principalTable: "Diys", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_DiyInterests_Interests_InterestId", column: x => x.InterestId, principalTable: "Interests", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_DiyInterests_DiyId", table: "DiyInterests", column: "DiyId"); migrationBuilder.CreateIndex( name: "IX_DiyInterests_InterestId", table: "DiyInterests", column: "InterestId"); migrationBuilder.CreateIndex( name: "IX_Diys_StudentId", table: "Diys", column: "StudentId"); migrationBuilder.CreateIndex( name: "IX_Diys_TaskId", table: "Diys", column: "TaskId"); migrationBuilder.CreateIndex( name: "IX_Interests_StudentId", table: "Interests", column: "StudentId"); migrationBuilder.CreateIndex( name: "IX_LessonMaterials_LessonId", table: "LessonMaterials", column: "LessonId"); migrationBuilder.CreateIndex( name: "IX_LessonMaterials_MaterialId", table: "LessonMaterials", column: "MaterialId"); migrationBuilder.CreateIndex( name: "IX_Lessons_ProductId", table: "Lessons", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_Lessons_TeacherId", table: "Lessons", column: "TeacherId"); migrationBuilder.CreateIndex( name: "IX_Materials_TeacherId", table: "Materials", column: "TeacherId"); migrationBuilder.CreateIndex( name: "IX_ProductInterests_InterestId", table: "ProductInterests", column: "InterestId"); migrationBuilder.CreateIndex( name: "IX_ProductInterests_ProductId", table: "ProductInterests", column: "ProductId"); migrationBuilder.CreateIndex( name: "IX_Products_StudentId", table: "Products", column: "StudentId"); migrationBuilder.CreateIndex( name: "IX_TaskMaterials_MaterialId", table: "TaskMaterials", column: "MaterialId"); migrationBuilder.CreateIndex( name: "IX_TaskMaterials_TaskId", table: "TaskMaterials", column: "TaskId"); migrationBuilder.CreateIndex( name: "IX_Tasks_TeacherId", table: "Tasks", column: "TeacherId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "DiyInterests"); migrationBuilder.DropTable( name: "LessonMaterials"); migrationBuilder.DropTable( name: "ProductInterests"); migrationBuilder.DropTable( name: "TaskMaterials"); migrationBuilder.DropTable( name: "Diys"); migrationBuilder.DropTable( name: "Lessons"); migrationBuilder.DropTable( name: "Interests"); migrationBuilder.DropTable( name: "Materials"); migrationBuilder.DropTable( name: "Tasks"); migrationBuilder.DropTable( name: "Products"); migrationBuilder.DropTable( name: "Teachers"); migrationBuilder.DropTable( name: "Students"); } } }