alter table eventhub.source_master_entity
    drop constraint if exists chk_source_master_entity_valid_time_order;

alter table eventhub.source_master_entity
    add constraint chk_source_master_entity_valid_time_order
        check (valid_from is null or valid_to is null or valid_from <= valid_to);

alter table eventhub.source_master_relation
    drop constraint if exists chk_source_master_relation_valid_time_order;

alter table eventhub.source_master_relation
    add constraint chk_source_master_relation_valid_time_order
        check (valid_from is null or valid_to is null or valid_from <= valid_to);
