Skip to content

Commit

Permalink
feat(tenant-management): shgds
Browse files Browse the repository at this point in the history
sdhgs

BREAKING CHANGE:
yes

43
  • Loading branch information
Tyagi-Sunny committed Sep 27, 2024
1 parent ae2ccbb commit f14113b
Showing 1 changed file with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ CREATE TABLE IF NOT EXISTS main.tenant_configs
id uuid NOT NULL DEFAULT (md5(((random())::text || (clock_timestamp())::text)))::uuid,
config_key varchar(100) NOT NULL,
config_value jsonb NOT NULL,
created_on timestamptz DEFAULT CURRENT_TIMESTAMP,
modified_on timestamptz,
created_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
modified_on timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL,
created_by uuid,
modified_by uuid,
deleted boolean DEFAULT FALSE NOT NULL,
Expand All @@ -14,4 +14,20 @@ CREATE TABLE IF NOT EXISTS main.tenant_configs
CONSTRAINT pk_tenant_configs_id PRIMARY KEY (id),
CONSTRAINT fk_tenant_configs_tenants FOREIGN KEY (tenant_id)
REFERENCES main.tenants(id)
)
);


CREATE OR REPLACE FUNCTION main.moddatetime()
RETURNS TRIGGER
LANGUAGE plpgsql
AS $function$
BEGIN
NEW.modified_on = now();
RETURN NEW;
END;
$function$;

CREATE TRIGGER mdt_tenant_configs
BEFORE UPDATE ON main.tenant_configs
FOR EACH ROW
EXECUTE FUNCTION main.moddatetime('modified_on');

0 comments on commit f14113b

Please sign in to comment.