<?xml version="1.0" encoding="UTF-8"?>

<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.1.xsd">

    <changeSet id="fix-workflow-id-column-type" author="fbristow">
        <modifyDataType tableName="workflow_named_parameters" columnName="workflow_id" newDataType="varchar(255)" />
        <sql>
            update workflow_named_parameters set workflow_id = left(workflow_id, 36);
            <comment>
                Strip the trailing 'whitespace' characters (actually NUL characters) after converting from binary
                to varchar.
            </comment>
        </sql>
    </changeSet>
</databaseChangeLog>

<?xml version="1.0" encoding="UTF-8"?>

<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.1.xsd">

    <changeSet id="fix-workflow-id-column-type" author="fbristow">
        <modifyDataType tableName="workflow_named_parameters" columnName="workflow_id" newDataType="varchar(255)"/>
        <addNotNullConstraint tableName="workflow_named_parameters" columnName="workflow_id"
                              columnDataType="varchar(255)"/>
        <sql>
            update workflow_named_parameters set workflow_id = left(workflow_id, 36);
            <comment>
                Strip the trailing 'whitespace' characters (actually NUL characters) after converting from binary
                to varchar (36 is the number of characters in a UUID, with hyphens).
            </comment>
        </sql>
    </changeSet>
</databaseChangeLog>

Add not null constraint to workflow_id on workflow_named_parameters.
Add not null constraint to workflow_id on workflow_named_parameters.
