Free database scripting tool connected to the GIT repository.
Connect your database to GitHub, Bitbucket …
Co znajdziesz w tym artykule:
How it’s working
The program is written as a console application which can use parameters to script the database or selected functions or SQL procedures.
What does it mean to scripting?
The program connect to the database creates scripts and saves as * .sql files on the hard disk. It then connects to the Git repository and sends it as Commit.
It is a simple tool so we can easily keep an eye on the changes that occur in our database.
Using the Windows scheduler, we can set the possibility of scripting the entire database once every 24 hours and release individual changes after finishing work.
Download and unpack the program anywhere on your computer’s hard drive.
After unpacking, complete the parameters in the ScriptDatabase.exe.config file:
– RepoPath– path on the hard drive where the databases will be scripted
– Databases– database names separated by a semicolon eg Database1; Database2 In such a configuration, the program will script two databasesdanych.
–LoginSql– username for the SQL instance where the databases are stored
– PasswordSql– password for the user to the SQL instance on which the databases are stored
– ServerInstance– SQL server name or IP
– GitUserName– username for the GIT repository
– GitToken – API token or repository password
– GitUrl – GIT repository url
<add key=”RepoPath” value=”C:\Databases\Repo”/>
<add key=”Databases” value=”Database1;Database2″/>
<add key=”LoginSql” value=”sa”/>
<add key=”PasswordSql” value=”P@$$w0rd”/>
<add key=”ServerInstance” value=”192.168.56.101″/>
<add key=”GitUserName” value=”email@example.com”/>
<add key=”GitToken” value P@$$w0rd “/>
<add key=”GitUrl” value=”https://github.com/username/repogit.git”/>
Use cases – description of program parameters
ScriptDatabase.exe /? – help
ScriptDatabase.exe /clone the first command you need to execute to colonize the GIT repository
ScriptDatabase.exe /all command exports the entire database structure to files and then executes GIT commands (Pull Stage Commit Push)
ScriptDatabase.exe /commit executes GIT commands (Pull Stage Commit Push)
ScriptDatabase.exe /procedure:ProcedureName will script the selected routine and then execute GIT commands (Pull Stage Commit Push). As the name of the procedure, we give the name without the schema [dbo] and square brackets
ScriptDatabase.exe /function:FunctionName will script the selected function and then execute the commands GIT (Pull Stage Commit Push). As the name of the function, we give the name without the schema [dbo] and square brackets
Added to SQL Management Studio as External Tools
We can add two shortcuts to the Management studio that will make scripting and committing to the GIT repository easier.
We choose External Tools.
For the procedure we add
For functions we add
At startup, you only need to enter the name of the function or procedure