/// <summary> /// Get directory value from configuration file /// </summary> /// <param name="directoryType">The type of directory to get</param> /// <returns>Value from Migratio configuration file</returns> /// <exception cref="ArgumentOutOfRangeException">Invalid directory type given</exception> private string GetSystemDirFromConfig(MigratioDirectory directoryType) { switch (directoryType) { case MigratioDirectory.Base: return(Config?.Directories?.Base); case MigratioDirectory.Rollout: return(Config?.Directories?.Rollout); case MigratioDirectory.Rollback: return(Config?.Directories?.Rollback); case MigratioDirectory.Seeders: return(Config?.Directories?.Seeders); default: throw new ArgumentOutOfRangeException(nameof(directoryType), directoryType, "Unknown directory type"); } }
/// <summary> /// Get default Migratio directory name /// </summary> /// <param name="directoryType">The type of directory to get</param> /// <returns>Default folder name</returns> /// <exception cref="ArgumentOutOfRangeException">Invalid directory type given</exception> private string GetDefaultSystemDir(MigratioDirectory directoryType) { switch (directoryType) { case MigratioDirectory.Base: return("migrations"); case MigratioDirectory.Rollout: return("rollout"); case MigratioDirectory.Rollback: return("rollback"); case MigratioDirectory.Seeders: return("seeders"); default: throw new ArgumentOutOfRangeException(nameof(directoryType), directoryType, "Unknown directory type"); } }
/// <inheritdoc /> /// <exception cref="Exception">Unable to determine directory for the given directoryType</exception> public string GetMigratioDir(string migrationBaseDir, string configPath, MigratioDirectory directoryType) { var configBase = Path.GetDirectoryName(configPath); var fromConfigFile = GetSystemDirFromConfig(directoryType); if (migrationBaseDir != null) { return(Path.GetFullPath(Path.Combine(migrationBaseDir, GetDefaultSystemDir(directoryType)))); } if (Path.IsPathRooted(fromConfigFile)) { return(fromConfigFile); } if (configBase == null) { throw new Exception("Unable to determine directory"); } return(Path.GetFullPath(Path.Combine(configBase, fromConfigFile))); }