using System; using Microsoft.EntityFrameworkCore.Migrations; namespace BrightGlimmer.Data.Migrations { public partial class CreateDatabase : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Addresses", columns: table => new { Id = table.Column(nullable: false), IsDeleted = table.Column(nullable: false), CreatedDate = table.Column(nullable: false), ModifiedDate = table.Column(nullable: false), StreetAddress1 = table.Column(nullable: true), StreetAddress2 = table.Column(nullable: true), City = table.Column(nullable: true), StateCode = table.Column(nullable: true), County = table.Column(nullable: true), ZipCode = table.Column(nullable: true), Latitude = table.Column(nullable: false), Longitude = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Addresses", x => x.Id); }); migrationBuilder.CreateTable( name: "Courses", columns: table => new { Id = table.Column(nullable: false), IsDeleted = table.Column(nullable: false), CreatedDate = table.Column(nullable: false), ModifiedDate = table.Column(nullable: false), Name = table.Column(nullable: true), Description = table.Column(nullable: true), Code = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Courses", x => x.Id); }); migrationBuilder.CreateTable( name: "Students", columns: table => new { Id = table.Column(nullable: false), IsDeleted = table.Column(nullable: false), CreatedDate = table.Column(nullable: false), ModifiedDate = table.Column(nullable: false), StudentNumber = table.Column(nullable: false), FirstName = table.Column(nullable: true), MiddleName = table.Column(nullable: true), LastName = table.Column(nullable: true), Email = table.Column(nullable: true), AddressId = table.Column(nullable: true), ProfilePictureUrl = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Students", x => x.Id); table.ForeignKey( name: "FK_Students_Addresses_AddressId", column: x => x.AddressId, principalTable: "Addresses", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "AssignedCourses", columns: table => new { Id = table.Column(nullable: false), IsDeleted = table.Column(nullable: false), CreatedDate = table.Column(nullable: false), ModifiedDate = table.Column(nullable: false), Grade = table.Column(nullable: false), IsActive = table.Column(nullable: false), Term = table.Column(nullable: true), StudentId = table.Column(nullable: true), CourseId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_AssignedCourses", x => x.Id); table.ForeignKey( name: "FK_AssignedCourses_Courses_CourseId", column: x => x.CourseId, principalTable: "Courses", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_AssignedCourses_Students_StudentId", column: x => x.StudentId, principalTable: "Students", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Phones", columns: table => new { Id = table.Column(nullable: false), IsDeleted = table.Column(nullable: false), CreatedDate = table.Column(nullable: false), ModifiedDate = table.Column(nullable: false), Type = table.Column(nullable: false), AreaCode = table.Column(nullable: false), Number = table.Column(nullable: false), StudentId = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Phones", x => x.Id); table.ForeignKey( name: "FK_Phones_Students_StudentId", column: x => x.StudentId, principalTable: "Students", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_AssignedCourses_CourseId", table: "AssignedCourses", column: "CourseId"); migrationBuilder.CreateIndex( name: "IX_AssignedCourses_StudentId", table: "AssignedCourses", column: "StudentId"); migrationBuilder.CreateIndex( name: "IX_Phones_StudentId", table: "Phones", column: "StudentId"); migrationBuilder.CreateIndex( name: "IX_Students_AddressId", table: "Students", column: "AddressId"); migrationBuilder.CreateIndex( name: "IX_Students_StudentNumber", table: "Students", column: "StudentNumber", unique: true); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "AssignedCourses"); migrationBuilder.DropTable( name: "Phones"); migrationBuilder.DropTable( name: "Courses"); migrationBuilder.DropTable( name: "Students"); migrationBuilder.DropTable( name: "Addresses"); } } }