<?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">

    <!--
        Alter the entity VariableUnits.
        Add foreign relation with UnitConverter
    -->
    <changeSet id="20241027235307-1" author="omg">
		<!-- Step 1: Add the column to the existing table -->
	    <addColumn tableName="variable_units">
	        <column name="unit_converter_id" type="bigint" />
	    </addColumn>
	    
	    <!-- Step 2: Add foreign key constraint to link it with the referenced table -->
	    <addForeignKeyConstraint
	        baseTableName="variable_units"
	        baseColumnNames="unit_converter_id"
	        referencedTableName="unit_converter"
	        referencedColumnNames="id"
	        constraintName="fk_variable_units__unit_converter_id"/>
    </changeSet>
    
    
</databaseChangeLog>
