sozsoft-platform/configs/seeds/postgres/object/Prj_T_UserMonthRate.sql
2026-10-08 13:51:14 +03:00

25 lines
935 B
SQL

CREATE TABLE IF NOT EXISTS public."Prj_T_UserMonthRate"
(
"Id" uuid NOT NULL DEFAULT gen_random_uuid(),
"TenantId" uuid NULL,
"UserId" uuid NOT NULL,
"Year" integer NOT NULL,
"Month" integer NOT NULL,
"Rate" numeric(18, 4) NOT NULL DEFAULT 100,
"CreationTime" timestamp NOT NULL DEFAULT (NOW() AT TIME ZONE 'UTC'),
"CreatorId" uuid NULL,
"LastModificationTime" timestamp NULL,
"LastModifierId" uuid NULL,
"IsDeleted" boolean NOT NULL DEFAULT FALSE,
"DeletionTime" timestamp NULL,
"DeleterId" uuid NULL,
CONSTRAINT "PK_Prj_T_UserMonthRate" PRIMARY KEY ("Id")
);
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'UQ_Prj_T_UserMonthRate_TenantId_UserId_Year_Month') THEN
ALTER TABLE public."Prj_T_UserMonthRate" ADD CONSTRAINT "UQ_Prj_T_UserMonthRate_TenantId_UserId_Year_Month" UNIQUE ("TenantId", "UserId", "Year", "Month");
END IF;
END
$$;