SQL Database Scripts
The scripts for creating or upgrading an SQL Server database are included with the CM4D Server and Client installers. These scripts are installed in a subfolder in the CM4D install directory: .\CM4D\Database Scripts\SQL scripts.
The SQL Scripts folder contains a number of script files for creating new databases, upgrading existing databases and maintenance scripts (e.g., re-index, drop stored procedures or wipe the database).
Running SQL Scripts manually on an existing database should ONLY be done by a qualified database administrator!
Each filename indicates the purpose of the script along with the schema version and database type (i.e., Site or CM4D database).
New Database Scripts
Scripts which are used to create a new empty database of each type
Create a clean empty CM4D Site database:
| Run Order | Script Name | Purpose | Reference |
| 1 | Site Tables.sql | Create the tables for a new Site database. | |
| 2 | Site Procedures.sql | Create stored procedures for the new Site database. | |
| 3 | Site Grants.sql | Grant access to the Site tables and stored procedures. | |
| 4 | Site Indexes.sql | Index the completed new Site database. |
Create a clean empty CM4D database:
| Run Order | Script Name | Purpose | Reference |
| 1 | Tables.sql | Create the tables for a new CM4D database. | |
| 2 | Procedures.sql | Create stored procedures for the new CM4D database. | |
| 3 | Grants.sql | Grant access to the CM4D tables and stored procedures. | |
| 4 | Indexes.sql | Index the completed new CM4D database. |
Upgrade Database Scripts
Scripts with the prefix 'UpdateSite' are used to upgrade CM4D Site databases.
The scripts without this prefix are used to upgrade the CM4D Datasource databases.
| Run Order | Script Name | Purpose | Reference |
| 1 | UpdateSite TablesXXn.sql | Create the tables for a new Site database. | |
| 2 | UpdateSiteProceduresXXn.sql | Create stored procedures to the new Site database tables. | |
Update CM4D databases:
| Run Order | Script Name | Purpose | Reference |
| 1 | UpdateTables.sql | Create the tables for a new CM4D database. | |
| 2 | UpdateProcedures.sql | Add procedures to the new CM4D database tables. | |
| 3 | UpdateGrants.sql | Grant access to the CM4D tables/procedures. | |
| 4 | UpdateIndexes.sql | Index the completed new CM4D database. |
Database Maintenance Scripts
Before removing any stored procedure, check for dependent objects and modify these objects accordingly. Dropping a stored procedure can cause dependent objects and scripts to fail when these objects are not updated.
Can we improve this topic?