How to generate migration script using RedGate docker?

165 Views Asked by At

I was able to compare two SQL Server databases on linux using RedGate docker:

docker run --rm --interactive --tty\
    redgate/sqlcompare:14 /IAgreeToTheEULA \
    /s1:sql_docker_1,1433 /db1:Customers /u1:SA /p1:pass \
    /s2:sql_docker_2,1533 /db2:Customers /u2:SA /p2:pass

However, it only shows me a very coarse-grained comparison (only telling me that these two tables are not the same, but not showing me their differences).

Is it a way that I can get more information about comparison? I need column-level and index-level comparisons.

Also, how can I generate the migration script?

1

There are 1 best solutions below

0
Piers Williams On BEST ANSWER

Thanks for using Redgate SQL Compare!

Full disclaimer - I'm a developer on that product.

To generate a report you'll need to do two things:

1.) Mount a directory like this:

--mount type=bind,src="C:\Users\x\Documents",dst=/scripts

Which mounts your Windows documents folder to a folder /scripts within the docker container.

2.) Add two additional arguments to SQL Compare to generate a report and of which type:

/report:"/scripts/report.html" /reporttype:Html

Then to generate a migration script you must have mounted a directory like above and also add an additional argument to SQL Compare:

/scriptfile:"/scripts/script.sql"

This will give you a SQL script file that you can execute

These two steps gave me an interactive HTML report that showed the column change difference I made between the source and target: enter image description here

And a SQL Script file

My final command (redacted) was:

docker run --rm --interactive --tty --mount type=bind,src="C:\Users\x\Documents",dst=/scripts redgate/sqlcompare:14 /IAgreeToTheEULA /s1:x.example.com,1433 /db1:compare_source /u1:sa /p1:xxx /s2:x.example.com,1433 /db2:compare_target /u2:sa /p2:xxx /scriptfile:"/scripts/script.sql" /report:"/scripts/report.html" /reporttype:Html

The switches for reports came from https://documentation.red-gate.com/sc/using-the-command-line/switches-used-in-the-command-line#Switchesusedinthecommandline-/include:%3Ctype%3E:%3Cregularexpression%3E and generating a script came from https://documentation.red-gate.com/sc/using-the-command-line/using-the-command-line-on-linux