Skip to main content

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.sql wipes data but keeps schema
  • When login fails with "Sign-in failed" and schema verification passes

How it works

Objects inserted (order)

StepObjectPurpose
1SoftwareVersions / SoftwareVersionLogin page version check (ZPILOT)
2CompanyMasterCompID 1 — Damsy Technologies
3UserRoleRoleID 1 — Administrator
4BranchMasterHead Office — required for GetLoginUser join
5UserAccountsadmin with encrypted password
6CompanyUserLinks user to CompID 1
7Verify SELECTSame joins as GetLoginUser

Default credentials

warning

Change the default password immediately after first successful login in any shared or production environment.

FieldValue
CompanyDamsy Technologies
CompID1
Login IDadmin
Password (plaintext)Admin@123
Stored passwordEncrypted 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

  1. SSMS → connect to DB_DAMSYERP
  2. Open 04-seed-minimal.sql
  3. 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)

  1. Open 04b-fix-admin-login.sql
  2. Execute

This script:

  • Prints current CompanyMaster, UserRole, BranchMaster, UserAccounts, CompanyUser
  • Ensures branch, role, company rows exist
  • Resets admin password to encrypted Admin@123
  • Sets module boolean columns on UserAccounts to 1
  • Re-validates CompanyUser link

Step 4 — Test in application

  1. Confirm MyConnectionString points to DB_DAMSYERP
  2. Recycle IIS app pool
  3. Login page → select Damsy Technologiesadmin / Admin@123

Module flags on admin user

Minimal seed enables all module booleans on UserAccounts, including:

ColumnModule
PayrollPayroll
BillingBills
ZStockStock
WebenrollRegistration
ZSalesSales
EmpSelfServicesESS
ControlPanelAdministration
OperationOperation
ZManagementDashboardManagement dashboard
ZContratedRatesContracted rates
VerificationAndApprovalVerification & approval
Attendance-related flagsAttendance punching

These drive home dashboard tiles via session dtVerifyUser.

info

Minimal seed intentionally omits full menu and page-permission matrices. MenuMaster and UserPermissions may be empty.

Symptom with empty menusCause
Dashboard loads; sidebar sparse or errors on drill-inNo menu rows for role
Admin screens redirect to errorPage 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.

Important notes

  • CompanyUser.Compid column spelling (lowercase id) matches legacy schema — scripts use this name deliberately.
  • GetLoginUser requires active company, user, role, branch, and matching encrypted password — all must be present.
  • SoftwareVersions mismatch rarely blocks login but affects version label on login UI.
  • Template file 04-seed-minimal-TEMPLATE.sql exists for customization — prefer editing a copy, not the verified minimal script, unless you know the deltas.

Common mistakes

MistakeResult
Typing plaintext password in UserPassword columnLogin always fails
Wrong company selected on login formValid user but wrong CompID join
Missing CompanyUser rowVerify SELECT returns zero rows
Expecting full menus from minimal seedNavigation errors until menu copy
Editing seed without BranchMasterGetLoginUser INNER JOIN failure

Next steps

  1. Deploy to IIS and test module tiles on Dashboard.
  2. Import menu/permission data if sidebar navigation is required.
  3. Create real company users via Administration module (after menus exist).
  4. Review FAQ for developer onboarding questions.