Command line tool (or API) for SQL Source Control Integration
We have an automated system for building our developer environments. It would be nice to have a command line tool that we can use as part of the machine build script to pull down the latest version of the database, build the initial database and link that database back to the TFS source. Our platform consists of quite a large number of databases so linking to them all manually via the UI is a bit tedious.
Thank you everyone for the suggestions and votes for this over the years.
I’d like to surface up a workaround for the “linking” problem which is mentioned in the comments. For the use case of easing pains around environment setup with a large number of databases, we have had customers find success using code based off Alessandro Alpi’s blog post: https://alessandroalpi.blog/2016/06/28/automatically-link-databases-to-red-gate-sql-source-control/
I do understand that this is a broader issue and hear that many of you also want command line or API support for the product in general.
If there are specific scenarios or workflows that would be useful to automate for you, this feedback is also very useful, and if you have details on the type of VCS you use and the workflow (such as a branching model) that it would fit in to, that would be very helpful for us to hear as well.
-
Jim commented
Hi Kendra,
I went and looked at Alessandro's blog post. While it "works", it is readily apparent that PowerShell is not his best skillset. I have forked his github repository and will clean it up into something more serviceable. Features like this would really be better served by providing cmdlets very similar to the SQL Change Automation product that will provide the functions customers would need to automate the most used operations in their CICD processes.
Link an existing database
Get Latest
Get Latest by tagMarketing your product as the pathway to CICD and then leaving these gaps in your implementation is unexpected.
Jim
-
Jim commented
Hi David,
I can only speak for myself, but as our environments become more fluid and virtual, the manual linking of the database would be replaced with optimally a PoSH command with parameters to perform the link action and get latest from a branch which is passed in as a parameter. We have 10 or so developers and each developer manually linking a dozen or so databases can get expensive as compared to when we can take a configuration management approach and automate the whole process freeing up the lost developer time. -
Toby Riley commented
I pop over every year to see if this has got any traction, sadly not. I would be a nice feature to be able to automate this process.
-
It's worth also adding that we do already have command lines that allow this. To see your changes you can use sqlcompare.exe to compare your dev DB with your local scripts folder, and provided you wan to pull all the changes down, you can so this with the /sync switch. Choosing a subset is possible, but tricky, hence my previous question.
-
This is a great idea, and one that we will have to address as the popularity of VSCode and Azure Data Studio increases. How do you see the commands looking, and how would you expect to interact with them? For example, if there are 10 changes to your dev DB, and you want to commit a subset, how would this work?
-
Anonymous commented
I love Redgate toolkit and SQL Source Control, but would like to integrate it into other tools and processes. Creating a CLI or Powershell (PS) module that allows users to check a database for changes and check in those changes from the command line would be awesome. I am already going to PS to create branches and it would be nice to just check in my change while I'm there.
I would also love to see the ability to manage DB connections for SSMS, VS and VSCode in one location.
-
Claude commented
I am very surprised there is still no way to automate the tedious process to linking up databases , or any other operations with SQL Source Control, via some CLI. So much clicking involved when you have to link dozens of DBs.
Then once the DBs are linked things get worse since for every commit & pull one has to wait for sqlsource to crunch the differences before you can go to the next step. On large databases, especially remote ones, it's really rough. -
Anonymous commented
deal breaker
-
gvdm commented
Nine years and no development for a CLI to be able to link and unlink DBs to source control. Moreover the tool is very slow in checking the DB changes to commit and the fact that we have to perform this action manually and not via a CLI is very tedious and time consuming.
-
Grant commented
This would be a very beneficial feature if not almost required. When your trying to source control a large amount of databases over multiple servers then try to have a large team hook into it, its more then a tedious effort for our developers.
-
VIJAY AELLA commented
Please make sure the all the databases are linked by admin to not make any mistakes in linking by the developer.
-
Tony Paille commented
RedGate - this has been a request for over 5 years now, and is a pain point for *many* people. When can we get some traction here and make people's lives easier? SSC is a great tool: not having this capability is positively mystifying.
-
Greg commented
We are interested in this as well!
-
Alec Joiner commented
Aside from even the CI/CD reasons for wanting a command line tool, SQL Server Management Studio and SQL Source Control are two of the slowest products I have ever used in my entire life, and by their powers combined an experience is created that is borderline unusable.
If comprehensive command line tools existed, instead of SQL Source Control being tied to SQL Management Studio, people would be able to integrate SQL Source Control into whatever tool they see fit.
-
Jon commented
I had this comment from Robert Clenshaw from RedGate -
Although there isn't a native way to relink databases, you might want to look at Alessandro Alpi's blog post on this subject as he's written his own Powershell script to do the job. We can't support this as it's not our code, but if this is a major pain point for you then you might want to consider it. Here's the link - https://suxstellino.wordpress.com/2016/06/28/automatically-link-databases-to-red-gate-sql-source-control/
-
Justin commented
Please get this done!
Linking all the databases manually sucks. Each folder in SVN matches the dbname, just auto link the whole instance! :)
-
Mike commented
Also checking in to see if there is any update here. We want to roll out some 18 database links to about 30 people, which may not seem like a lot, but it's time that we could save if this process were possible. Looks like the workaround still doesn't work, I was hoping I could just write a script to add XML to each user's machine, but that doesn't seem possible.
-
Carlos commented
If you are still looking for testers, I am interested.
-
Justin bird commented
Just checking in to see whether there's been progress here...having to re-link databases because I now have a new profile gah! To reiterate my point, if you aren't linked to source control yourself, the database still has an extended properties entry which states the location of the current check-in. A "we've identified a location, do you want to re-use it" type question would be most helpful.
-
Anonymous commented
Same problem. Hundreds of databases, multiple developers. We need the ability to copy the config out to all developers without error or duplication.