context: namespace Realm.Live.DAL.Migrations
  {
      using System.Data.Entity.Migrations;
      
      public partial class InitialSetup : DbMigration
      {
          public override void Up()
          {
              CreateTable(
                  "dbo.Auctions",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          InstanceId = c.Long(),
                          ItemId = c.Int(),
                          Quantity = c.Int(nullable: false),
                          CharacterId = c.Int(),
                          DurationInSeconds = c.Int(nullable: false),
                          Reserve = c.Int(nullable: false),
                          IsFinished = c.Boolean(nullable: false),
                          CreateDateUtc = c.DateTime(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("dbo.Characters", t => t.CharacterId)
                  .ForeignKey("dbo.Instances", t => t.InstanceId)
                  .Index(t => t.InstanceId)
                  .Index(t => t.CharacterId);
              
              CreateTable(
                  "dbo.AuctionBids",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          AuctionId = c.Long(nullable: false),
                          CharacterId = c.Int(),
                          DatePlaced = c.DateTime(nullable: false),
                          Amount = c.Int(nullable: false),
                          IsRetracted = c.Boolean(nullable: false),
                          CreateDateUtc = c.DateTime(),
                          Auction_Id = c.Int(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("dbo.Auctions", t => t.Auction_Id)
                  .ForeignKey("dbo.Characters", t => t.CharacterId)
                  .Index(t => t.CharacterId)
                  .Index(t => t.Auction_Id);
              
              CreateTable(
                  "dbo.Characters",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          UserId = c.Int(),
                          Name = c.String(maxLength: 50),
                          DeletedOn = c.DateTime(),
                          GuildId = c.Int(),
                          LocationId = c.Int(),
                          RaceId = c.Int(),
                          Level = c.Int(nullable: false),
                          Experience = c.Int(nullable: false),
                          Coin = c.Int(nullable: false),
                          Gender = c.Int(nullable: false),
                          AutoAttackAbilityId = c.Int(),
                          TrainingPoints = c.Int(nullable: false),
                          BankId = c.Int(),
                          CreateDateUtc = c.DateTime(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("dbo.Banks", t => t.BankId)
                  .ForeignKey("dbo.Guilds", t => t.GuildId)
                  .ForeignKey("dbo.Users", t => t.UserId)
                  .Index(t => t.UserId)
                  .Index(t => t.GuildId)
                  .Index(t => t.BankId);
              
              CreateTable(
                  "dbo.CharacterAbilities",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          CharacterId = c.Int(nullable: false),
                          AbilityId = c.Int(),
                          PurchasedOn = c.DateTime(),
                          CreateDateUtc = c.DateTime(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("dbo.Characters", t => t.CharacterId)
                  .Index(t => t.CharacterId);
              
              CreateTable(
                  "dbo.CharacterAuctions",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          CharacterId = c.Int(nullable: false),
                          AuctionId = c.Long(),
                          CreateDateUtc = c.DateTime(),
                          Auction_Id = c.Int(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("dbo.Auctions", t => t.Auction_Id)
                  .ForeignKey("dbo.Characters", t => t.CharacterId)
                  .Index(t => t.CharacterId)
                  .Index(t => t.Auction_Id);
              
              CreateTable(
                  "dbo.Banks",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          Coin = c.Int(nullable: false),
                          Level = c.Int(nullable: false),
                          LastAccessed = c.DateTime(),
                          BankType = c.Int(nullable: false),
                          CreateDateUtc = c.DateTime(),
                      })
                  .PrimaryKey(t => t.Id);
              
              CreateTable(
                  "dbo.BankItems",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          BankId = c.Int(nullable: false),
                          InstanceId = c.Long(),
                          ItemId = c.Int(),
                          Quantity = c.Int(nullable: false),
                          CreateDateUtc = c.DateTime(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("dbo.Banks", t => t.BankId)
                  .ForeignKey("dbo.Instances", t => t.InstanceId)
                  .Index(t => t.BankId)
                  .Index(t => t.InstanceId);
              
              CreateTable(
                  "dbo.Instances",
                  c => new
                      {
                          Id = c.Long(nullable: false, identity: true),
                          CreatedOn = c.DateTime(nullable: false),
                          InstanceType = c.Int(nullable: false),
                      })
                  .PrimaryKey(t => t.Id);
              
              CreateTable(
                  "dbo.BankLogs",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          BankId = c.Int(nullable: false),
                          ModifiedOn = c.DateTime(nullable: false),
                          CharacterName = c.String(maxLength: 50),
                          ItemId = c.Int(),
                          Quantity = c.Int(nullable: false),
                          Withdrew = c.Boolean(nullable: false),
                          CreateDateUtc = c.DateTime(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("dbo.Banks", t => t.BankId)
                  .Index(t => t.BankId);
              
              CreateTable(
                  "dbo.CharacterChannels",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          CharacterId = c.Int(nullable: false),
                          ChannelId = c.Int(),
                          Handle = c.String(maxLength: 10),
                          IsEnabled = c.Boolean(nullable: false),
                          CreateDateUtc = c.DateTime(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("dbo.Channels", t => t.ChannelId)
                  .ForeignKey("dbo.Characters", t => t.CharacterId)
                  .Index(t => t.CharacterId)
                  .Index(t => t.ChannelId);
              
              CreateTable(
                  "dbo.Channels",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          Name = c.String(nullable: false, maxLength: 20),
                          ChannelType = c.Int(nullable: false),
                          Bits = c.Int(nullable: false),
                          OwnerId = c.Int(),
                          CreateDateUtc = c.DateTime(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("dbo.Characters", t => t.OwnerId)
                  .Index(t => t.OwnerId);
              
              CreateTable(
                  "dbo.CharacterFactions",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          CharacterId = c.Int(nullable: false),
                          FactionId = c.Int(),
                          Reputation = c.Int(nullable: false),
                          CreateDateUtc = c.DateTime(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("dbo.Characters", t => t.CharacterId)
                  .Index(t => t.CharacterId);
              
              CreateTable(
                  "dbo.Guilds",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          Name = c.String(nullable: false, maxLength: 50),
                          Description = c.String(maxLength: 1024),
                          Motd = c.String(maxLength: 1024),
                          Url = c.String(maxLength: 50),
                          MemberLimit = c.Int(nullable: false),
                          MemberChannelId = c.Int(),
                          OfficerChannelId = c.Int(),
                          Level = c.Int(nullable: false),
                          Experience = c.Int(nullable: false),
                          BankId = c.Int(),
                          CreateDateUtc = c.DateTime(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("dbo.Banks", t => t.BankId)
                  .ForeignKey("dbo.Channels", t => t.MemberChannelId)
                  .ForeignKey("dbo.Channels", t => t.OfficerChannelId)
                  .Index(t => t.MemberChannelId)
                  .Index(t => t.OfficerChannelId)
                  .Index(t => t.BankId);
              
              CreateTable(
                  "dbo.GuildAbilities",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          GuildId = c.Int(nullable: false),
                          AbilityId = c.Int(),
                          UnlockedOn = c.DateTime(nullable: false),
                          CreateDateUtc = c.DateTime(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("dbo.Guilds", t => t.GuildId)
                  .Index(t => t.GuildId);
              
              CreateTable(
                  "dbo.GuildMembers",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          GuildId = c.Int(nullable: false),
                          GuildRankType = c.Int(nullable: false),
                          JoinedOn = c.DateTime(),
                          MemberNote = c.String(maxLength: 255),
                          CreateDateUtc = c.DateTime(),
                          Character_Id = c.Int(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("dbo.Characters", t => t.Character_Id)
                  .ForeignKey("dbo.Guilds", t => t.GuildId)
                  .Index(t => t.GuildId)
                  .Index(t => t.Character_Id);
              
              CreateTable(
                  "dbo.CharacterItems",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          CharacterId = c.Int(nullable: false),
                          InstanceId = c.Long(),
                          ItemId = c.Int(),
                          Quantity = c.Int(nullable: false),
                          WearLocationId = c.Int(),
                          ContainedInItemId = c.Long(),
                          CreateDateUtc = c.DateTime(),
                      })
                  .PrimaryKey(t => t.Id)
                  .ForeignKey("dbo.Characters", t => t.CharacterId)
                  .ForeignKey("dbo.Instances", t => t.ContainedInItemId)
                  .ForeignKey("dbo.Instances", t => t.InstanceId)
                  .Index(t => t.CharacterId)
                  .Index(t => t.InstanceId)
                  .Index(t => t.ContainedInItemId);
              
              CreateTable(
                  "dbo.CharacterMailbox",
                  c => new
                      {
                          Id = c.Int(nullable: false, identity: true),
                          CharacterId = c.Int(nullable: false),
                          FromCharacterName = c.String(maxLength: 50),
                          Subject = c.String(maxLength: 50),
                          Text = c.String(),
                          SentOn = c.DateTime(nullable: false),
                          IsNew = c.Boolean(nullable: false),
                          Coin = c.Int(nullable: false),
  
gt:                         CreateDateUtc = c.DateTime(),