erikbra / grate

grate - the SQL scripts migration runner
MIT License
209 stars 40 forks source link

Add "WITH MOVE" configuration to database restore #593

Open franhoey opened 3 weeks ago

franhoey commented 3 weeks ago

Is your feature request related to a problem? Please describe. When restoring MS SQL Server databases the log and data files are restored to the same file location they held on the computer where the backup was made. If the database is restored to a different computer and the folder structure defined by the original file locations do not exist, the restore fails. This becomes an issue when working in a team who do not have a standard setup or restoring data between local machines and alternatively configured test or production environment servers. Or in my case when I tried to execute the restore on a newly built laptop.

Describe the solution you'd like This is tricky, because grate needs to be agnostic to database type. My suggestion is to allow a mix of data formats to the Restore configuration item. Either a simple string as it currently is to the backup file, or a structured string similar to the Folder configuration (name-value separated by semi-colon) to add additional parameters e.g. "file=C:/path/file.bak;move=database|D:/data/filename.mdf;move=database_log|D:/logs/filename.ldf"

Describe alternatives you've considered We could use JSON in the configuration value, but this hasn't been used in other configurations New configurations could be added e.g. RestoreMove, but this would then be specific to MS SQL Server, where as a configuration string format in the Restore configuration setting would allow specific config to be used on other database types in the future

Additional context N/A

franhoey commented 3 weeks ago

I get time in my job when things are slow I could use to complete this issue it that is helpful