*** Settings ***
Documentation     Integration checks for spec-parity schema constraints and indexes.
...               Verifies migration output includes resource_links.link_type default,
...               checkpoint_metadata FK enforcement, and decisions partial superseded index.
...               Split into independent test cases for isolated failure reporting.
Resource          ${CURDIR}/common.resource
Suite Setup       Setup Test Environment
Suite Teardown    Cleanup Test Environment

*** Variables ***
${HELPER_SCRIPT}    robot/helper_schema_parity_migration.py

*** Test Cases ***
Resource Links Link Type Default After Migration
    [Documentation]    Validate resource_links.link_type column exists with default 'contains'.
    [Tags]    database    migration    integration    link-type
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    schema-parity-link-type    cwd=${WORKSPACE}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    schema-parity-link-type-ok

Checkpoint Metadata FK Enforcement After Migration
    [Documentation]    Validate checkpoint_metadata FK constraints and orphan rejection.
    [Tags]    database    migration    integration    fks
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    schema-parity-fks    cwd=${WORKSPACE}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    schema-parity-fks-ok

Decisions Superseded Partial Index After Migration
    [Documentation]    Validate idx_decisions_superseded partial index on decisions.superseded_by.
    [Tags]    database    migration    integration    index
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    schema-parity-index    cwd=${WORKSPACE}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    schema-parity-index-ok
