<?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
    http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.10.xsd">

  <changeSet author="mulk" id="1.3-1">
    <createTable tableName="post_texts" schemaName="benki">
      <column name="post" type="integer">
        <constraints
          nullable="false"
          primaryKeyName="post_texts_pkey"
          primaryKey="true"
          foreignKeyName="post_texts_post_fkey"
          referencedTableSchemaName="benki"
          referencedTableName="posts"
          referencedColumnNames="id"/>
      </column>

      <column name="language" type="varchar">
        <constraints
          nullable="false"
          primaryKeyName="lazychat_message_texts_pkey"
          primaryKey="true"
          checkConstraint="IN ('', 'de', 'en', 'fr', 'ja', 'la')"/>
      </column>
    </createTable>

    <renameColumn tableName="lazychat_message_texts" schemaName="benki" oldColumnName="lazychat_message" newColumnName="post"/>
    <renameColumn tableName="bookmark_texts" schemaName="benki" oldColumnName="bookmark" newColumnName="post"/>

    <sql>
      ALTER TABLE benki.lazychat_message_texts INHERIT benki.post_texts;
    </sql>

    <sql>
      ALTER TABLE benki.bookmark_texts INHERIT benki.post_texts;
    </sql>
  </changeSet>

</databaseChangeLog>
