-- Fix timestamp column type conversion issue
-- Run this if the Hibernate automatic schema update still fails

-- For tb_map_sheet_anal_data
ALTER TABLE tb_map_sheet_anal_data 
    ALTER COLUMN anal_end_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING anal_end_dttm::TIMESTAMP WITH TIME ZONE;

ALTER TABLE tb_map_sheet_anal_data 
    ALTER COLUMN anal_strt_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING anal_strt_dttm::TIMESTAMP WITH TIME ZONE;

ALTER TABLE tb_map_sheet_anal_data 
    ALTER COLUMN created_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING created_dttm::TIMESTAMP WITH TIME ZONE;

ALTER TABLE tb_map_sheet_anal_data 
    ALTER COLUMN updated_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING updated_dttm::TIMESTAMP WITH TIME ZONE;

ALTER TABLE tb_map_sheet_anal_data 
    ALTER COLUMN data_state_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING data_state_dttm::TIMESTAMP WITH TIME ZONE;

-- For tb_map_sheet_learn_data
ALTER TABLE tb_map_sheet_learn_data 
    ALTER COLUMN anal_end_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING anal_end_dttm::TIMESTAMP WITH TIME ZONE;

ALTER TABLE tb_map_sheet_learn_data 
    ALTER COLUMN anal_strt_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING anal_strt_dttm::TIMESTAMP WITH TIME ZONE;

ALTER TABLE tb_map_sheet_learn_data 
    ALTER COLUMN created_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING created_dttm::TIMESTAMP WITH TIME ZONE;

ALTER TABLE tb_map_sheet_learn_data 
    ALTER COLUMN updated_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING updated_dttm::TIMESTAMP WITH TIME ZONE;

ALTER TABLE tb_map_sheet_learn_data 
    ALTER COLUMN data_state_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING data_state_dttm::TIMESTAMP WITH TIME ZONE;

ALTER TABLE tb_map_sheet_learn_data 
    ALTER COLUMN gukuin_used_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING gukuin_used_dttm::TIMESTAMP WITH TIME ZONE;

-- For tb_map_sheet_learn_data_geom
ALTER TABLE tb_map_sheet_learn_data_geom 
    ALTER COLUMN created_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING created_dttm::TIMESTAMP WITH TIME ZONE;

ALTER TABLE tb_map_sheet_learn_data_geom 
    ALTER COLUMN updated_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING updated_dttm::TIMESTAMP WITH TIME ZONE;

-- For tb_map_sheet_anal_data_geom
ALTER TABLE tb_map_sheet_anal_data_geom 
    ALTER COLUMN created_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING created_dttm::TIMESTAMP WITH TIME ZONE;

ALTER TABLE tb_map_sheet_anal_data_geom 
    ALTER COLUMN updated_dttm SET DATA TYPE TIMESTAMP WITH TIME ZONE 
    USING updated_dttm::TIMESTAMP WITH TIME ZONE;