<?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="003-create-audit-logs-table" author="effigenix">
        <createTable tableName="audit_logs">
            <column name="id" type="VARCHAR(36)">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="event" type="VARCHAR(100)">
                <constraints nullable="false"/>
            </column>
            <column name="entity_id" type="VARCHAR(36)"/>
            <column name="performed_by" type="VARCHAR(36)"/>
            <column name="details" type="VARCHAR(2000)"/>
            <column name="timestamp" type="TIMESTAMP">
                <constraints nullable="false"/>
            </column>
            <column name="ip_address" type="VARCHAR(45)"/>
            <column name="user_agent" type="VARCHAR(500)"/>
            <column name="created_at" type="TIMESTAMP" defaultValueComputed="CURRENT_TIMESTAMP">
                <constraints nullable="false"/>
            </column>
        </createTable>
        <createIndex tableName="audit_logs" indexName="idx_audit_event">
            <column name="event"/>
        </createIndex>
        <createIndex tableName="audit_logs" indexName="idx_audit_actor">
            <column name="performed_by"/>
        </createIndex>
        <createIndex tableName="audit_logs" indexName="idx_audit_timestamp">
            <column name="timestamp"/>
        </createIndex>
        <createIndex tableName="audit_logs" indexName="idx_audit_entity">
            <column name="entity_id"/>
        </createIndex>
        <createIndex tableName="audit_logs" indexName="idx_audit_created_at">
            <column name="created_at"/>
        </createIndex>
    </changeSet>

</databaseChangeLog>
