private void EnableMigrations(string[] args) { var criteriaParmas = ParseParams(args); var criteria = new EnableMigrationsCriteria { ProjectPath = criteriaParmas.ProjectPath, RepoName = criteriaParmas.OptionalRepoName, ConfigFilePath = criteriaParmas.ConfigFilePath, }; var setup = new SchemaSetup(); setup.EnableMigrations(criteria); }
/// <summary> /// Enables the ability for that project to be able to use NHibernate Repo migrations, automatic or manual. /// </summary> public void EnableMigrations(EnableMigrationsCriteria criteria) { MessageFilter.Register(); var repoInfo = TypeHandler.FindSingleRepo(criteria.ProjectPath, criteria.RepoName); //if it is null something is wrong so drop out. if (repoInfo == null) return; AssertRepoHasEmptyConstructor(repoInfo.RepoType); EnsureDbAndMigrationTableExists(criteria.ProjectPath, repoInfo.RepoType, criteria.ConfigFilePath); var repoBase = TypeHandler.CreateRepoBase(repoInfo.Assembly.Location, repoInfo.RepoType); //create migration log table, if it doesn't exist. var updater = CreateSchemaUpdater(criteria.ProjectPath, typeof(MigrationRepo), criteria.ConfigFilePath, repoBase.ConnectionStringOrName); updater.Execute(true, true); bool multipleFound = false; var configType = TypeHandler.FindSingleConfiguration(criteria.ProjectPath, repoInfo.RepoType, out multipleFound); //this should not happen. should only ever have one config per repo type. if(multipleFound) return; if (configType == null) { LoggerBase.Log("Adding migration configuration"); var filePath = new ConfigurationFileHandler().CreateConfigurationFile(criteria.ProjectPath, repoInfo.RepoType.Name, "Migrations", MigrationToUse.Manual); new ProjectDteHelper().AddFile(criteria.ProjectPath, "Migrations", filePath, showFile: true); } else { LoggerBase.Log("System is already configured for migrations, see class: " + configType.Name); } //clean up ProjectEvalutionHelper.FinishedWithProject(criteria.ProjectPath); MessageFilter.Revoke(); }