This article describes how to link a SQL Server database to a Perforce repository that is installed on a dedicated machine (local or a remote one).
Linking a database to a cloud repository is already covered where the Perforce repository hosted on Assembla.com is used as an example. Detailed information about using the cloud-based Perforce repository on Assembla.com can be found in the How to link a SQL Server database to an Assembla.com repository using Perforce article.
Before linking a database to a Perforce repository, whether on a local machine (the same machine where ApexSQL Source Control is installed) or to a remote one (Perforce server/repository is not on the same machine where ApexSQL Source Control is installed), there are requirements that must be fulfilled, before the linking process:
- Perforce Server must be installed and set
- To install the Perforce Server, use the Helix versioning engine
Make sure that the Server component is included in the installation process:
By default, a Perforce Server on a local machine is accessed using the localhost:1666 address, where 1666 is a default port that is used for Perforce
- Once the Perforce Server is installed, a SQL Server database can be linked to a Perforce repository.
Since the process of linking a database to source control is already covered in the How to link a database to a source control system article, where all the steps in the Source control setup window are explained (steps that are common for any source control system), we’ll focus on specific information that should be passed when linking to a Perforce repository.
An important step is to choose Perforce from the Source control system drop-down list, in the Connection type step of the Source control setup window:
Another important step is to pass the appropriate values in the System login tab of the Source control setup window (the final step in the linking process). When choosing Perforce as a source control system in the first step, the final step will be as follows:
Username and password
When linking a database to a Perforce Server that is hosted on a local machine, credentials can be omitted. Even if the client machine where ApexSQL Source Control is installed is in the same domain as the machine where the Perforce Server is installed, credentials can be omitted. If, for any reason, credentials are mandatory, they can be specified.
The Host field should contain the address of the Perforce Server. When a local machine is used, it is sufficient to specify localhost:1666 (which is a default address).
When installing a Perforce Server, a default depot will be created called “depot”. Assuming that default depot will be used the System login step will be as follows:
All available depot types are supported by ApexSQL Source Control
A Perforce workspace is important because if it is not specified, a Perforce depot can be accessed, but file exchange could not be available. Since we’ll need a Perforce depot to commit SQL database files, a workspace is mandatory.
A workspace name cannot contain special characters (! @, #, $, etc.) and cannot be specified using numbers only. If numbers are to be used in a workspace name, they must be used in combination with letters
It is important to mention that workspaces for each linked database must be unique for each user. This means that if one developer created a workspace called, for example, Test, other developers could not specify the same workspace, even if a different depot is used.
Let’s specify a workspace called Dev01Test for the purpose of this article.
Now that we have all the required information, a SQL Server database can be linked by clicking the Finish button in the bottom right section of the Source control setup window:
Q: Is it possible to use a single depot for linking multiple databases?
A: Yes, as long as the workspace for each database is different.
Q: What happens when linking a database to a workspace where another database is already mapped?
A: The error message appears saying that the specified workspace is already in use:
Q: Is it possible to link a SQL Server database to a Perforce repository using both dedicated and shared development models?
A: Yes, selecting a development model is irrelevant in this case. Like with other natively supported source control systems, a database can be linked using any of the available development models.
Q: What happens if the non-exited depot is specified in the Depot field?
A: A warning message appears saying that the specified depot name does not exist:
Q: If the Perforce Server is installed on a dedicated machine, is there anything specific that must be installed on a client-side?
A: No, if the Perforce Server is on a remote machine, the client will need SQL Server Management Studio and ApexSQL Source Control installed. Assuming that a valid connection exists between the client and a server machine, no additional configuration is required on a client-side in order to link a database to a Perforce repository.
Q: Is it possible to review available depots created on a Perforce Server using ApexSQL Source Control?
A: No, this is not available to achieve using ApexSQL Source Control.
To review existing depots on a Perforce Server, a command-line client, or any GUI client is required to be installed. To get a list of all available depots, execute the following command using the Perforce command-line client:
The result will be similar to the following:
Depot depot 2020/03/06 local depot/… ‘Default depot’
Depot depot_test 2020/03/06 local depot_test/… ‘Created by Kruso. ‘
Depot depotkruso 2020/03/06 local depotkruso/… ‘Created by Kruso. ‘
Depot streamsDepot 2020/03/06 stream 1 streamsDepot/… ‘Created by Kruso. ‘