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

<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
    <table name="shippingmethod" resource="default" engine="innodb" comment="shippingmethod">
        <column xsi:type="int" name="method_id" unsigned="true" nullable="false" identity="true" comment="Method Id Primary key" />
        <column xsi:type="smallint" name="is_active" unsigned="true" nullable="false" default="0" comment="Is Active" />
        <column xsi:type="smallint" name="pos" unsigned="true" nullable="false" default="0" comment="Position" />
        <column xsi:type="varchar" name="name"  nullable="false" length="255" comment="Name" />
        <column xsi:type="varchar" name="comment" nullable="false"  comment="comment" />
        <column xsi:type="varchar" name="stores" nullable="false" length="255"  comment="stores" />
        <column xsi:type="varchar" name="cust_groups" nullable="false" length="255"  comment="cust_groups" />
        <column xsi:type="int" name="select_rate" unsigned="true" nullable="false" default="0" comment="select_rate" />
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="method_id" />
        </constraint>
    </table>
    <table name="shippingrate" resource="default" engine="innodb">
        <column xsi:type="int" name="rate_id" unsigned="true" nullable="false" identity="true" comment="Rate Id Primary key" />
        <column xsi:type="int" name="method_id" unsigned="true" nullable="false" default="0" comment="method_id" />
        <column xsi:type="varchar" name="country" nullable="false" length="4"  comment="country" />
        <column xsi:type="varchar" name="state" nullable="false" length="10" default="0" comment="state" />
        <column xsi:type="varchar" name="city" nullable="false" length="12" comment="city" />
        <column xsi:type="varchar" name="zip_from" nullable="false" length="10" comment="zip_from" />
        <column xsi:type="varchar" name="zip_to" nullable="false" length="10" comment="zip_to" />
        <column xsi:type="decimal" name="price_from" scale="4" precision="12" default="0" comment="price_from"/>
        <column xsi:type="decimal" name="price_to" scale="4" precision="12" default="0" comment="price_to"/>
        <column xsi:type="decimal" name="weight_from" scale="4" precision="12" default="0" comment="weight_from"/>
        <column xsi:type="decimal" name="weight_to" scale="4" precision="12" default="0" comment="weight_to"/>
        <column xsi:type="int" name="qty_from"  unsigned="true" nullable="false" default="0" comment="qty_from"/>
        <column xsi:type="int" name="qty_to"  unsigned="true" nullable="false" default="0" comment="qty_to"/>
        <column xsi:type="int" name="shipping_type"  unsigned="true" nullable="false" default="0" comment="shipping_type"/>
        <column xsi:type="decimal" name="cost_base" scale="4" precision="12" default="0" comment="cost_base"/>
        <column xsi:type="decimal" name="cost_percent" scale="4" precision="12" default="0" comment="cost_percent"/>
        <column xsi:type="decimal" name="cost_product" scale="4" precision="12" default="0" comment="cost_product"/>
        <column xsi:type="decimal" name="cost_weight" scale="4" precision="12" default="0" comment="cost_weight"/>
        <column xsi:type="varchar" name="time_delivery" nullable="false" length="255" comment="time_delivery"/>
        <column xsi:type="int" name="num_zip_from" padding="10"  comment="num_zip_from"/>
        <column xsi:type="int" name="num_zip_to" padding="10"  comment="num_zip_to"/>


        <index referenceId="shippingmethod_ind" indexType="btree">
            <column name="method_id"/>
        </index>
        <constraint xsi:type="primary" referenceId="PRIMARY">
            <column name="rate_id" />
        </constraint>
        <constraint xsi:type="foreign" referenceId="PROVINCE_PROVINCE_ID_CITY_PROVINCE_ID" table="shippingrate" column="method_id" referenceTable="shippingmethod" referenceColumn="method_id"/>
    </table>
</schema>