<?xml version="1.0" encoding="UTF-8"?>
<!--
 This file is part of the Meeds project (https://meeds.io/).

 Copyright (C) 2020 - 2025 Meeds Association contact@meeds.io

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 3 of the License, or (at your option) any later version.
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public License
 along with this program; if not, write to the Free Software Foundation,
 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-->
<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-3.3.xsd">

  <changeSet author="task" id="1.3.0-1">
    <validCheckSum>7:4c348e911e6945cbcaddc49d8528ff8e</validCheckSum>
    <addColumn tableName="TASK_COMMENTS">
        <column name="PARENT_COMMENT_ID" type="BIGINT" />
    </addColumn>
  </changeSet>

  <changeSet author="task" id="1.3.0-2" dbms="mssql">
    <addForeignKeyConstraint baseColumnNames="PARENT_COMMENT_ID" baseTableName="TASK_COMMENTS" constraintName="FK_TASK_COMMENT_PARENT_CMT_ID" deferrable="false" initiallyDeferred="false" onDelete="NO ACTION" onUpdate="NO ACTION"  referencedColumnNames="COMMENT_ID" referencedTableName="TASK_COMMENTS" />
  </changeSet>

  <changeSet author="task" id="1.3.0-3" dbms="mysql,h2,sybase,db2,hsqldb,postgresql" failOnError="false">
      <validCheckSum>7:03a7ef811cee34357cc041b4fadc0acb</validCheckSum>
      <preConditions onFail="MARK_RAN">
          <foreignKeyConstraintExists foreignKeyName="FK_TASK_COMMENT_PARENT_COMMENT_ID"/>
      </preConditions>
    <dropForeignKeyConstraint baseTableName="TASK_COMMENTS" constraintName="FK_TASK_COMMENT_PARENT_COMMENT_ID" />
  </changeSet>

  <changeSet author="task" id="1.3.0-4" dbms="mysql,h2,sybase,db2,hsqldb,oracle,postgresql" failOnError="false">
    <addForeignKeyConstraint baseColumnNames="PARENT_COMMENT_ID" baseTableName="TASK_COMMENTS" constraintName="FK_TASK_COMMENT_PARENT_CMT_ID" deferrable="false" initiallyDeferred="false" deleteCascade="true" onDelete="CASCADE" onUpdate="NO ACTION"  referencedColumnNames="COMMENT_ID" referencedTableName="TASK_COMMENTS" />
  </changeSet>

</databaseChangeLog>