Atlas Forms
Deploying Tenant Overrides
Tenant overrides are deployed as separate SQL data files in a tenant-specific subfolder, with their own deploy script. They run after the base group scripts, ensuring the base forms exist before any override rows are inserted.
Folder Structure
BizFirstFiV3DB/dbo/Data/AtlasForms/
GuardRails/ ← base group scripts
GuardRails_Category.data.sql
Atlas_Forms_13000_GuardRail_List.data.sql
...
Deploy_GuardRails_Forms.sql ← base deploy script
Tenants/
Tenant_9_Acme/
GuardRails/ ← Tenant 9 overrides for GuardRails
Tenant_9_GuardRail_Override_13001.data.sql ← control label override
Tenant_9_GuardRail_Disable_13007.data.sql ← disable audit form
Tenant_9_Atlas_Forms_913001_GdprConsent.data.sql ← private form
Deploy_Tenant_9_GuardRails.sql ← tenant deploy script
Tenant Deploy Script
-- Deploy_Tenant_9_GuardRails.sql
-- IMPORTANT: Run AFTER Deploy_GuardRails_Forms.sql
-- Base forms must exist before override rows can be inserted.
:r .\Tenant_9_GuardRail_Override_13001.data.sql
:r .\Tenant_9_GuardRail_Disable_13007.data.sql
:r .\Tenant_9_Atlas_Forms_913001_GdprConsent.data.sql
Override Row SQL File
-- Tenant_9_GuardRail_Override_13001.data.sql
-- Control label override: 'Policy Name' → 'Rule Name' for Tenant 9
SET IDENTITY_INSERT [dbo].[Atlas_Forms] ON;
IF NOT EXISTS (
SELECT 1 FROM [dbo].[Atlas_Forms]
WHERE [FormID] = 13001 AND [TenantID] = 9
)
BEGIN
-- Read the base schema, apply overrides, insert the merged result
DECLARE @baseSchema NVARCHAR(MAX);
SELECT @baseSchema = [SchemaJson]
FROM [dbo].[Atlas_Forms]
WHERE [FormID] = 13001 AND [TenantID] IS NULL;
-- In practice the merged schema is pre-computed by the deployer tool
-- and inserted as a static JSON string:
INSERT INTO [dbo].[Atlas_Forms]
([FormID], [FormCode], [FormCategoryID], [FormTypeID],
[PrimaryUsage], [NodeUsage], [TenantID], [IsActive], [SchemaJson])
VALUES
(13001, 'GuardRail_Edit', 130, 2,
'guardrails', 'guardrail-edit', 9, 1,
N'{ "metadata": { "formId": 13001, "title": "Edit GuardRail" },
"controls": [
{ "id": "policy-name", "label": "Rule Name", "placeholder": "Enter rule name" }
] }');
END
SET IDENTITY_INSERT [dbo].[Atlas_Forms] OFF;
Deployment Order
| Step | Script | Must Run After |
|---|---|---|
| 1 | Category script (GuardRails_Category.data.sql) | — |
| 2 | Base form scripts (Atlas_Forms_13000_*.data.sql etc.) | Step 1 |
| 3 | Tenant override scripts (Tenant_9_*.data.sql) | Step 2 |
| 4 | Tenant addition scripts (Tenant_9_Atlas_Forms_913001_*.data.sql) | Step 1 (category must exist) |
CI Pipeline Integration
# In your CI deploy pipeline (pseudocode)
# 1. Run base group deploy scripts
sqlcmd -S $DB_SERVER -d $DB_NAME -i "GuardRails/Deploy_GuardRails_Forms.sql"
# 2. Run each tenant's override deploy scripts
for tenant_dir in Tenants/*/GuardRails/; do
if [ -f "$tenant_dir/Deploy_*.sql" ]; then
sqlcmd -S $DB_SERVER -d $DB_NAME -i "$tenant_dir/Deploy_*.sql"
fi
done
All Scripts Must Be Idempotent
Every INSERT in every tenant override script must use an
IF NOT EXISTS guard. The CI pipeline runs these scripts on every deployment — a missing guard will cause a primary key violation on the second run and fail the deployment.