Seed scripts
After schema is applied to DB_DAMSYERP, seed scripts insert the minimum rows required for login, company selection, and module tile visibility. They do not replace a full production data load.
Introduction
The script pack under database-backup/scripts-blank-db/ includes idempotent SQL files: safe to re-run when guarded by IF NOT EXISTS checks. The primary seed is 04-seed-minimal.sql; 04b-fix-admin-login.sql repairs the authentication chain when login still fails.
Purpose
Provide a known-good starting point — one company, one administrator, all module flags enabled — so developers and operators can validate IIS + SQL connectivity before importing business data.
When to use
- Immediately after Blank database setup schema apply
- After
00-recreate-blank-database.sqlwipes data but keeps schema - When login fails with "Sign-in failed" and schema verification passes
How it works
Objects inserted (order)
| Step | Object | Purpose |
|---|---|---|
| 1 | SoftwareVersions / SoftwareVersion | Login page version check (ZPILOT) |
| 2 | CompanyMaster | CompID 1 — Damsy Technologies |
| 3 | UserRole | RoleID 1 — Administrator |
| 4 | BranchMaster | Head Office — required for GetLoginUser join |
| 5 | UserAccounts | admin with encrypted password |
| 6 | CompanyUser | Links user to CompID 1 |
| 7 | Verify SELECT | Same joins as GetLoginUser |
Default credentials
Change the default password immediately after first successful login in any shared or production environment.
| Field | Value |
|---|---|
| Company | Damsy Technologies |
| CompID | 1 |
| Login ID | admin |
| Password (plaintext) | Admin@123 |
| Stored password | Encrypted via UTILITIES.HashCryptography.Encrypt |
Encrypted value in SQL (both seed scripts):
pnvwVaziAnZkG/KRvd7FLA==
The application encrypts the submitted password before calling dbo.GetLoginUser — plaintext is never stored.
Step-by-step — Run seed scripts
Step 1 — Confirm schema is applied
Run 02-verify-blank-database.sql. Table and procedure counts must be greater than zero.
Step 2 — Execute minimal seed
- SSMS → connect to
DB_DAMSYERP - Open
04-seed-minimal.sql - Execute (F5)
Watch Messages pane for:
Login chain OK. Use LoginID=admin Password=Admin@123 Company=Damsy Technologies.
If RAISERROR ... Login chain verify FAILED, proceed to Step 3.
Step 3 — Repair login (if needed)
- Open
04b-fix-admin-login.sql - Execute
This script:
- Prints current
CompanyMaster,UserRole,BranchMaster,UserAccounts,CompanyUser - Ensures branch, role, company rows exist
- Resets
adminpassword to encryptedAdmin@123 - Sets module boolean columns on
UserAccountsto 1 - Re-validates
CompanyUserlink
Step 4 — Test in application
- Confirm
MyConnectionStringpoints toDB_DAMSYERP - Recycle IIS app pool
- Login page → select Damsy Technologies →
admin/Admin@123
Module flags on admin user
Minimal seed enables all module booleans on UserAccounts, including:
| Column | Module |
|---|---|
Payroll | Payroll |
Billing | Bills |
ZStock | Stock |
Webenroll | Registration |
ZSales | Sales |
EmpSelfServices | ESS |
ControlPanel | Administration |
Operation | Operation |
ZManagementDashboard | Management dashboard |
ZContratedRates | Contracted rates |
VerificationAndApproval | Verification & approval |
| Attendance-related flags | Attendance punching |
These drive home dashboard tiles via session dtVerifyUser.
MenuMaster and UserPermissions
Minimal seed intentionally omits full menu and page-permission matrices. MenuMaster and UserPermissions may be empty.
| Symptom with empty menus | Cause |
|---|---|
| Dashboard loads; sidebar sparse or errors on drill-in | No menu rows for role |
| Admin screens redirect to error | Page permission SP returns nothing |
Remediation: Copy MenuMaster and UserPermissions (and related lookup data) from a working dev database, or run your organization's full data migration scripts.
Seed script note (Phase 4):
MenuMaster / UserPermissions may still be empty — menus appear after you copy those rows from local DB.
Examples
Example — Manual password reset (same as app encryption)
Use 04b-fix-admin-login.sql rather than inventing hashes. If you must align with C# encryption, run the same HashCryptography.Encrypt("Admin@123") in a small utility — the seed value above is the canonical hash.
Example — Verify login chain in SSMS
SELECT ua.LoginID, cm.CompName, ur.RoleName, bm.BranchName
FROM dbo.UserAccounts ua
INNER JOIN dbo.CompanyUser cu ON ua.UserAccountsID = cu.UserAccountsID
INNER JOIN dbo.CompanyMaster cm ON cu.Compid = cm.CompID
INNER JOIN dbo.UserRole ur ON ua.RoleID = ur.RoleID
INNER JOIN dbo.BranchMaster bm ON ua.BranchCode = bm.BranchCode
WHERE ua.LoginID = N'admin' AND cu.Compid = 1;
Example — Re-run seed safely
Most blocks use IF NOT EXISTS — re-running 04-seed-minimal.sql skips existing rows. Use 04b when password or links drift.
Related pages
Important notes
CompanyUser.Compidcolumn spelling (lowercase id) matches legacy schema — scripts use this name deliberately.GetLoginUserrequires active company, user, role, branch, and matching encrypted password — all must be present.SoftwareVersionsmismatch rarely blocks login but affects version label on login UI.- Template file
04-seed-minimal-TEMPLATE.sqlexists for customization — prefer editing a copy, not the verified minimal script, unless you know the deltas.
Common mistakes
| Mistake | Result |
|---|---|
Typing plaintext password in UserPassword column | Login always fails |
| Wrong company selected on login form | Valid user but wrong CompID join |
Missing CompanyUser row | Verify SELECT returns zero rows |
| Expecting full menus from minimal seed | Navigation errors until menu copy |
Editing seed without BranchMaster | GetLoginUser INNER JOIN failure |
Next steps
- Deploy to IIS and test module tiles on Dashboard.
- Import menu/permission data if sidebar navigation is required.
- Create real company users via Administration module (after menus exist).
- Review FAQ for developer onboarding questions.