Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
master0luc opened this issue Mar 21, 2022 · 1 comment

Comments

@master0luc
Copy link

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

@sjd23
Copy link

sjd23 commented Oct 16, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants