ApexSQL Source Control
This article explains how to create and use Git, Mercurial, and Subversion local file repositories with ApexSQL Source Control
The local file system repository is intended for single users as a solution for the application testing and evaluation purposes. The advantages of a local repository are easy setup and fast local data transfer since it bypasses the source control server. However, it is not recommended as a long-term solution because it is difficult to share it with other team members and setup a proper security for the repository.
The database can be linked to the local file system repository with ApexSQL Source Control through local file access protocol.
To create a local file system repository:
- Download and install Git source control system with Git Bash
- Start Git Bash
- Type git init –bare <directory> to create a bare repository directory
Example: “git init –bare /c/repository” will create an empty repository in C:/repository
Alongside with the repository directory, a .git subdirectory in the repository root will be created, containing all of the necessary metadata. For more information, see the Git documentation.
The local file system repository can be created by cloning the existing remote Git repository accessible via HTTP, HTTPS and SSH protocols. To do so, in Git Bash type git clone <url> <directory> (example: git clone https://github.com/test /c/repository)
To create a local file system repository using TortoiseHg:
- Download and install TortoiseHg
In Windows Explorer, right-click on a folder where the repository will be created and from the TortoiseHg submenu, select the Create Repository Here option:
In the New Repository dialog box, specify the repository name in the Destination path box and click the Create button:
Alternatively, a Mercurial repository can be created from the CLI. To do that:
- Start Command Prompt
- Type hg init <directory_path> (example: hg init E:\Mercurial\Repository)
To create a local file system repository using TortoiseSVN:
- Download and install TortoiseSVN
- Create a new folder on a local hard drive to set it as a local repository
Right-click on the newly created folder and from the TortoiseSVN submenu, select the Create repository here option:
Make sure that the folder is empty and not write protected to prevent errors during the repository creation process
A repository will be created inside the new folder and a confirmation dialog will appear:
To determine whether to create a directory structure within the repository, check out the Subversion documentation section called “Repository Layout”.
It is strongly recommended to use an empty folder as a local repository, or a folder with the same structure as ApexSQL Source Control uses
Alternatively, Subversion repository can be created from the CLI. To do that:
- Open the Command Prompt interface
- Type the following command svnadmin create <directory>
Example: svnadmin create C:\SVNRepository
TortoiseSVN will set a custom folder icon when creates a repository so that local repositories can be easily identified, unlike when the repository is created using the CLI.
To link the database to the local file system repository with ApexSQL Source Control:
In SQL Server Management Studio, right-click a database from the Object Explorer pane, and from the context menu, select the Link database to source control option:
In the Connection type step of the Source control wizard, specify source control system:
In the System login step provide Repository path in the form of:
Repository path should be specified in the same manner, regardless of the source control system that is used
In case of using the local repository, username and password are not mandatory
Additionally, the user can create a new folder in the repository.
After the linking process is completed, ApexSQL Source Control will store all the necessary script files in the local file system repository.
Q: What are the pros\cons of using a local file system repository?
A: Pros: Fast, easy adjustments and if there is no need for extra security it can be used inside internal LAN.
Cons: Anybody can delete the repository, by accident. Security can be jeopardized in case access is enabled over Internet.
Q: Is it possible to use network drive as a local file system repository?
A: Yes, it is possible to use network drive as a central store point without a problem, in case all developers are in the same LAN environment.
Q: Why can’t other source control systems that ApexSQL Source Control supports be used with a local file system repository?
A: Because only Git, Mercurial and SVN support creation of the file system repository which can be accessed using the file protocol.
Q: Which database development models can be used with a local file system repository?
A: Both models, Shared and Dedicated can be used with a local file system repository.