Evolve icon indicating copy to clipboard operation
Evolve copied to clipboard

Inconsistent behavior in treating paths in Evolve.Evolve() on Windows and Linux

Open master0luc opened this issue 2 years ago • 1 comments

migration scripts are diposed in "{ProjectFolder}\db\migrations*.sql;" This task is invoked on statrup:

 public abstract class DbMigrationTask : IStartupTask
  {
      protected readonly string _connectionString;
      private readonly string _databaseSchema;
      private readonly ILogger<DbMigrationTask> _logger;

      protected DbMigrationTask(string connectionString, ILogger<DbMigrationTask> logger)
      {
          _connectionString = connectionString;
          _logger = logger;
      }

      protected DbMigrationTask(string connectionString, ILogger<DbMigrationTask> logger, string databaseSchema)
      {
          _connectionString = connectionString;
          _databaseSchema = databaseSchema;
          _logger = logger;
  	}

  	public virtual Task ExecuteAsync()
      {
          try {
              using (var connection = new NpgsqlConnection(_connectionString)) {
                  var evolve = new Evolve.Evolve(connection, msg => _logger.LogInformation(msg)) {
                      IsEraseDisabled = true,
                      CommandTimeout = 600
                  };
                //HERE ADD FOLDERS
                  evolve.Locations = new[] {
                        Path.Combine("db", "migrations")
                  };
                  evolve.Migrate();
              }
          }
          catch (Exception e)
          {
  				switch (e) {
  					case NpgsqlException npgsqlException
  						when npgsqlException.Message.StartsWith("The connection pool has been exhausted") ||
  								npgsqlException.Message.StartsWith("Exception while reading from stream"):
  					case PostgresException postgresException
  						when postgresException.SqlState == "57P03":
  						_logger.LogCritical("Database migration failed.", e);
  						throw;
  					default:
  						break;
  				}
          }

          return Task.CompletedTask;
      }
  }

So, path is "db/migrations/" and on Linux SQL scripts are not found => and it is correct behavior BUT on Windows SQL scripts are perfectly found. From my undestanding, on Windows Scripts shall not be found either

master0luc avatar Mar 21 '22 11:03 master0luc

This is normally a case sensitivity issue. Have you resolved it?

sjd23 avatar Oct 16 '23 06:10 sjd23