namespace StudentDAL.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitialCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.PersonInStudySubjects",
                c => new
                    {
                        PersonInStudySubjectID = c.Int(nullable: false, identity: true),
                        PersonID = c.Int(nullable: false),
                        StudySubjectID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.PersonInStudySubjectID)
                .ForeignKey("dbo.People", t => t.PersonID, cascadeDelete: true)
                .ForeignKey("dbo.StudySubjects", t => t.StudySubjectID, cascadeDelete: true)
                .Index(t => t.PersonID)
                .Index(t => t.StudySubjectID);
            
            CreateTable(
                "dbo.People",
                c => new
                    {
                        PersonID = c.Int(nullable: false, identity: true),
                        FirstName = c.String(),
                        LastName = c.String(),
                        NickName = c.String(),
                        DOB = c.DateTime(nullable: false),
                        IsActive = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.PersonID);
            
            CreateTable(
                "dbo.StudySubjects",
                c => new
                    {
                        StudySubjectID = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                    })
                .PrimaryKey(t => t.StudySubjectID);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.PersonInStudySubjects", "StudySubjectID", "dbo.StudySubjects");
            DropForeignKey("dbo.PersonInStudySubjects", "PersonID", "dbo.People");
            DropIndex("dbo.PersonInStudySubjects", new[] { "StudySubjectID" });
            DropIndex("dbo.PersonInStudySubjects", new[] { "PersonID" });
            DropTable("dbo.StudySubjects");
            DropTable("dbo.People");
            DropTable("dbo.PersonInStudySubjects");
        }
    }
}
