<?xml version="1.0" encoding="UTF-8"?>
<!--
    Document   : stocks.xml
    Author     : Carlos Garcia Gomez
    Description:
        Structure for the stocks table.
-->
<table>
    <column>
        <name>cantidad</name>
        <type>double precision</type>
        <default>0</default>
    </column>
    <column>
        <name>codalmacen</name>
        <type>character varying(4)</type>
        <null>NO</null>
    </column>
    <column>
        <name>disponible</name>
        <type>double precision</type>
        <default>0</default>
    </column>
    <column>
        <name>idproducto</name>
        <type>integer</type>
        <null>NO</null>
    </column>
    <column>
        <name>idstock</name>
        <type>serial</type>
        <null>NO</null>
    </column>
    <column>
        <name>pterecibir</name>
        <type>double precision</type>
        <default>0</default>
    </column>
    <column>
        <name>referencia</name>
        <type>character varying(30)</type>
        <null>NO</null>
    </column>
    <column>
        <name>reservada</name>
        <type>double precision</type>
        <default>0</default>
    </column>
    <column>
        <name>stockmax</name>
        <type>double precision</type>
        <default>0</default>
    </column>
    <column>
        <name>stockmin</name>
        <type>double precision</type>
        <default>0</default>
    </column>
    <column>
        <name>ubicacion</name>
        <type>character varying(100)</type>
    </column>
    <constraint>
        <name>stocks_pkey2</name>
        <type>PRIMARY KEY (idstock)</type>
    </constraint>
    <constraint>
        <name>ca_stocks_almacenes</name>
        <type>FOREIGN KEY (codalmacen) REFERENCES almacenes (codalmacen) ON DELETE CASCADE ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>ca_stocks_productos</name>
        <type>FOREIGN KEY (idproducto) REFERENCES productos (idproducto) ON DELETE CASCADE ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>ca_stocks_variantes</name>
        <type>FOREIGN KEY (referencia) REFERENCES variantes (referencia) ON DELETE CASCADE ON UPDATE CASCADE</type>
    </constraint>
    <constraint>
        <name>uniq_stocks_almacen_referencia</name>
        <type>UNIQUE (codalmacen, referencia)</type>
    </constraint>
</table>
