namespace iRely.Model.Migrations
{
    using System.Data.Entity.Migrations;
    
    public partial class Sample : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "tblSMCity",
                c => new
                    {
                        intCityID = c.Int(nullable: false, identity: true),
                        strCity = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intCityID);
            
            CreateTable(
                "tblSMCompanySetup",
                c => new
                    {
                        intCompanySetupID = c.Int(nullable: false, identity: true),
                        strCompanyName = c.String(),
                        strContactName = c.String(),
                        strAddress = c.String(),
                        intCityID = c.Int(),
                        intStateID = c.Int(),
                        intZipCodeID = c.Int(),
                        intCountryID = c.Int(),
                        strPhone = c.String(),
                        strFax = c.String(),
                        memWebSite = c.String(),
                        strEmail = c.String(),
                        strFederalTaxID = c.String(),
                        strStateTaxID = c.String(),
                        strBusinessType = c.String(),
                        strUPCCode = c.String(),
                        strIndustryID = c.String(),
                        strNote = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intCompanySetupID)
                .ForeignKey("tblSMCountry", t => t.intCountryID)
                .ForeignKey("tblSMState", t => t.intStateID)
                .ForeignKey("tblSMZipCode", t => t.intZipCodeID)
                .ForeignKey("tblSMCity", t => t.intCityID)
                .Index(t => t.intCountryID)
                .Index(t => t.intStateID)
                .Index(t => t.intZipCodeID)
                .Index(t => t.intCityID);
            
            CreateTable(
                "tblSMCountry",
                c => new
                    {
                        intCountryID = c.Int(nullable: false, identity: true),
                        strCountry = c.String(),
                        strCountryCode = c.String(),
                        intCityAreaDigit = c.Int(),
                        strCityAreaMask = c.String(),
                        intLocalDigit = c.Int(),
                        strLocalNumberMask = c.String(),
                        ysnDisplayCountryCode = c.Boolean(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intCountryID);
            
            CreateTable(
                "tblSMZipCode",
                c => new
                    {
                        intZipCodeID = c.Int(nullable: false, identity: true),
                        strZipCode = c.String(),
                        intStateID = c.Int(),
                        intCityID = c.Int(),
                        intCountryID = c.Int(),
                        dblLatitude = c.Decimal(precision: 18, scale: 2),
                        dblLongitude = c.Decimal(precision: 18, scale: 2),
                        intSort = c.Int(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intZipCodeID)
                .ForeignKey("tblSMState", t => t.intStateID)
                .ForeignKey("tblSMCountry", t => t.intCountryID)
                .ForeignKey("tblSMCity", t => t.intCityID)
                .Index(t => t.intStateID)
                .Index(t => t.intCountryID)
                .Index(t => t.intCityID);
            
            CreateTable(
                "tblSMState",
                c => new
                    {
                        intStateID = c.Int(nullable: false, identity: true),
                        strState = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intStateID);
            
            CreateTable(
                "tblSMCurrency",
                c => new
                    {
                        intCurrencyID = c.Int(nullable: false, identity: true),
                        strCurrencyID = c.String(),
                        strDescription = c.String(),
                        dblActualRate = c.Decimal(nullable: false, precision: 18, scale: 2),
                        dblExchangeRate = c.Decimal(nullable: false, precision: 18, scale: 2),
                        dblBuy = c.Decimal(nullable: false, precision: 18, scale: 2),
                        dblSell = c.Decimal(nullable: false, precision: 18, scale: 2),
                        dtmDate = c.DateTime(nullable: false),
                        strSymbol = c.String(),
                        strMemo = c.String(),
                        intSort = c.Int(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intCurrencyID);
            
            CreateTable(
                "tblSMCurrencyDetail",
                c => new
                    {
                        intCurrencyDetailID = c.Int(nullable: false, identity: true),
                        dtmDate = c.DateTime(nullable: false),
                        dblExchangeRate = c.Decimal(nullable: false, precision: 18, scale: 2),
                        dblBuy = c.Decimal(nullable: false, precision: 18, scale: 2),
                        dblSell = c.Decimal(nullable: false, precision: 18, scale: 2),
                        strMemo = c.String(),
                        intCurrencyID = c.Int(nullable: false),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intCurrencyDetailID)
                .ForeignKey("tblSMCurrency", t => t.intCurrencyID, cascadeDelete: true)
                .Index(t => t.intCurrencyID);
            
            CreateTable(
                "tblSMImageFile",
                c => new
                    {
                        intImageFileID = c.Int(nullable: false),
                        imgFile = c.Binary(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intImageFileID)
                .ForeignKey("tblSMSecurityMenuList", t => t.intImageFileID)
                .Index(t => t.intImageFileID);
            
            CreateTable(
                "tblSMSecurityMenuList",
                c => new
                    {
                        intMenuID = c.Int(nullable: false, identity: true),
                        intParentID = c.Int(),
                        intProductID = c.Int(),
                        strName = c.String(),
                        intSort = c.Int(),
                        strType = c.String(),
                        ysnExpanded = c.Boolean(nullable: false),
                        strCommand = c.String(),
                        strDescription = c.String(),
                        strShortCutKey = c.String(),
                        imgIcon = c.Binary(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intMenuID);
            
            CreateTable(
                "tblSMMenuFavorite",
                c => new
                    {
                        intMenuFavoriteID = c.Int(nullable: false, identity: true),
                        intUserID = c.Int(),
                        intMenuID = c.Int(),
                        intParentID = c.Int(),
                        strType = c.String(),
                        strName = c.String(),
                        intSort = c.Int(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intMenuFavoriteID)
                .ForeignKey("tblSMSecurityMenuList", t => t.intMenuID)
                .Index(t => t.intMenuID);
            
            CreateTable(
                "tblSMMenuRecent",
                c => new
                    {
                        intMenuRecentID = c.Int(nullable: false, identity: true),
                        intUserID = c.Int(nullable: false),
                        intMenuID = c.Int(),
                        intParentID = c.Int(),
                        strType = c.String(),
                        strName = c.String(),
                        intSort = c.Int(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intMenuRecentID)
                .ForeignKey("tblSMSecurityMenuList", t => t.intMenuID)
                .Index(t => t.intMenuID);
            
            CreateTable(
                "tblSMMenuReport",
                c => new
                    {
                        intReportID = c.Int(nullable: false),
                        intMenuID = c.Int(),
                        intParentID = c.Int(),
                        intProductID = c.Int(),
                        strName = c.String(),
                        intImageIndex = c.Int(),
                        intSort = c.Int(),
                        strType = c.String(),
                        ysnExpanded = c.Boolean(nullable: false),
                        strCommand = c.String(),
                        intUserID = c.Int(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intReportID)
                .ForeignKey("tblSMSecurityMenuList", t => t.intMenuID)
                .ForeignKey("tblSMProduct", t => t.intProductID)
                .Index(t => t.intMenuID)
                .Index(t => t.intProductID);
            
            CreateTable(
                "tblSMProduct",
                c => new
                    {
                        intProductID = c.Int(nullable: false),
                        strProductName = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intProductID);
            
            CreateTable(
                "tblSMSecurityMenuUserDetail",
                c => new
                    {
                        intSecurityMenuUserDetailID = c.Int(nullable: false, identity: true),
                        intSecurityMenuUserID = c.Int(),
                        intParentID = c.Int(),
                        strType = c.String(),
                        intMenuID = c.Int(),
                        strCaption = c.String(),
                        strShortcutKey = c.String(),
                        imgIcon = c.Binary(),
                        intSort = c.Int(),
                        ysnExpanded = c.Boolean(),
                        intConcurrencyID = c.Int(),
                        tblSMSecurityMenuUserDetail2_intSecurityMenuUserDetailID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityMenuUserDetailID)
                .ForeignKey("tblSMSecurityMenuUser", t => t.intSecurityMenuUserID)
                .ForeignKey("tblSMSecurityMenuUserDetail", t => t.tblSMSecurityMenuUserDetail2_intSecurityMenuUserDetailID)
                .ForeignKey("tblSMSecurityMenuList", t => t.intMenuID)
                .Index(t => t.intSecurityMenuUserID)
                .Index(t => t.tblSMSecurityMenuUserDetail2_intSecurityMenuUserDetailID)
                .Index(t => t.intMenuID);
            
            CreateTable(
                "tblSMSecurityMenuUser",
                c => new
                    {
                        intSecurityMenuUserID = c.Int(nullable: false, identity: true),
                        strMenuUser = c.String(),
                        strDescription = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityMenuUserID);
            
            CreateTable(
                "tblSMSecurityUser",
                c => new
                    {
                        intUserID = c.Int(nullable: false, identity: true),
                        strUserID = c.String(),
                        strPassword = c.String(),
                        strOverridePassword = c.String(),
                        intSecurityUserGroupID = c.Int(nullable: false),
                        intSecurityMenuUserID = c.Int(),
                        strEmail = c.String(),
                        strManagerName = c.String(),
                        strAssistantName = c.String(),
                        strOffice = c.String(),
                        strDepartment = c.String(),
                        ysnMustChange = c.Boolean(),
                        ysnCantChange = c.Boolean(),
                        ysnDisabled = c.Boolean(),
                        ysnRememberUserName = c.Boolean(),
                        strGlobalLogin = c.String(),
                        strFieldKoToh = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intUserID)
                .ForeignKey("tblSMSecurityUserGroup", t => t.intSecurityUserGroupID, cascadeDelete: true)
                .ForeignKey("tblSMSecurityMenuUser", t => t.intSecurityMenuUserID)
                .Index(t => t.intSecurityUserGroupID)
                .Index(t => t.intSecurityMenuUserID);
            
            CreateTable(
                "tblSMPreferencesUser",
                c => new
                    {
                        intPreferenceUserID = c.Int(nullable: false, identity: true),
                        strFieldName = c.String(),
                        strFieldCaption = c.String(),
                        strFieldType = c.String(),
                        strFieldValue = c.String(),
                        intUserID = c.Int(nullable: false),
                        intUserGroupID = c.Int(nullable: false),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intPreferenceUserID)
                .ForeignKey("tblSMSecurityUser", t => t.intUserID, cascadeDelete: true)
                .Index(t => t.intUserID);
            
            CreateTable(
                "tblSMSecurityUserGroup",
                c => new
                    {
                        intSecurityUserGroupID = c.Int(nullable: false, identity: true),
                        strUserGroup = c.String(),
                        strDescription = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityUserGroupID);
            
            CreateTable(
                "tblSMSecurityUserGroupControl",
                c => new
                    {
                        intSecurityUserGroupControlID = c.Int(nullable: false, identity: true),
                        intSecurityUserGroupID = c.Int(),
                        intControlID = c.Int(),
                        strPermission = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityUserGroupControlID)
                .ForeignKey("tblSMSecurityUserGroup", t => t.intSecurityUserGroupID)
                .Index(t => t.intSecurityUserGroupID);
            
            CreateTable(
                "tblSMSecurityUserGroupMenu",
                c => new
                    {
                        intSecurityUserGroupMenuID = c.Int(nullable: false, identity: true),
                        intSecurityUserGroupID = c.Int(),
                        intMenuID = c.Int(),
                        strPermission = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityUserGroupMenuID)
                .ForeignKey("tblSMSecurityUserGroup", t => t.intSecurityUserGroupID)
                .ForeignKey("tblSMSecurityMenuList", t => t.intMenuID)
                .Index(t => t.intSecurityUserGroupID)
                .Index(t => t.intMenuID);
            
            CreateTable(
                "tblSMSecurityUserGroupForm",
                c => new
                    {
                        intSecurityUserGroupFormID = c.Int(nullable: false, identity: true),
                        intSecurityUserGroupID = c.Int(),
                        intFormID = c.Int(),
                        strPermission = c.String(),
                        intConcurrencyID = c.Int(),
                        tblSMSecurityFormList_intSecurityFormListID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityUserGroupFormID)
                .ForeignKey("tblSMSecurityFormList", t => t.tblSMSecurityFormList_intSecurityFormListID)
                .ForeignKey("tblSMSecurityUserGroup", t => t.intSecurityUserGroupID)
                .Index(t => t.tblSMSecurityFormList_intSecurityFormListID)
                .Index(t => t.intSecurityUserGroupID);
            
            CreateTable(
                "tblSMSecurityFormList",
                c => new
                    {
                        intSecurityFormListID = c.Int(nullable: false, identity: true),
                        intSecurityModuleListID = c.Int(nullable: false),
                        strFormName = c.String(),
                        strDisplayName = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityFormListID)
                .ForeignKey("tblSMSecurityModuleList", t => t.intSecurityModuleListID, cascadeDelete: true)
                .Index(t => t.intSecurityModuleListID);
            
            CreateTable(
                "tblSMSecurityControlList",
                c => new
                    {
                        intSecurityControlListID = c.Int(nullable: false, identity: true),
                        intSecurityFormListID = c.Int(nullable: false),
                        strControlType = c.String(),
                        strControlName = c.String(),
                        strDisplayName = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityControlListID)
                .ForeignKey("tblSMSecurityFormList", t => t.intSecurityFormListID, cascadeDelete: true)
                .Index(t => t.intSecurityFormListID);
            
            CreateTable(
                "tblSMSecurityUserControl",
                c => new
                    {
                        intSecurityUserControlID = c.Int(nullable: false, identity: true),
                        intControlID = c.Int(nullable: false),
                        strPermission = c.String(),
                        intUserID = c.Int(),
                        intConcurrencyID = c.Int(),
                        tblSMSecurityControlList_intSecurityControlListID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityUserControlID)
                .ForeignKey("tblSMSecurityControlList", t => t.tblSMSecurityControlList_intSecurityControlListID)
                .ForeignKey("tblSMSecurityUser", t => t.intUserID)
                .Index(t => t.tblSMSecurityControlList_intSecurityControlListID)
                .Index(t => t.intUserID);
            
            CreateTable(
                "tblSMSecurityUserDefault",
                c => new
                    {
                        intSecurityUserDefaultID = c.Int(nullable: false, identity: true),
                        intControlID = c.Int(nullable: false),
                        strDefaultValue = c.String(),
                        intUserID = c.Int(),
                        intConcurrencyID = c.Int(),
                        tblSMSecurityControlList_intSecurityControlListID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityUserDefaultID)
                .ForeignKey("tblSMSecurityControlList", t => t.tblSMSecurityControlList_intSecurityControlListID)
                .ForeignKey("tblSMSecurityUser", t => t.intUserID)
                .Index(t => t.tblSMSecurityControlList_intSecurityControlListID)
                .Index(t => t.intUserID);
            
            CreateTable(
                "tblSMSecurityUserRequired",
                c => new
                    {
                        intSecurityUserRequiredID = c.Int(nullable: false, identity: true),
                        intControlID = c.Int(nullable: false),
                        strRequireType = c.String(),
                        intUserID = c.Int(),
                        intConcurrencyID = c.Int(),
                        tblSMSecurityControlList_intSecurityControlListID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityUserRequiredID)
                .ForeignKey("tblSMSecurityControlList", t => t.tblSMSecurityControlList_intSecurityControlListID)
                .ForeignKey("tblSMSecurityUser", t => t.intUserID)
                .Index(t => t.tblSMSecurityControlList_intSecurityControlListID)
                .Index(t => t.intUserID);
            
            CreateTable(
                "tblSMSecurityModuleList",
                c => new
                    {
                        intSecurityModuleListID = c.Int(nullable: false, identity: true),
                        strModuleName = c.String(),
                        strDisplayName = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityModuleListID);
            
            CreateTable(
                "tblSMSecurityReportList",
                c => new
                    {
                        intSecurityReportListID = c.Int(nullable: false, identity: true),
                        intSecurityModuleListID = c.Int(nullable: false),
                        strReportName = c.String(),
                        strDescription = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityReportListID)
                .ForeignKey("tblSMSecurityModuleList", t => t.intSecurityModuleListID, cascadeDelete: true)
                .Index(t => t.intSecurityModuleListID);
            
            CreateTable(
                "tblSMSecurityUserForm",
                c => new
                    {
                        intSecurityUserFormID = c.Int(nullable: false, identity: true),
                        intFormID = c.Int(nullable: false),
                        strPermission = c.String(),
                        intUserID = c.Int(),
                        intConcurrencyID = c.Int(),
                        tblSMSecurityFormList_intSecurityFormListID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityUserFormID)
                .ForeignKey("tblSMSecurityFormList", t => t.tblSMSecurityFormList_intSecurityFormListID)
                .ForeignKey("tblSMSecurityUser", t => t.intUserID)
                .Index(t => t.tblSMSecurityFormList_intSecurityFormListID)
                .Index(t => t.intUserID);
            
            CreateTable(
                "tblSMSecurityUserMenu",
                c => new
                    {
                        intSecurityUserMenuID = c.Int(nullable: false, identity: true),
                        strPermission = c.String(),
                        intUserID = c.Int(nullable: false),
                        intMenuID = c.Int(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityUserMenuID)
                .ForeignKey("tblSMSecurityUser", t => t.intUserID, cascadeDelete: true)
                .ForeignKey("tblSMSecurityMenuList", t => t.intMenuID)
                .Index(t => t.intUserID)
                .Index(t => t.intMenuID);
            
            CreateTable(
                "tblSMMenuPreference",
                c => new
                    {
                        intPreferenceID = c.Int(nullable: false, identity: true),
                        intParentID = c.Int(),
                        strPreferenceName = c.String(),
                        strDescription = c.String(),
                        strAssembly = c.String(),
                        ysnShowDescription = c.Boolean(),
                        intSort = c.Int(),
                        strType = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intPreferenceID);
            
            CreateTable(
                "tblSMPreferencesCompany",
                c => new
                    {
                        intPreferenceCompanyID = c.Int(nullable: false, identity: true),
                        strFieldName = c.String(),
                        strFieldCaption = c.String(),
                        strFieldType = c.String(),
                        strFieldValue = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intPreferenceCompanyID);
            
            CreateTable(
                "tblSMSearch",
                c => new
                    {
                        intSearchID = c.Int(nullable: false, identity: true),
                        strApplicationName = c.String(),
                        strTableName = c.String(),
                        intUserID = c.Int(nullable: false),
                        strDefaultColumnMatching = c.String(),
                        ysnSort = c.Boolean(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSearchID);
            
            CreateTable(
                "tblSMSearchDefaultField",
                c => new
                    {
                        intDefaultFieldID = c.Int(nullable: false),
                        intSearchID = c.Int(nullable: false),
                        intSearchDetailID = c.Int(nullable: false),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intDefaultFieldID)
                .ForeignKey("tblSMSearchDetail", t => t.intSearchDetailID, cascadeDelete: true)
                .ForeignKey("tblSMSearch", t => t.intDefaultFieldID)
                .Index(t => t.intSearchDetailID)
                .Index(t => t.intDefaultFieldID);
            
            CreateTable(
                "tblSMSearchDetail",
                c => new
                    {
                        intSearchDetailID = c.Int(nullable: false, identity: true),
                        intSearchID = c.Int(nullable: false),
                        strColumnName = c.String(),
                        strColumnCaption = c.String(),
                        ysnColumnVisible = c.Boolean(nullable: false),
                        intWidth = c.Int(nullable: false),
                        intSort = c.Int(nullable: false),
                        strDataType = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSearchDetailID)
                .ForeignKey("tblSMSearch", t => t.intSearchID, cascadeDelete: true)
                .Index(t => t.intSearchID);
            
            CreateTable(
                "tblSMSearchDefaultFilter",
                c => new
                    {
                        intSearchDefaultFilterID = c.Int(nullable: false, identity: true),
                        intSearchID = c.Int(nullable: false),
                        intSearchDetailID = c.Int(nullable: false),
                        strCondition = c.String(),
                        strCriteria = c.String(),
                        strCriteriaBetween = c.String(),
                        strJoin = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSearchDefaultFilterID)
                .ForeignKey("tblSMSearchDetail", t => t.intSearchDetailID, cascadeDelete: true)
                .ForeignKey("tblSMSearch", t => t.intSearchID, cascadeDelete: true)
                .Index(t => t.intSearchDetailID)
                .Index(t => t.intSearchID);
            
            CreateTable(
                "tblSMSearchDefaultGroup",
                c => new
                    {
                        intSearchDefaultGroupID = c.Int(nullable: false, identity: true),
                        intSearchID = c.Int(nullable: false),
                        intSearchDetailID = c.Int(nullable: false),
                        strSortOrder = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSearchDefaultGroupID)
                .ForeignKey("tblSMSearchDetail", t => t.intSearchDetailID, cascadeDelete: true)
                .ForeignKey("tblSMSearch", t => t.intSearchID, cascadeDelete: true)
                .Index(t => t.intSearchDetailID)
                .Index(t => t.intSearchID);
            
            CreateTable(
                "tblSMSearchLockedField",
                c => new
                    {
                        intSearchLockedFieldID = c.Int(nullable: false),
                        intSearchDetailID = c.Int(),
                        strDescription = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSearchLockedFieldID)
                .ForeignKey("tblSMSearchDetail", t => t.intSearchDetailID)
                .ForeignKey("tblSMSearch", t => t.intSearchLockedFieldID)
                .Index(t => t.intSearchDetailID)
                .Index(t => t.intSearchLockedFieldID);
            
            CreateTable(
                "tblSMSearchMatching",
                c => new
                    {
                        intSearchMatchingID = c.Int(nullable: false, identity: true),
                        intSearchID = c.Int(nullable: false),
                        intSearchDetailID = c.Int(nullable: false),
                        strMatchType = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSearchMatchingID)
                .ForeignKey("tblSMSearchDetail", t => t.intSearchDetailID, cascadeDelete: true)
                .ForeignKey("tblSMSearch", t => t.intSearchID, cascadeDelete: true)
                .Index(t => t.intSearchDetailID)
                .Index(t => t.intSearchID);
            
            CreateTable(
                "tblSMSearchSorting",
                c => new
                    {
                        intSearchSortID = c.Int(nullable: false),
                        intSearchDetailID = c.Int(),
                        strSortOrder = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSearchSortID)
                .ForeignKey("tblSMSearchDetail", t => t.intSearchDetailID)
                .ForeignKey("tblSMSearch", t => t.intSearchSortID)
                .Index(t => t.intSearchDetailID)
                .Index(t => t.intSearchSortID);
            
            CreateTable(
                "tblSMSearchSavedSearch",
                c => new
                    {
                        intSMSearchSavedSearch = c.Int(nullable: false, identity: true),
                        strDescription = c.String(),
                        strName = c.String(),
                        dtmDateSaved = c.DateTime(),
                        intSearchID = c.Int(),
                        strFilter = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSMSearchSavedSearch)
                .ForeignKey("tblSMSearch", t => t.intSearchID)
                .Index(t => t.intSearchID);
            
            CreateTable(
                "tblSMSecurityPermissionGroup",
                c => new
                    {
                        intSecurityPermissionGroupID = c.Int(nullable: false, identity: true),
                        strPermissionGroup = c.String(),
                        strDescription = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityPermissionGroupID);
            
            CreateTable(
                "tblSMSecurityPermissionGroupControl",
                c => new
                    {
                        intSecurityPermissionGroupControlID = c.Int(nullable: false, identity: true),
                        intSecurityPermissionGroupID = c.Int(),
                        intControlID = c.Int(),
                        strPermission = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityPermissionGroupControlID)
                .ForeignKey("tblSMSecurityPermissionGroup", t => t.intSecurityPermissionGroupID)
                .Index(t => t.intSecurityPermissionGroupID);
            
            CreateTable(
                "tblSMSecurityPermissionGroupForm",
                c => new
                    {
                        intSecurityPermissionGroupFormID = c.Int(nullable: false, identity: true),
                        intSecurityPermissionGroupID = c.Int(),
                        intFormID = c.Int(),
                        strPermission = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityPermissionGroupFormID)
                .ForeignKey("tblSMSecurityPermissionGroup", t => t.intSecurityPermissionGroupID)
                .Index(t => t.intSecurityPermissionGroupID);
            
            CreateTable(
                "tblSMSecurityPermissionGroupMenu",
                c => new
                    {
                        intSecurityPermissionGroupMenuID = c.Int(nullable: false, identity: true),
                        intSecurityPermissionGroupID = c.Int(),
                        intMenuID = c.Int(),
                        strPermission = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityPermissionGroupMenuID)
                .ForeignKey("tblSMSecurityPermissionGroup", t => t.intSecurityPermissionGroupID)
                .Index(t => t.intSecurityPermissionGroupID);
            
            CreateTable(
                "tblSMSecurityPolicy",
                c => new
                    {
                        intSecurityPolicyID = c.Int(nullable: false, identity: true),
                        strPolicyGroup = c.String(),
                        strPolicy = c.String(),
                        strValueType = c.String(),
                        strValue = c.String(),
                        strDisplayValue = c.String(),
                        strDescription = c.String(),
                        intSecurityPolicyGroupID = c.Int(nullable: false),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityPolicyID)
                .ForeignKey("tblSMSecurityPolicyGroup", t => t.intSecurityPolicyGroupID, cascadeDelete: true)
                .Index(t => t.intSecurityPolicyGroupID);
            
            CreateTable(
                "tblSMSecurityPolicyGroup",
                c => new
                    {
                        intSecurityPolicyGroupID = c.Int(nullable: false, identity: true),
                        strPolicyGroupName = c.String(),
                        strPolicyGroupDescription = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intSecurityPolicyGroupID);
            
            CreateTable(
                "tblSMShipVia",
                c => new
                    {
                        intShipViaID = c.Int(nullable: false, identity: true),
                        strShipVia = c.String(),
                        strService = c.String(),
                        ysnCOD = c.Boolean(nullable: false),
                        intSort = c.Int(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intShipViaID);
            
            CreateTable(
                "tblSMTerm",
                c => new
                    {
                        intTermID = c.Int(nullable: false, identity: true),
                        strTerm = c.String(),
                        dblDiscount = c.Decimal(precision: 18, scale: 2),
                        intDay = c.Int(),
                        intDaysDue = c.Int(),
                        dblInterest = c.Decimal(precision: 18, scale: 2),
                        ysnShowOnRetail = c.Boolean(nullable: false),
                        ysnShowOnWhsle = c.Boolean(nullable: false),
                        intSort = c.Int(),
                        strType = c.String(),
                        dblDayOfMonth = c.Decimal(precision: 18, scale: 2),
                        dblDiscountDay = c.Decimal(precision: 18, scale: 2),
                        intMinDay = c.Int(),
                        ysnActive = c.Boolean(),
                        strDescription = c.String(),
                        intConcurrencyID = c.Int(),
                    })
                .PrimaryKey(t => t.intTermID);
            
        }
        
        public override void Down()
        {
            DropIndex("tblSMSecurityPolicy", new[] { "intSecurityPolicyGroupID" });
            DropIndex("tblSMSecurityPermissionGroupMenu", new[] { "intSecurityPermissionGroupID" });
            DropIndex("tblSMSecurityPermissionGroupForm", new[] { "intSecurityPermissionGroupID" });
            DropIndex("tblSMSecurityPermissionGroupControl", new[] { "intSecurityPermissionGroupID" });
            DropIndex("tblSMSearchSavedSearch", new[] { "intSearchID" });
            DropIndex("tblSMSearchSorting", new[] { "intSearchSortID" });
            DropIndex("tblSMSearchSorting", new[] { "intSearchDetailID" });
            DropIndex("tblSMSearchMatching", new[] { "intSearchID" });
            DropIndex("tblSMSearchMatching", new[] { "intSearchDetailID" });
            DropIndex("tblSMSearchLockedField", new[] { "intSearchLockedFieldID" });
            DropIndex("tblSMSearchLockedField", new[] { "intSearchDetailID" });
            DropIndex("tblSMSearchDefaultGroup", new[] { "intSearchID" });
            DropIndex("tblSMSearchDefaultGroup", new[] { "intSearchDetailID" });
            DropIndex("tblSMSearchDefaultFilter", new[] { "intSearchID" });
            DropIndex("tblSMSearchDefaultFilter", new[] { "intSearchDetailID" });
            DropIndex("tblSMSearchDetail", new[] { "intSearchID" });
            DropIndex("tblSMSearchDefaultField", new[] { "intDefaultFieldID" });
            DropIndex("tblSMSearchDefaultField", new[] { "intSearchDetailID" });
            DropIndex("tblSMSecurityUserMenu", new[] { "intMenuID" });
            DropIndex("tblSMSecurityUserMenu", new[] { "intUserID" });
            DropIndex("tblSMSecurityUserForm", new[] { "intUserID" });
            DropIndex("tblSMSecurityUserForm", new[] { "tblSMSecurityFormList_intSecurityFormListID" });
            DropIndex("tblSMSecurityReportList", new[] { "intSecurityModuleListID" });
            DropIndex("tblSMSecurityUserRequired", new[] { "intUserID" });
            DropIndex("tblSMSecurityUserRequired", new[] { "tblSMSecurityControlList_intSecurityControlListID" });
            DropIndex("tblSMSecurityUserDefault", new[] { "intUserID" });
            DropIndex("tblSMSecurityUserDefault", new[] { "tblSMSecurityControlList_intSecurityControlListID" });
            DropIndex("tblSMSecurityUserControl", new[] { "intUserID" });
            DropIndex("tblSMSecurityUserControl", new[] { "tblSMSecurityControlList_intSecurityControlListID" });
            DropIndex("tblSMSecurityControlList", new[] { "intSecurityFormListID" });
            DropIndex("tblSMSecurityFormList", new[] { "intSecurityModuleListID" });
            DropIndex("tblSMSecurityUserGroupForm", new[] { "intSecurityUserGroupID" });
            DropIndex("tblSMSecurityUserGroupForm", new[] { "tblSMSecurityFormList_intSecurityFormListID" });
            DropIndex("tblSMSecurityUserGroupMenu", new[] { "intMenuID" });
            DropIndex("tblSMSecurityUserGroupMenu", new[] { "intSecurityUserGroupID" });
            DropIndex("tblSMSecurityUserGroupControl", new[] { "intSecurityUserGroupID" });
            DropIndex("tblSMPreferencesUser", new[] { "intUserID" });
            DropIndex("tblSMSecurityUser", new[] { "intSecurityMenuUserID" });
            DropIndex("tblSMSecurityUser", new[] { "intSecurityUserGroupID" });
            DropIndex("tblSMSecurityMenuUserDetail", new[] { "intMenuID" });
            DropIndex("tblSMSecurityMenuUserDetail", new[] { "tblSMSecurityMenuUserDetail2_intSecurityMenuUserDetailID" });
            DropIndex("tblSMSecurityMenuUserDetail", new[] { "intSecurityMenuUserID" });
            DropIndex("tblSMMenuReport", new[] { "intProductID" });
            DropIndex("tblSMMenuReport", new[] { "intMenuID" });
            DropIndex("tblSMMenuRecent", new[] { "intMenuID" });
            DropIndex("tblSMMenuFavorite", new[] { "intMenuID" });
            DropIndex("tblSMImageFile", new[] { "intImageFileID" });
            DropIndex("tblSMCurrencyDetail", new[] { "intCurrencyID" });
            DropIndex("tblSMZipCode", new[] { "intCityID" });
            DropIndex("tblSMZipCode", new[] { "intCountryID" });
            DropIndex("tblSMZipCode", new[] { "intStateID" });
            DropIndex("tblSMCompanySetup", new[] { "intCityID" });
            DropIndex("tblSMCompanySetup", new[] { "intZipCodeID" });
            DropIndex("tblSMCompanySetup", new[] { "intStateID" });
            DropIndex("tblSMCompanySetup", new[] { "intCountryID" });
            DropForeignKey("tblSMSecurityPolicy", "intSecurityPolicyGroupID", "tblSMSecurityPolicyGroup");
            DropForeignKey("tblSMSecurityPermissionGroupMenu", "intSecurityPermissionGroupID", "tblSMSecurityPermissionGroup");
            DropForeignKey("tblSMSecurityPermissionGroupForm", "intSecurityPermissionGroupID", "tblSMSecurityPermissionGroup");
            DropForeignKey("tblSMSecurityPermissionGroupControl", "intSecurityPermissionGroupID", "tblSMSecurityPermissionGroup");
            DropForeignKey("tblSMSearchSavedSearch", "intSearchID", "tblSMSearch");
            DropForeignKey("tblSMSearchSorting", "intSearchSortID", "tblSMSearch");
            DropForeignKey("tblSMSearchSorting", "intSearchDetailID", "tblSMSearchDetail");
            DropForeignKey("tblSMSearchMatching", "intSearchID", "tblSMSearch");
            DropForeignKey("tblSMSearchMatching", "intSearchDetailID", "tblSMSearchDetail");
            DropForeignKey("tblSMSearchLockedField", "intSearchLockedFieldID", "tblSMSearch");
            DropForeignKey("tblSMSearchLockedField", "intSearchDetailID", "tblSMSearchDetail");
            DropForeignKey("tblSMSearchDefaultGroup", "intSearchID", "tblSMSearch");
            DropForeignKey("tblSMSearchDefaultGroup", "intSearchDetailID", "tblSMSearchDetail");
            DropForeignKey("tblSMSearchDefaultFilter", "intSearchID", "tblSMSearch");
            DropForeignKey("tblSMSearchDefaultFilter", "intSearchDetailID", "tblSMSearchDetail");
            DropForeignKey("tblSMSearchDetail", "intSearchID", "tblSMSearch");
            DropForeignKey("tblSMSearchDefaultField", "intDefaultFieldID", "tblSMSearch");
            DropForeignKey("tblSMSearchDefaultField", "intSearchDetailID", "tblSMSearchDetail");
            DropForeignKey("tblSMSecurityUserMenu", "intMenuID", "tblSMSecurityMenuList");
            DropForeignKey("tblSMSecurityUserMenu", "intUserID", "tblSMSecurityUser");
            DropForeignKey("tblSMSecurityUserForm", "intUserID", "tblSMSecurityUser");
            DropForeignKey("tblSMSecurityUserForm", "tblSMSecurityFormList_intSecurityFormListID", "tblSMSecurityFormList");
            DropForeignKey("tblSMSecurityReportList", "intSecurityModuleListID", "tblSMSecurityModuleList");
            DropForeignKey("tblSMSecurityUserRequired", "intUserID", "tblSMSecurityUser");
            DropForeignKey("tblSMSecurityUserRequired", "tblSMSecurityControlList_intSecurityControlListID", "tblSMSecurityControlList");
            DropForeignKey("tblSMSecurityUserDefault", "intUserID", "tblSMSecurityUser");
            DropForeignKey("tblSMSecurityUserDefault", "tblSMSecurityControlList_intSecurityControlListID", "tblSMSecurityControlList");
            DropForeignKey("tblSMSecurityUserControl", "intUserID", "tblSMSecurityUser");
            DropForeignKey("tblSMSecurityUserControl", "tblSMSecurityControlList_intSecurityControlListID", "tblSMSecurityControlList");
            DropForeignKey("tblSMSecurityControlList", "intSecurityFormListID", "tblSMSecurityFormList");
            DropForeignKey("tblSMSecurityFormList", "intSecurityModuleListID", "tblSMSecurityModuleList");
            DropForeignKey("tblSMSecurityUserGroupForm", "intSecurityUserGroupID", "tblSMSecurityUserGroup");
            DropForeignKey("tblSMSecurityUserGroupForm", "tblSMSecurityFormList_intSecurityFormListID", "tblSMSecurityFormList");
            DropForeignKey("tblSMSecurityUserGroupMenu", "intMenuID", "tblSMSecurityMenuList");
            DropForeignKey("tblSMSecurityUserGroupMenu", "intSecurityUserGroupID", "tblSMSecurityUserGroup");
            DropForeignKey("tblSMSecurityUserGroupControl", "intSecurityUserGroupID", "tblSMSecurityUserGroup");
            DropForeignKey("tblSMPreferencesUser", "intUserID", "tblSMSecurityUser");
            DropForeignKey("tblSMSecurityUser", "intSecurityMenuUserID", "tblSMSecurityMenuUser");
            DropForeignKey("tblSMSecurityUser", "intSecurityUserGroupID", "tblSMSecurityUserGroup");
            DropForeignKey("tblSMSecurityMenuUserDetail", "intMenuID", "tblSMSecurityMenuList");
            DropForeignKey("tblSMSecurityMenuUserDetail", "tblSMSecurityMenuUserDetail2_intSecurityMenuUserDetailID", "tblSMSecurityMenuUserDetail");
            DropForeignKey("tblSMSecurityMenuUserDetail", "intSecurityMenuUserID", "tblSMSecurityMenuUser");
            DropForeignKey("tblSMMenuReport", "intProductID", "tblSMProduct");
            DropForeignKey("tblSMMenuReport", "intMenuID", "tblSMSecurityMenuList");
            DropForeignKey("tblSMMenuRecent", "intMenuID", "tblSMSecurityMenuList");
            DropForeignKey("tblSMMenuFavorite", "intMenuID", "tblSMSecurityMenuList");
            DropForeignKey("tblSMImageFile", "intImageFileID", "tblSMSecurityMenuList");
            DropForeignKey("tblSMCurrencyDetail", "intCurrencyID", "tblSMCurrency");
            DropForeignKey("tblSMZipCode", "intCityID", "tblSMCity");
            DropForeignKey("tblSMZipCode", "intCountryID", "tblSMCountry");
            DropForeignKey("tblSMZipCode", "intStateID", "tblSMState");
            DropForeignKey("tblSMCompanySetup", "intCityID", "tblSMCity");
            DropForeignKey("tblSMCompanySetup", "intZipCodeID", "tblSMZipCode");
            DropForeignKey("tblSMCompanySetup", "intStateID", "tblSMState");
            DropForeignKey("tblSMCompanySetup", "intCountryID", "tblSMCountry");
            DropTable("tblSMTerm");
            DropTable("tblSMShipVia");
            DropTable("tblSMSecurityPolicyGroup");
            DropTable("tblSMSecurityPolicy");
            DropTable("tblSMSecurityPermissionGroupMenu");
            DropTable("tblSMSecurityPermissionGroupForm");
            DropTable("tblSMSecurityPermissionGroupControl");
            DropTable("tblSMSecurityPermissionGroup");
            DropTable("tblSMSearchSavedSearch");
            DropTable("tblSMSearchSorting");
            DropTable("tblSMSearchMatching");
            DropTable("tblSMSearchLockedField");
            DropTable("tblSMSearchDefaultGroup");
            DropTable("tblSMSearchDefaultFilter");
            DropTable("tblSMSearchDetail");
            DropTable("tblSMSearchDefaultField");
            DropTable("tblSMSearch");
            DropTable("tblSMPreferencesCompany");
            DropTable("tblSMMenuPreference");
            DropTable("tblSMSecurityUserMenu");
            DropTable("tblSMSecurityUserForm");
            DropTable("tblSMSecurityReportList");
            DropTable("tblSMSecurityModuleList");
            DropTable("tblSMSecurityUserRequired");
            DropTable("tblSMSecurityUserDefault");
            DropTable("tblSMSecurityUserControl");
            DropTable("tblSMSecurityControlList");
            DropTable("tblSMSecurityFormList");
            DropTable("tblSMSecurityUserGroupForm");
            DropTable("tblSMSecurityUserGroupMenu");
            DropTable("tblSMSecurityUserGroupControl");
            DropTable("tblSMSecurityUserGroup");
            DropTable("tblSMPreferencesUser");
            DropTable("tblSMSecurityUser");
            DropTable("tblSMSecurityMenuUser");
            DropTable("tblSMSecurityMenuUserDetail");
            DropTable("tblSMProduct");
            DropTable("tblSMMenuReport");
            DropTable("tblSMMenuRecent");
            DropTable("tblSMMenuFavorite");
            DropTable("tblSMSecurityMenuList");
            DropTable("tblSMImageFile");
            DropTable("tblSMCurrencyDetail");
            DropTable("tblSMCurrency");
            DropTable("tblSMState");
            DropTable("tblSMZipCode");
            DropTable("tblSMCountry");
            DropTable("tblSMCompanySetup");
            DropTable("tblSMCity");
        }
    }
}
