<?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-rsvps-table" author="fete">
        <createTable tableName="rsvps">
            <column name="id" type="bigserial" autoIncrement="true">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="rsvp_token" type="uuid">
                <constraints nullable="false" unique="true"/>
            </column>
            <column name="event_id" type="bigint">
                <constraints nullable="false"
                             foreignKeyName="fk_rsvps_event_id"
                             references="events(id)"
                             deleteCascade="true"/>
            </column>
            <column name="name" type="varchar(100)">
                <constraints nullable="false"/>
            </column>
        </createTable>

        <createIndex tableName="rsvps" indexName="idx_rsvps_event_id">
            <column name="event_id"/>
        </createIndex>

        <createIndex tableName="rsvps" indexName="idx_rsvps_rsvp_token">
            <column name="rsvp_token"/>
        </createIndex>
    </changeSet>

</databaseChangeLog>
