Skip to content

[Feature] Add Migration Support for MSSQLΒ #29

@MrDwarf7

Description

@MrDwarf7

Is your feature request related to a problem? Please describe.

Migrations are a valuable feature for managing database schemas, but the lack of MSSQL support in the main sqlx crate means users of sqlx_oldapi miss out on this functionality. This creates challenges in achieving feature parity with other supported databases.

Describe the solution you'd like

I would like to confirm if implementing the MigrateDatabase and Migrate traits is sufficient to enable migration support for the MSSQL backend.

A secondary component would be potentially enabling the macro support for migrate!() though I've not looked into if it uses the same underlying implementation as of yet.

If so, I'm happy to contribute an implementation, along with any necessary tests.
I understand that testing for MSSQL can be troublesome at the best of time- and am aware it also partially contributed to its removal from upstream. That being said- I'm down to give it a crack + any creating tests if/as needed.

Describe alternatives you've considered

None applicable, upstream sqlx dropped MSSQL support some time ago.

Additional context

The goal is to enable code like the following:

        let (connection_timeout, idle_timeout, max_lifetime) = Self::pool_opts(config);

        let client = sqlx::mssql::MssqlPoolOptions::new()
            .idle_timeout(idle_timeout)
            .max_connections(config.db_pool_total_connections() as u32)
            .max_lifetime(max_lifetime)
            .acquire_timeout(connection_timeout)
            .connect(&Self::format_connection_string(config)?)
            .await?;

        let migrator = sqlx::migrate::Migrator::new(std::path::Path::new("../../migrations"))
            .await?;
        migrator.run(&client).await?;

Currently, this fails because the MSSQL implementation lacks the Migrate trait, which is required by run_direct (expecting C: Migrate).

I'm eager to attempt this implementation, though I note that I have no prior experience with database backend implementations.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions