Files
bright-glimmer/BrightGlimmer.Data/Migrations/20190424174147_CreateDatabase.cs

171 lines
7.2 KiB
C#

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<Guid>(nullable: false),
IsDeleted = table.Column<bool>(nullable: false),
CreatedDate = table.Column<DateTime>(nullable: false),
ModifiedDate = table.Column<DateTime>(nullable: false),
StreetAddress1 = table.Column<string>(nullable: true),
StreetAddress2 = table.Column<string>(nullable: true),
City = table.Column<string>(nullable: true),
StateCode = table.Column<string>(nullable: true),
County = table.Column<string>(nullable: true),
ZipCode = table.Column<string>(nullable: true),
Latitude = table.Column<decimal>(nullable: false),
Longitude = table.Column<decimal>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Addresses", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Courses",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
IsDeleted = table.Column<bool>(nullable: false),
CreatedDate = table.Column<DateTime>(nullable: false),
ModifiedDate = table.Column<DateTime>(nullable: false),
Name = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true),
Code = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Courses", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Students",
columns: table => new
{
Id = table.Column<Guid>(nullable: false),
IsDeleted = table.Column<bool>(nullable: false),
CreatedDate = table.Column<DateTime>(nullable: false),
ModifiedDate = table.Column<DateTime>(nullable: false),
StudentNumber = table.Column<int>(nullable: false),
FirstName = table.Column<string>(nullable: true),
MiddleName = table.Column<string>(nullable: true),
LastName = table.Column<string>(nullable: true),
Email = table.Column<string>(nullable: true),
AddressId = table.Column<Guid>(nullable: true),
ProfilePictureUrl = table.Column<string>(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<Guid>(nullable: false),
IsDeleted = table.Column<bool>(nullable: false),
CreatedDate = table.Column<DateTime>(nullable: false),
ModifiedDate = table.Column<DateTime>(nullable: false),
Grade = table.Column<decimal>(nullable: false),
IsActive = table.Column<bool>(nullable: false),
Term = table.Column<string>(nullable: true),
StudentId = table.Column<Guid>(nullable: true),
CourseId = table.Column<Guid>(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<Guid>(nullable: false),
IsDeleted = table.Column<bool>(nullable: false),
CreatedDate = table.Column<DateTime>(nullable: false),
ModifiedDate = table.Column<DateTime>(nullable: false),
Type = table.Column<int>(nullable: false),
AreaCode = table.Column<int>(nullable: false),
Number = table.Column<int>(nullable: false),
StudentId = table.Column<Guid>(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");
}
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");
}
}
}