<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<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 https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.26.xsd" >
    <changeSet author="Sheldan" id="allowed_mention-table">
        <createTable tableName="allowed_mention">
            <column name="server_id" type="BIGINT">
                <constraints nullable="false" primaryKey="true" primaryKeyName="allowed_mention_pkey"/>
            </column>
            <column name="created" type="TIMESTAMP WITHOUT TIME ZONE">
                <constraints nullable="true"/>
            </column>
            <column name="updated" type="TIMESTAMP WITHOUT TIME ZONE"/>
            <column name="everyone_mention" type="BOOLEAN">
                <constraints nullable="true"/>
            </column>
            <column name="user_mention" type="BOOLEAN">
                <constraints nullable="true"/>
            </column>
            <column name="role_mention" type="BOOLEAN">
                <constraints nullable="true"/>
            </column>
        </createTable>
        <addForeignKeyConstraint baseColumnNames="server_id" baseTableName="allowed_mention" constraintName="fk_allowed_mention_server"
                                 deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION" referencedColumnNames="id" referencedTableName="server" validate="true"/>
        <sql>
            DROP TRIGGER IF EXISTS allowed_mention_update_trigger ON allowed_mention;
            CREATE TRIGGER allowed_mention_update_trigger BEFORE UPDATE ON allowed_mention FOR EACH ROW EXECUTE PROCEDURE update_trigger_procedure();
        </sql>
        <sql>
            DROP TRIGGER IF EXISTS allowed_mention_insert_trigger ON allowed_mention;
            CREATE TRIGGER allowed_mention_insert_trigger BEFORE INSERT ON allowed_mention FOR EACH ROW EXECUTE PROCEDURE insert_trigger_procedure();
        </sql>
    </changeSet>

</databaseChangeLog>