# Database Setup Project
This directory contains the Inno Setup script for building a setup package for the Process Director database. The setup package works the same for both FEMA and LPNU branches of the database.

## Configuration Variables
During installation using the compiled setup package for the database, the user is prompted for values for the following configuration variables:

1. PDAdmin login password.
2. SQL Server 2022 instance.

The PDAdmin login password and SQL Server 2022 instance are passed to `sqlcmd` to create the Process Director database, create a new SQL Server login for PDAdmin, and map the new login to a database user with role assignments.

## Dependencies
[SQL Server 2022](https://www.microsoft.com/en-us/sql-server/sql-server-2022) is required to host the Process Director database. **Note:** This dependency is not satisfied by the setup package, as this configuration is very manual.

## Additional Notes
1. When building the database setup package, the `PublishPath` pre-processor variable in the Inno Setup script ([Database_Setup.iss](Database_Setup.iss)) should be set to the `sql` directory where the following SQL scripts are located: `ProcessDirector.sql` (publish script generated by Visual Studio), `PDAdmin.sql` (from `IWS5.Database/Security`), and `RoleMemberships.sql` (from `IWS5.Database/Security`).
2. The setup package for the database is compatible with x64-based systems only, as SQL Server 2022 is 64-bit only.
3. If there are no SQL Server 2022 instances installed on the target machine, the setup will be aborted. There is no way to bypass this check.
4. By default, only the default SQL Server 2022 instance on the target machine can be used and the dropdown to select a different instance is disabled. To attempt installation to another instance, launch the setup executable from the command line with the flag: `/EnableInstanceSelect=true`. **Note:** The installation will likely fail due to a mismatch between the service accounts used by `sqlcmd` when creating the database.
5. The logs of each script run by `sqlcmd` are output to the installation directory.