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

    <!--
        Altered the entity DashboardComponent.
        #1 Add type and chart_type enums
    -->
    <changeSet id="20250303485000-1" author="omg">
    	<!-- Step 1: Add column's -->
    	<addColumn tableName="dashboard_component">
	        <column name="type" type="varchar(15)" />
	        <column name="chart_type" type="varchar(15)" />
	    </addColumn>
    </changeSet>
    
    <!-- Step 2: Populate type column with default 'TABLE' -->
	<changeSet id="20250303485000-2" author="omg">
	    <sql>
	        UPDATE dashboard_component
	        SET dashboard_component.type = 'TABLE';
	    </sql>
	</changeSet>

    <!-- Step 3: Make the column non-nullable -->
    <changeSet id="20250303485000-3" author="omg">
	    <addNotNullConstraint tableName="dashboard_component" columnName="type" columnDataType="varchar(15)"/>
	</changeSet>
</databaseChangeLog>
