feat: update entity properties to use definite assignment assertion and add unique indexes for tenant-specific codes

This commit is contained in:
Syed Waseem
2026-07-21 13:17:08 +05:30
parent f3acfd2181
commit e8e6da31be
22 changed files with 166 additions and 158 deletions
+6 -2
View File
@@ -149,7 +149,7 @@ CREATE INDEX IF NOT EXISTS idx_tbl_revenue_segments_tenant ON masters.tbl_revenu
CREATE TABLE IF NOT EXISTS masters.tbl_rules_categories (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"tenantId" UUID NOT NULL REFERENCES tenant.tbl_tenants(id) ON DELETE CASCADE,
code VARCHAR(100) UNIQUE NOT NULL,
code VARCHAR(100) NOT NULL,
name VARCHAR(150) NOT NULL,
description TEXT,
"displayOrder" INT DEFAULT 0,
@@ -158,6 +158,8 @@ CREATE TABLE IF NOT EXISTS masters.tbl_rules_categories (
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_tbl_rules_categories_tenant ON masters.tbl_rules_categories("tenantId");
CREATE UNIQUE INDEX IF NOT EXISTS uq_tbl_rules_categories_tenant_code
ON masters.tbl_rules_categories("tenantId", code);
CREATE TABLE IF NOT EXISTS masters.tbl_rule_categories_values (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
@@ -176,7 +178,7 @@ CREATE INDEX IF NOT EXISTS idx_tbl_rule_categories_values_category ON masters.tb
CREATE TABLE IF NOT EXISTS masters.tbl_operators (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"tenantId" UUID NOT NULL REFERENCES tenant.tbl_tenants(id) ON DELETE CASCADE,
code VARCHAR(50) UNIQUE NOT NULL,
code VARCHAR(50) NOT NULL,
name VARCHAR(100) NOT NULL,
symbol VARCHAR(20),
"dataTypes" TEXT[],
@@ -186,6 +188,8 @@ CREATE TABLE IF NOT EXISTS masters.tbl_operators (
"updatedAt" TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_tbl_operators_tenant ON masters.tbl_operators("tenantId");
CREATE UNIQUE INDEX IF NOT EXISTS uq_tbl_operators_tenant_code
ON masters.tbl_operators("tenantId", code);
-- ─── Cohorts ────────────────────────────────────────────────────────────────