<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <!-- Extends Printxpand_Core's product designer settings table with the photoprint-only field. -->
    <table name="productdesigner_config">
        <column xsi:type="int" name="allowed_max_quantity" nullable="true" padding="10" unsigned="true" comment="Allowed Max Quantity (Photoprint)"/>
    </table>
    <!-- Per-photo size/qty/price summary saved with each photoprint design (drives cart price + output). -->
    <table name="productdesigner_designs">
        <column xsi:type="text" name="photo_print_details" nullable="true" comment="Photo Print Details"/>
    </table>
    <table name="productdesigner_photoprint_config" engine="innodb" resource="default" comment="productdesigner_photoprint_config">
        <column xsi:type="int" name="config_id" identity="true" nullable="false" padding="10" unsigned="true" comment="Primary key" />
        <column xsi:type="smallint" name="status" default="1" nullable="false" unsigned="true" comment="status" />
        <column xsi:type="varchar" name="unit" default="cm" nullable="false" length="20" comment="unit" />
        <column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP" comment="created_at" on_update="false"/>
        <column xsi:type="timestamp" name="updated_at" nullable="true" default="CURRENT_TIMESTAMP" comment="updated_at" on_update="true"/>
        <constraint referenceId="PRIMARY" xsi:type="primary">
            <column name="config_id"/>
        </constraint>
    </table>
    <table name="productdesigner_photoprint_size" engine="innodb" resource="default" comment="productdesigner_photoprint_size">
        <column xsi:type="int" name="size_id" identity="true" nullable="false" padding="10" unsigned="true" comment="Primary key" />
        <column xsi:type="int" name="config_id" nullable="false" padding="10" unsigned="true" comment="parent config_id" />
        <column xsi:type="decimal" name="image_width" scale="4" precision="12" nullable="false" default="0" comment="image_width" />
        <column xsi:type="decimal" name="image_height" scale="4" precision="12" nullable="false" default="0" comment="image_height" />
        <column xsi:type="decimal" name="price" scale="4" precision="12" nullable="false" default="0" comment="price" />
        <column xsi:type="int" name="position" nullable="false" default="0" padding="10" comment="position" />
        <column xsi:type="smallint" name="status" default="1" nullable="false" unsigned="true" comment="status" />
        <constraint referenceId="PRIMARY" xsi:type="primary">
            <column name="size_id"/>
        </constraint>
        <constraint xsi:type="foreign" referenceId="PRODUCTDESIGNER_PHOTOPRINT_SIZE_CONFIG_ID_CONFIG_CONFIG_ID"
                    table="productdesigner_photoprint_size" column="config_id"
                    referenceTable="productdesigner_photoprint_config" referenceColumn="config_id"
                    onDelete="CASCADE"/>
        <index referenceId="PRODUCTDESIGNER_PHOTOPRINT_SIZE_CONFIG_ID" indexType="btree">
            <column name="config_id"/>
        </index>
    </table>
</schema>
