<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
    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
                        http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

    <!--
        Added the entity MetadataValue.
    -->
    <changeSet id="20241015091607-1" author="jhipster">
        <createTable tableName="metadata_value" remarks="Metadata Value\nThe value of a metadata property.">
            <column name="id" type="bigint" autoIncrement="true" startWith="1500">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="metadata_property_code" type="varchar(255)" remarks="Functional relational key to MetadataProperty">
                <constraints nullable="false" />
            </column>
            <column name="target_domain_key" type="varchar(255)" remarks="The target domain key that this MetadataValue belongs. Its a class name or a key provided by the consumer. &lt;br&gt;\nUsed with targetDomainId to create as unique relation with the target domain\n@see targetDomainId">
                <constraints nullable="false" />
            </column>
            <column name="target_domain_id" type="bigint" remarks="The target domain Id that this MetadataValue belongs. &lt;br&gt;\nUsed with targetDomainKey to create as unique relation with the target domain\n@see targetDomainKey">
                <constraints nullable="false" />
            </column>
            <column name="value" type="varchar(255)" remarks="The value of the MetadataProperty, persisted as a string. &lt;br&gt;">
                <constraints nullable="true" />
            </column>
            <column name="version" type="integer" defaultValueNumeric="-1" remarks="Record version for concurrency control.">
                <constraints nullable="false" />
            </column>
            <!-- jhipster-needle-liquibase-add-column - JHipster will add columns here -->
        </createTable>
    </changeSet>

    <!-- jhipster-needle-liquibase-add-changeset - JHipster will add changesets here -->

    <!--
        Load sample data generated with Faker.js
        - This data can be easily edited using a CSV editor (or even MS Excel) and
          is located in the 'src/main/resources/config/liquibase/fake-data' directory
        - By default this data is applied when running with the JHipster 'dev' profile.
          This can be customized by adding or removing 'faker' in the 'spring.liquibase.contexts'
          Spring Boot configuration key.
    -->
    <changeSet id="20241015091607-1-data" author="jhipster" context="faker">
        <loadData
                  file="config/liquibase/fake-data/metadata_value.csv"
                  separator=";"
                  tableName="metadata_value"
                  usePreparedStatements="true">
            <column name="id" type="numeric"/>
            <column name="metadata_property_code" type="string"/>
            <column name="target_domain_key" type="string"/>
            <column name="target_domain_id" type="numeric"/>
            <column name="value" type="string"/>
            <column name="version" type="numeric"/>
            <!-- jhipster-needle-liquibase-add-loadcolumn - JHipster (and/or extensions) can add load columns here -->
        </loadData>
    </changeSet>
</databaseChangeLog>
