Files
alla-tms/drizzle/0012_change_duration_minutes.sql
2026-07-16 09:53:14 +07:00

48 lines
1.5 KiB
SQL

ALTER TABLE "training_records"
ADD COLUMN "submitted_minutes" integer,
ADD COLUMN "approved_minutes" integer;
UPDATE "training_records"
SET
"submitted_minutes" = ROUND("hours" * 60),
"approved_minutes" = CASE
WHEN "approved_hours" IS NULL THEN NULL
ELSE ROUND("approved_hours" * 60)
END
WHERE "submitted_minutes" IS NULL
OR ("approved_hours" IS NOT NULL AND "approved_minutes" IS NULL);
ALTER TABLE "training_policies"
ADD COLUMN "total_target_minutes" integer,
ADD COLUMN "k_target_minutes" integer,
ADD COLUMN "s_target_minutes" integer,
ADD COLUMN "a_target_minutes" integer;
UPDATE "training_policies"
SET
"total_target_minutes" = ROUND("total_hours" * 60),
"k_target_minutes" = ROUND("k_hours" * 60),
"s_target_minutes" = ROUND("s_hours" * 60),
"a_target_minutes" = ROUND("a_hours" * 60)
WHERE "total_target_minutes" IS NULL
OR "k_target_minutes" IS NULL
OR "s_target_minutes" IS NULL
OR "a_target_minutes" IS NULL;
ALTER TABLE "employee_training_targets"
ADD COLUMN "total_target_minutes" integer,
ADD COLUMN "k_target_minutes" integer,
ADD COLUMN "s_target_minutes" integer,
ADD COLUMN "a_target_minutes" integer;
UPDATE "employee_training_targets"
SET
"total_target_minutes" = ROUND("total_hours" * 60),
"k_target_minutes" = ROUND("k_hours" * 60),
"s_target_minutes" = ROUND("s_hours" * 60),
"a_target_minutes" = ROUND("a_hours" * 60)
WHERE "total_target_minutes" IS NULL
OR "k_target_minutes" IS NULL
OR "s_target_minutes" IS NULL
OR "a_target_minutes" IS NULL;