<?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-latest.xsd">

    <changeSet id="029-seed-stock-movement-permissions" author="effigenix">
        <preConditions onFail="MARK_RAN">
            <not>
                <sqlCheck expectedResult="1">
                    SELECT COUNT(*) FROM role_permissions
                    WHERE role_id = 'c0a80121-0000-0000-0000-000000000001'
                    AND permission = 'STOCK_MOVEMENT_READ'
                </sqlCheck>
            </not>
        </preConditions>
        <comment>Add STOCK_MOVEMENT_READ and STOCK_MOVEMENT_WRITE permissions for ADMIN role</comment>

        <sql>
            INSERT INTO role_permissions (role_id, permission) VALUES
                ('c0a80121-0000-0000-0000-000000000001', 'STOCK_MOVEMENT_READ'),
                ('c0a80121-0000-0000-0000-000000000001', 'STOCK_MOVEMENT_WRITE')
            ON CONFLICT DO NOTHING;
        </sql>
    </changeSet>

</databaseChangeLog>
