<?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">
    <table name="piehs_static_cache_page" resource="default" engine="innodb" comment="PieHS Static Cache Pages">
        <column xsi:type="int" name="page_id" unsigned="true" nullable="false" identity="true" comment="Page ID"/>
        <column xsi:type="varchar" name="page_type" length="32" nullable="false" comment="Page Type"/>
        <column xsi:type="varchar" name="page_identifier" length="191" nullable="false" comment="Page Identifier"/>
        <column xsi:type="smallint" name="store_id" unsigned="true" nullable="false" default="0" comment="Store ID"/>
        <column xsi:type="varchar" name="request_path" length="255" nullable="false" comment="Request Path"/>
        <column xsi:type="varchar" name="disk_path" length="512" nullable="false" comment="Disk Path"/>
        <column xsi:type="varchar" name="content_hash" length="64" nullable="true" comment="Content Hash"/>
        <column xsi:type="varchar" name="last_status" length="32" nullable="true" comment="Last Status"/>
        <column xsi:type="text" name="last_error" nullable="true" comment="Last Error"/>
        <column xsi:type="timestamp" name="last_rendered_at" nullable="true" on_update="false" comment="Last Rendered At"/>
        <column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP" on_update="false" comment="Created At"/>
        <column xsi:type="timestamp" name="updated_at" nullable="false" default="CURRENT_TIMESTAMP" on_update="true" comment="Updated At"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="page_id"/>
        </constraint>
        <constraint xsi:type="unique" referenceId="PIEHS_STATIC_CACHE_PAGE_TARGET_UNIQUE">
            <column name="page_type"/>
            <column name="page_identifier"/>
            <column name="store_id"/>
        </constraint>
        <index referenceId="PIEHS_STATIC_CACHE_PAGE_REQUEST_PATH" indexType="btree">
            <column name="request_path"/>
        </index>
    </table>

    <table name="piehs_static_cache_job" resource="default" engine="innodb" comment="PieHS Static Cache Jobs">
        <column xsi:type="int" name="job_id" unsigned="true" nullable="false" identity="true" comment="Job ID"/>
        <column xsi:type="varchar" name="dedupe_key" length="191" nullable="true" comment="Dedupe Key"/>
        <column xsi:type="varchar" name="page_type" length="32" nullable="false" comment="Page Type"/>
        <column xsi:type="varchar" name="page_identifier" length="191" nullable="false" comment="Page Identifier"/>
        <column xsi:type="smallint" name="store_id" unsigned="true" nullable="false" default="0" comment="Store ID"/>
        <column xsi:type="varchar" name="action" length="32" nullable="false" default="invalidate_render" comment="Action"/>
        <column xsi:type="varchar" name="status" length="16" nullable="false" default="pending" comment="Status"/>
        <column xsi:type="smallint" name="priority" unsigned="true" nullable="false" default="100" comment="Priority"/>
        <column xsi:type="smallint" name="attempts" unsigned="true" nullable="false" default="0" comment="Attempts"/>
        <column xsi:type="int" name="available_at" unsigned="true" nullable="false" default="0" comment="Available At Unix"/>
        <column xsi:type="int" name="locked_at" unsigned="true" nullable="true" comment="Locked At Unix"/>
        <column xsi:type="varchar" name="locked_by" length="128" nullable="true" comment="Locked By"/>
        <column xsi:type="text" name="last_error" nullable="true" comment="Last Error"/>
        <column xsi:type="varchar" name="source" length="128" nullable="true" comment="Source"/>
        <column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP" on_update="false" comment="Created At"/>
        <column xsi:type="timestamp" name="updated_at" nullable="false" default="CURRENT_TIMESTAMP" on_update="true" comment="Updated At"/>
        <column xsi:type="timestamp" name="finished_at" nullable="true" on_update="false" comment="Finished At"/>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="job_id"/>
        </constraint>
        <constraint xsi:type="unique" referenceId="PIEHS_STATIC_CACHE_JOB_DEDUPE_UNIQUE">
            <column name="dedupe_key"/>
        </constraint>
        <index referenceId="PIEHS_STATIC_CACHE_JOB_STATUS_AVAILABLE" indexType="btree">
            <column name="status"/>
            <column name="available_at"/>
            <column name="priority"/>
            <column name="job_id"/>
        </index>
        <index referenceId="PIEHS_STATIC_CACHE_JOB_TARGET" indexType="btree">
            <column name="page_type"/>
            <column name="page_identifier"/>
            <column name="store_id"/>
        </index>
    </table>
</schema>
