Skip to content

Support multi-database migrations #2052

Open
@DanielTuran

Description

@DanielTuran

Is your feature request related to a problem? Please describe.
In Postgres server, I need to perform these steps in these exact order:

  1. Call a function in "postgres" database (pgaadauth_create_principal())
  2. Create schema objects in "my-application" database
  3. Call a function in "postgres" (`cron.schedule_in_database(... , ... ,'my-application'))

Describe the solution you'd like
To be discussed, but:

  1. Add some hooks, that will allow to run custom C# code before or after migration step, such as:
    void BeforeUp();
    
    This would allow me to write custom C# code that executes custom script in different database.
    public void BeforeUp()
    {
      using var connection = new NpgsqlConnection(postgresConnStr);
      connection.Open();
      using var jobCommand = connection.CreateCommand();
      jobCommand.CommandText = $"""
    	SELECT cron.schedule_in_database('{CleanupJobName}','0 1 * * 6', 'CALL "{AppSchema}"."DbCleanup"();', 		 
          """;
      jobCommand.ExecuteNonQuery();
    }
    
  2. Allow connection string customization per migration
  3. Allow to setup multiple Migrators each with its own set of migrations and connectionstring + create RunnerOrchestrator

Is this a feature you'd like to submit a PR for?
if we agree on API design...

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureA new feature (we all like those)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions