Skip to content

Add WithDatabaseBackup to SQL Server integration #15839

@Chicoo

Description

@Chicoo

Is there an existing issue for this?

  • I have searched the existing issues

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

In development you might not always want to start from an empty database, but you might have a backup that is used by all developers.
This is adding extra steps for the developers during the onboarding and it requires a manual restore when the developer needs to have a clean database.

Describe the solution you'd like

Add a new extension to the SQL Server database integration

var sql = builder.AddSqlServer("sql")
                 .WithLifetime(ContainerLifetime.Persistent);

var db = sql.AddDatabase(databaseName)
                 .WithDatabaseRestore(string backupFilepath)

The method should check if the database exits, if it does exist it does nothing. If the database does not exist it will create the database using the backup file.

The feature should also add a restore command to the sql resource in the dashboard. The command should force the restore of the backup on the existing database.

This helps the dev experience when the database exists, but the developer wants to start with a "clean" database.

Additional context

I have looked into adding the feature to the SQL Server Community integration, but this is a cleaner way. When using the community integration first the database needs to be created and only then the backup can be restored.

I already have a large part of the code ready as we are using it in our projects, so I am happy to contribute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions