<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">

    <changeSet id="017-timestamps-to-timestamptz" author="effigenix" dbms="postgresql">
        <comment>Migrate all TIMESTAMP columns to TIMESTAMP WITH TIME ZONE for consistent timezone handling</comment>

        <!-- users -->
        <sql>ALTER TABLE users ALTER COLUMN created_at TYPE TIMESTAMP WITH TIME ZONE;</sql>
        <sql>ALTER TABLE users ALTER COLUMN last_login TYPE TIMESTAMP WITH TIME ZONE;</sql>

        <!-- audit_logs -->
        <sql>ALTER TABLE audit_logs ALTER COLUMN timestamp TYPE TIMESTAMP WITH TIME ZONE;</sql>
        <sql>ALTER TABLE audit_logs ALTER COLUMN created_at TYPE TIMESTAMP WITH TIME ZONE;</sql>

        <!-- articles -->
        <sql>ALTER TABLE articles ALTER COLUMN created_at TYPE TIMESTAMP WITH TIME ZONE;</sql>
        <sql>ALTER TABLE articles ALTER COLUMN updated_at TYPE TIMESTAMP WITH TIME ZONE;</sql>

        <!-- suppliers -->
        <sql>ALTER TABLE suppliers ALTER COLUMN created_at TYPE TIMESTAMP WITH TIME ZONE;</sql>
        <sql>ALTER TABLE suppliers ALTER COLUMN updated_at TYPE TIMESTAMP WITH TIME ZONE;</sql>

        <!-- customers -->
        <sql>ALTER TABLE customers ALTER COLUMN created_at TYPE TIMESTAMP WITH TIME ZONE;</sql>
        <sql>ALTER TABLE customers ALTER COLUMN updated_at TYPE TIMESTAMP WITH TIME ZONE;</sql>

        <!-- recipes -->
        <sql>ALTER TABLE recipes ALTER COLUMN created_at TYPE TIMESTAMP WITH TIME ZONE;</sql>
        <sql>ALTER TABLE recipes ALTER COLUMN updated_at TYPE TIMESTAMP WITH TIME ZONE;</sql>
    </changeSet>

    <changeSet id="017-timestamps-to-timestamptz" author="effigenix" dbms="h2">
        <comment>H2: Migrate all TIMESTAMP columns to TIMESTAMP WITH TIME ZONE</comment>

        <sql>ALTER TABLE users ALTER COLUMN created_at SET DATA TYPE TIMESTAMP WITH TIME ZONE;</sql>
        <sql>ALTER TABLE users ALTER COLUMN last_login SET DATA TYPE TIMESTAMP WITH TIME ZONE;</sql>

        <sql>ALTER TABLE audit_logs ALTER COLUMN timestamp SET DATA TYPE TIMESTAMP WITH TIME ZONE;</sql>
        <sql>ALTER TABLE audit_logs ALTER COLUMN created_at SET DATA TYPE TIMESTAMP WITH TIME ZONE;</sql>

        <sql>ALTER TABLE articles ALTER COLUMN created_at SET DATA TYPE TIMESTAMP WITH TIME ZONE;</sql>
        <sql>ALTER TABLE articles ALTER COLUMN updated_at SET DATA TYPE TIMESTAMP WITH TIME ZONE;</sql>

        <sql>ALTER TABLE suppliers ALTER COLUMN created_at SET DATA TYPE TIMESTAMP WITH TIME ZONE;</sql>
        <sql>ALTER TABLE suppliers ALTER COLUMN updated_at SET DATA TYPE TIMESTAMP WITH TIME ZONE;</sql>

        <sql>ALTER TABLE customers ALTER COLUMN created_at SET DATA TYPE TIMESTAMP WITH TIME ZONE;</sql>
        <sql>ALTER TABLE customers ALTER COLUMN updated_at SET DATA TYPE TIMESTAMP WITH TIME ZONE;</sql>

        <sql>ALTER TABLE recipes ALTER COLUMN created_at SET DATA TYPE TIMESTAMP WITH TIME ZONE;</sql>
        <sql>ALTER TABLE recipes ALTER COLUMN updated_at SET DATA TYPE TIMESTAMP WITH TIME ZONE;</sql>
    </changeSet>

</databaseChangeLog>
