-- Custom SQL migration file, put you code below! --
 -- Step 1: Add the new 'datetime' column
    ALTER TABLE "hour"
    ADD COLUMN "datetime" TIMESTAMPTZ;

    -- Step 2: Update 'datetime' by combining 'Day.date' and 'Hour.time'
    UPDATE "hour"
    SET "datetime" = ("day"."date"::timestamp + ("hour"."time" * INTERVAL '1 hour')) AT TIME ZONE 'UTC'
    FROM "day"
    WHERE "hour"."dayId" = "day"."id";

    -- Step 3: Add a unique constraint to 'datetime'
    ALTER TABLE "hour"
	ADD CONSTRAINT "hour_datetime_unique" UNIQUE("datetime");

    -- Step 3: Drop the old 'time' column
    ALTER TABLE "hour"
    DROP COLUMN "time";
