namespace SmartCDC.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class RenameAspNetUsersToRegistration : DbMigration
    {
        //public override void Up()
        //{
        //    RenameTable(name: "dbo.AspNetUsers", newName: "Registration");
        //    RenameTable(name: "dbo.AspNetRoles", newName: "Roles");
        //    RenameTable(name: "dbo.AspNetUserRoles", newName: "UserRoles");
        //    RenameTable(name: "dbo.AspNetUserClaims", newName: "UserClaims");
        //    RenameTable(name: "dbo.AspNetUserLogins", newName: "UserLogins");
        //}

        //public override void Down()
        //{
        //    RenameTable(name: "dbo.Registration", newName: "AspNetUsers");
        //    RenameTable(name: "dbo.Roles", newName: "AspNetRoles");
        //    RenameTable(name: "dbo.UserRoles", newName: "AspNetUserRoles");
        //    RenameTable(name: "dbo.UserClaims", newName: "AspNetUserClaims");
        //    RenameTable(name: "dbo.UserLogins", newName: "AspNetUserLogins");
        //}
        public override void Up()
        {
            CreateTable(
                "dbo.Roles",
                c => new
                {
                    Id = c.String(nullable: false, maxLength: 128),
                    Name = c.String(nullable: false, maxLength: 256),
                })
                .PrimaryKey(t => t.Id)
                .Index(t => t.Name, unique: true, name: "RoleNameIndex");

            CreateTable(
                "dbo.UserRoles",
                c => new
                {
                    UserId = c.String(nullable: false, maxLength: 128),
                    RoleId = c.String(nullable: false, maxLength: 128),
                })
                .PrimaryKey(t => new { t.UserId, t.RoleId })
                .ForeignKey("dbo.Roles", t => t.RoleId, cascadeDelete: true)
                .ForeignKey("dbo.Registration", t => t.UserId, cascadeDelete: true)
                .Index(t => t.UserId)
                .Index(t => t.RoleId);

            CreateTable(
                "dbo.Registration",
                c => new
                {
                    Id = c.String(nullable: false, maxLength: 128),
                    Email = c.String(maxLength: 256),
                    EmailConfirmed = c.Boolean(nullable: false),
                    PasswordHash = c.String(),
                    SecurityStamp = c.String(),
                    PhoneNumber = c.String(),
                    PhoneNumberConfirmed = c.Boolean(nullable: false),
                    TwoFactorEnabled = c.Boolean(nullable: false),
                    LockoutEndDateUtc = c.DateTime(),
                    LockoutEnabled = c.Boolean(nullable: false),
                    AccessFailedCount = c.Int(nullable: false),
                    UserName = c.String(nullable: false, maxLength: 256),
                })
                .PrimaryKey(t => t.Id)
                .Index(t => t.UserName, unique: true, name: "UserNameIndex");

            CreateTable(
                "dbo.UserClaims",
                c => new
                {
                    Id = c.Int(nullable: false, identity: true),
                    UserId = c.String(nullable: false, maxLength: 128),
                    ClaimType = c.String(),
                    ClaimValue = c.String(),
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Registration", t => t.UserId, cascadeDelete: true)
                .Index(t => t.UserId);

            CreateTable(
                "dbo.UserLogins",
                c => new
                {
                    LoginProvider = c.String(nullable: false, maxLength: 128),
                    ProviderKey = c.String(nullable: false, maxLength: 128),
                    UserId = c.String(nullable: false, maxLength: 128),
                })
                .PrimaryKey(t => new { t.LoginProvider, t.ProviderKey, t.UserId })
                .ForeignKey("dbo.Registration", t => t.UserId, cascadeDelete: true)
                .Index(t => t.UserId);

        }

        public override void Down()
        {
            DropForeignKey("dbo.UserRoles", "UserId", "dbo.Registration");
            DropForeignKey("dbo.UserLogins", "UserId", "dbo.Registration");
            DropForeignKey("dbo.UserClaims", "UserId", "dbo.Registration");
            DropForeignKey("dbo.UserRoles", "RoleId", "dbo.Roles");
            DropIndex("dbo.UserLogins", new[] { "UserId" });
            DropIndex("dbo.UserClaims", new[] { "UserId" });
            DropIndex("dbo.Registration", "UserNameIndex");
            DropIndex("dbo.UserRoles", new[] { "RoleId" });
            DropIndex("dbo.UserRoles", new[] { "UserId" });
            DropIndex("dbo.Roles", "RoleNameIndex");
            DropTable("dbo.UserLogins");
            DropTable("dbo.UserClaims");
            DropTable("dbo.Registration");
            DropTable("dbo.UserRoles");
            DropTable("dbo.Roles");
        }
    }
}
