Exemplo n.º 1
0
        private static List <string> GetOrderedScriptPaths(SqlFolders sqlFolders)
        {
            List <string> scripts = new List <string>();

            //goes through folders in the order they are in the app settings
            //and adds filepaths sorted alphabetically per folder.
            foreach (string folder in sqlFolders.SqlScripts)
            {
                scripts.AddRange(Directory.GetFiles(Path.Combine(sqlFolders.SqlRoot, folder), "*.sql").ToList().OrderBy(name => name, StringComparer.InvariantCulture));
            }

            return(scripts);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            IConfiguration config             = LoadConfiguration();
            PostgresConfig pgconf             = config.GetSection("PostgreSQL").Get <PostgresConfig>();
            SqlFolders     sqlFolders         = config.GetSection("SqlFolders").Get <SqlFolders>();
            string         pgConnectionString = BuildConnectionString(pgconf);

            List <string> scripts = GetOrderedScriptPaths(sqlFolders);

            foreach (string s in scripts)
            {
                ExecuteSqlScript(s, pgConnectionString);
            }
        }