-- Tables

-- Alters

ALTER TABLE AKUZ.T_SCHEDULE_FREETIME ADD "endtime" timestamp NULL;

UPDATE AKUZ.T_SCHEDULE_FREETIME 
SET "endtime" = DATEADD(MONTH,t.Duration,t.BeginTime)
FROM AKUZ.T_SCHEDULE_FREETIME t;

ALTER TABLE AKUZ.T_SCHEDULE_FREETIME ALTER COLUMN "endtime" SET NOT NULL;

-- θνδεκρ
drop index if exists akuz.ix_t_schedule_freetime_scheduleitem;

create index ix_t_schedule_freetime_scheduleitem on akuz.t_schedule_freetime(scheduleitem) include(schedulefreetimeid,reason,begintime,endtime);

ALTER TABLE AKUZ.T_SCHEDULE_FREETIME DROP COLUMN "duration";