--
-- pguserQL database dump
--



--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: 
--

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;


--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: 
--

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';





--
-- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE ar_internal_metadata (
    key character varying NOT NULL,
    value character varying,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL
);


ALTER TABLE ar_internal_metadata OWNER TO pguser;

--
-- Name: areareparto; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE areareparto
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 5500
    CACHE 1;


ALTER TABLE areareparto OWNER TO pguser;


--
-- Name: area_reparto; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE area_reparto (
    id_local integer,
    latitud character varying(50),
    longitud character varying(50),
    id_ubicacion integer DEFAULT nextval('areareparto'::regclass) NOT NULL,
    id_poligono integer NOT NULL
);


ALTER TABLE area_reparto OWNER TO pguser;

--
-- Name: areatipo; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE areatipo
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 555000000000
    CACHE 1;


ALTER TABLE areatipo OWNER TO pguser;

--
-- Name: area_tipo; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE area_tipo (
    id_reparto integer DEFAULT nextval('areatipo'::regclass) NOT NULL,
    descripcion character varying(60),
    id_local integer DEFAULT 0,
    activo integer DEFAULT 0,
    costo_despacho integer
);
ALTER TABLE ONLY area_tipo ALTER COLUMN id_local SET STATISTICS 100;


ALTER TABLE area_tipo OWNER TO pguser;


--
-- Name: arqueo_caja; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE arqueo_caja (
    fecha date,
    id_turno smallint NOT NULL,
    id_operador smallint NOT NULL,
    id_tipopago smallint NOT NULL,
    montocaja integer,
    montosistema integer,
    id_local smallint NOT NULL,
    id integer NOT NULL,
    diferencia numeric(12,2) DEFAULT 0,
    nombre_caja character varying(20) DEFAULT NULL::character varying
);


ALTER TABLE arqueo_caja OWNER TO pguser;

--
-- Name: arqueo_caja_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE arqueo_caja_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE arqueo_caja_id_seq OWNER TO pguser;

--
-- Name: arqueo_caja_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE arqueo_caja_id_seq OWNED BY arqueo_caja.id;


--
-- Name: articulo; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE articulo (
    id_articulo integer NOT NULL,
    id_mayorarticulo integer,
    id_unidadcompra integer,
    id_unidadinventario integer,
    id_unidadreceta integer,
    art_nombre character varying(60),
    art_descripcion text,
    art_marca double precision,
    art_impuesto1 numeric(12,2),
    art_impuesto2 numeric(12,2),
    art_fmodificacion date,
    borrado boolean DEFAULT false,
    id_externo bigint,
    art_costo numeric(12,2),
    art_codigo character varying(50),
    art_invxcompra numeric(12,2),
    art_recetaxinventario numeric(12,2),
    id_artpadre integer,
    id_receta integer,
    ultprecio numeric(12,2),
    id_bodega integer DEFAULT 1,
    art_sinicial numeric(12,2),
    art_smin numeric(12,2),
    art_smax numeric(12,2),
    art_codigo_barra_uc character varying(50),
    art_codigo_barra_ui character varying(50)
);


ALTER TABLE articulo OWNER TO pguser;

--
-- Name: COLUMN articulo.ultprecio; Type: COMMENT; Schema: public; Owner: pguser
--

COMMENT ON COLUMN articulo.ultprecio IS 'ultimo precio de compra que se actualiza con el sincronizador';


--
-- Name: articulo_asociado; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE articulo_asociado (
    id_art_ext integer NOT NULL,
    id_asociacion integer NOT NULL
);


ALTER TABLE articulo_asociado OWNER TO pguser;

--
-- Name: TABLE articulo_asociado; Type: COMMENT; Schema: public; Owner: pguser
--

COMMENT ON TABLE articulo_asociado IS 'Esta tabla es el embudo de articulos de SAP a los articulos de Methodo.

En una asociacion no pueden haber ids de articulos externos repetidos, por eso se agreg el indice unico id_a_ext.';


--
-- Name: articulo_externo; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE articulo_externo (
    id_art_ext bigint NOT NULL,
    nombre character varying(60)
);


ALTER TABLE articulo_externo OWNER TO pguser;

--
-- Name: articulo_inventario; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE articulo_inventario (
    id_articulo bigint NOT NULL,
    id_tipolocal integer NOT NULL,
    tipo_inventario smallint DEFAULT 0,
    lapso smallint
);


ALTER TABLE articulo_inventario OWNER TO pguser;

--
-- Name: TABLE articulo_inventario; Type: COMMENT; Schema: public; Owner: pguser
--

COMMENT ON TABLE articulo_inventario IS 'El tipo de inventario es:
0: con el inventario general
1: diario
2: semanal, usa lapso como el dia de la semana
3: mensual, usa lapso como el dia del mes ';


--
-- Name: articulo_stock; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE articulo_stock (
    id_local integer,
    id_articulo integer,
    ars_fecha date,
    ars_cantsys integer,
    ars_cantusu integer
);


ALTER TABLE articulo_stock OWNER TO pguser;


--
-- Name: articulo_tipo_local; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE articulo_tipo_local (
    id_articulo integer NOT NULL,
    id_tipolocal integer NOT NULL,
    estado integer
);


ALTER TABLE articulo_tipo_local OWNER TO pguser;


--
-- Name: asociacion; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE asociacion (
    id_asociacion integer NOT NULL,
    nombre character varying(100) NOT NULL,
    id_articulo integer NOT NULL
);


ALTER TABLE asociacion OWNER TO pguser;

--
-- Name: bodega; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE bodega (
    id_local integer NOT NULL,
    id_bodega integer NOT NULL,
    nombre character varying(25),
    descripcion character varying(40),
    merma integer
);


ALTER TABLE bodega OWNER TO pguser;

--
-- Name: boletas; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE boletas (
    id bigint NOT NULL,
    id_local bigint NOT NULL,
    dfecha date,
    ncaja bigint,
    nmonto double precision,
    nboleini double precision,
    nbolefin double precision,
    clocal character(3),
    id_turno bigint,
    nombre_documento character varying(50)
);


ALTER TABLE boletas OWNER TO pguser;

--
-- Name: centro_costo; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE centro_costo (
    id_centrocosto integer NOT NULL,
    id_cliente integer,
    nombre character varying(50) DEFAULT NULL::character varying,
    activo integer,
    codig character varying(25) DEFAULT NULL::character varying
);


ALTER TABLE centro_costo OWNER TO pguser;

--
-- Name: centro_ingreso; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE centro_ingreso (
    id_centroingreso integer NOT NULL,
    ci_nombre character varying(30) NOT NULL,
    ci_caja_asociada character varying(20),
    id_local integer
);


ALTER TABLE centro_ingreso OWNER TO pguser;


--
-- Name: ciudad; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE ciudad (
    ciu_sec_codigo character varying(4),
    ciu_sec_nombre character varying(100),
    ciu_prin_codigo character varying(4),
    ciu_prin_nombre character varying(100)
);


ALTER TABLE ciudad OWNER TO pguser;

--
-- Name: clase_prod_cfg; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE clase_prod_cfg (
    id_claseprodcfg integer NOT NULL,
    id_claseproducto integer,
    id_centroingreso integer,
    id_impresora integer,
    id_periodoatencion integer,
    id_bodega integer,
    precio integer,
    id_impcopia integer,
    id_impbackup integer,
    impresorapadre integer,
    id_local integer
);


ALTER TABLE clase_prod_cfg OWNER TO pguser;

--
-- Name: clase_prod_local; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE clase_prod_local (
    id_tipolocal integer NOT NULL,
    id_claseproducto integer NOT NULL
);


ALTER TABLE clase_prod_local OWNER TO pguser;


--
-- Name: clase_producto; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE clase_producto (
    id_claseproducto smallint NOT NULL,
    nombre character varying(30),
    descripcion character varying(100)
);


ALTER TABLE clase_producto OWNER TO pguser;

--
-- Name: cliente_ecommerce; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE cliente_ecommerce (
    id_cadena integer NOT NULL,
    nombre_cadena character varying(50),
    url_logo_cadena character varying(250),
    monto_minimo integer DEFAULT 0,
    correo character varying(250),
    carpeta_local character varying(100)
);


ALTER TABLE cliente_ecommerce OWNER TO pguser;


--
-- Name: cliente_ecommercelocal; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE cliente_ecommercelocal (
    id_usuarioecommerce integer,
    id_local character varying(15),
    estado integer DEFAULT 0
);


ALTER TABLE cliente_ecommercelocal OWNER TO pguser;


--
-- Name: clientes; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE clientes (
    id_cliente integer NOT NULL,
    id_local integer NOT NULL,
    rut character varying(9),
    nombre character varying(40),
    apellidos character varying(18),
    actividad character varying(60),
    direccion character varying(300),
    comuna character varying(15),
    ciudad character varying(15),
    telefono_casa character varying(20),
    telefono_of character varying(20),
    observaciones character varying(100),
    fecha_ingreso date,
    fecha_modificacion date,
    tope_credito real,
    id_convenio integer,
    id_padre integer,
    tipo character varying(10),
    id_centrocosto integer,
    nrotarjeta character varying(50),
    inibloq date,
    finbloq date,
    bloqueado integer,
    cdiario integer,
    razonbloq character varying(100),
    dv character(1),
    tope_consumo real,
    activo integer,
    usa_delivery integer,
    sobregiro real,
    cumple date,
    tipo_puntaje integer,
    email character varying(100),
    credito_restringido numeric(12,2),
    credito_libre numeric(12,2),
    socio integer,
    id_operador integer,
    h_ini_bloqueo time without time zone,
    h_fin_bloqueo time without time zone,
    puntaje integer,
    password character varying(15),
    facebook_id character varying(30),
    google_id character varying(30),
    codigo character varying(10),
    sexo character varying(20),
    id_usuarioecommerce integer,
    fecha_bloqueo date DEFAULT '1900-01-01'::date,
    id integer NOT NULL
);


ALTER TABLE clientes OWNER TO pguser;

--
-- Name: clientes_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE clientes_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE clientes_id_seq OWNER TO pguser;

--
-- Name: clientes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE clientes_id_seq OWNED BY clientes.id;


--
-- Name: colores_ecommerce; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE colores_ecommerce (
    id_cadena integer,
    nombre_color character varying(50),
    orden integer
);


ALTER TABLE colores_ecommerce OWNER TO pguser;

--
-- Name: control_exportacion; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE control_exportacion (
    id_control integer NOT NULL,
    valor_int bigint,
    descripcion character varying(50),
    id_local smallint NOT NULL
);


ALTER TABLE control_exportacion OWNER TO pguser;

--
-- Name: control_inventario; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE control_inventario (
    id_local integer,
    id_articulo integer,
    ci_tipo integer,
    ci_periodo integer,
    ci_partida date,
    ci_fmodificacion date
);


ALTER TABLE control_inventario OWNER TO pguser;

--
-- Name: convenio; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE convenio (
    id_convenio integer NOT NULL,
    id_cliente integer,
    id_tipo_convenio integer,
    inicio date,
    fin date,
    nombre character varying(30) DEFAULT NULL::character varying,
    descripcion character varying(70) DEFAULT NULL::character varying,
    iniciobloqueo date,
    termbloqueo date,
    dia_pago real,
    observacion character varying(50),
    bloqueado integer
);


ALTER TABLE convenio OWNER TO pguser;

--
-- Name: convenio_id_convenio_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE convenio_id_convenio_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE convenio_id_convenio_seq OWNER TO pguser;

--
-- Name: convenio_id_convenio_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE convenio_id_convenio_seq OWNED BY convenio.id_convenio;


--
-- Name: credito_cliente; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE credito_cliente (
    id_local integer NOT NULL,
    id_credito integer NOT NULL,
    id_cliente integer NOT NULL,
    fecha date,
    facturado real,
    id_mesa integer,
    id_docto integer,
    pagado real,
    monto real,
    id_centrocosto integer,
    id_convenio integer,
    numero integer
);


ALTER TABLE credito_cliente OWNER TO pguser;

--
-- Name: credito_cliente_id_credito_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE credito_cliente_id_credito_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE credito_cliente_id_credito_seq OWNER TO pguser;

--
-- Name: credito_cliente_id_credito_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE credito_cliente_id_credito_seq OWNED BY credito_cliente.id_credito;



--
-- Name: deli_destino; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE deli_destino (
    id_destino integer NOT NULL,
    id_cliente integer,
    calle character varying(100),
    numero character varying(15),
    depto character varying(15),
    block character varying(15),
    contacto character varying(100),
    fono_contacto character varying(100),
    ciu_sec_codigo character varying(3),
    borrado integer,
    maestro integer,
    otrodato character varying(100),
    id_local integer,
    comuna character varying(100)
);
ALTER TABLE ONLY deli_destino ALTER COLUMN id_destino SET STATISTICS 0;


ALTER TABLE deli_destino OWNER TO pguser;

--
-- Name: deli_detalle; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE deli_detalle (
    id_detalle_orden integer NOT NULL,
    id_producto integer,
    cantidad integer,
    id_deliorden integer,
    precio integer
);


ALTER TABLE deli_detalle OWNER TO pguser;

--
-- Name: delifpago; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE delifpago
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 5555555555555
    CACHE 1;


ALTER TABLE delifpago OWNER TO pguser;

--
-- Name: deli_fpago_ecommerce; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE deli_fpago_ecommerce (
    id_deli_ecommerce integer DEFAULT nextval('delifpago'::regclass) NOT NULL,
    id_tipopago integer,
    monto integer,
    id_mesaecommerce integer,
    vuelto_efectivo real,
    estado integer,
    id_local integer NOT NULL,
    id_usuarioecommerce integer
);


ALTER TABLE deli_fpago_ecommerce OWNER TO pguser;

--
-- Name: deli_orden; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE deli_orden (
    id_deli_orden integer NOT NULL,
    id_cliente integer,
    id_destino integer,
    id_mesa integer,
    fecha date NOT NULL,
    tiempo_max integer,
    observacion character varying(200),
    finalizada time without time zone,
    reparto time without time zone,
    retiro integer,
    llegada time without time zone,
    id_local integer,
    hora time(6) without time zone,
    consumo numeric(12,2),
    hora_entrega time without time zone,
    accesorios character varying(100),
    accesorios_estado integer,
    repartidor integer
);


ALTER TABLE deli_orden OWNER TO pguser;

--
-- Name: descuentoe; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE descuentoe
    START WITH 16
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 50000
    CACHE 1;


ALTER TABLE descuentoe OWNER TO pguser;

--
-- Name: descuento_ecommerce; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE descuento_ecommerce (
    id_descuento integer DEFAULT nextval('descuentoe'::regclass) NOT NULL,
    codigo character varying(15),
    porcentaje_descuento integer,
    fecha_inicio date,
    fecha_termino date,
    activo smallint DEFAULT 0
);


ALTER TABLE descuento_ecommerce OWNER TO pguser;

--
-- Name: detalle_did; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE detalle_did (
    id_local bigint,
    id_did bigint,
    id_articulo bigint,
    cantidad numeric(12,2),
    preciounit numeric(12,2)
);


ALTER TABLE detalle_did OWNER TO pguser;


--
-- Name: detalle_factura; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE detalle_factura (
    id_factura integer,
    id_local integer,
    id_articulo integer,
    cantidad real,
    precio real,
    imp1 real,
    imp2 real,
    descto_monto real,
    recargo_monto real
);


ALTER TABLE detalle_factura OWNER TO pguser;


--
-- Name: detalle_gd; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE detalle_gd (
    id_articulo integer,
    id_guiadespacho integer,
    dgd_cantidad integer,
    dgd_preciounit integer,
    dgd_desc integer,
    dgd_recargo integer,
    dgd_monto integer
);


ALTER TABLE detalle_gd OWNER TO pguser;


--
-- Name: detalle_gdc; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE detalle_gdc (
    id_articulo integer,
    id_guiadespachocompra integer,
    dgc_preciounit double precision,
    dgc_cantidad real,
    dgc_preciounit2 double precision,
    dgc_cantidad2 double precision,
    id_local bigint NOT NULL,
    desc_monto double precision DEFAULT 0,
    recargo double precision DEFAULT 0,
    recargo_monto double precision DEFAULT 0
);


ALTER TABLE detalle_gdc OWNER TO pguser;

--
-- Name: detalle_log_sinc; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE detalle_log_sinc (
    id_logsincronizacion bigint,
    dls_inicio character varying(10),
    dls_accion character varying(20),
    dls_fin character varying(10),
    dls_estado character varying(200)
);


ALTER TABLE detalle_log_sinc OWNER TO pguser;


--
-- Name: detalle_menu_especial; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE detalle_menu_especial (
    fk_menu_especial integer NOT NULL,
    fk_producto integer NOT NULL,
    cantidad integer NOT NULL
);


ALTER TABLE detalle_menu_especial OWNER TO pguser;


--
-- Name: detalle_nc; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE detalle_nc (
    id_notacredito integer,
    id_articulo integer,
    dnc_cantidad integer,
    dnc_preciounit integer
);


ALTER TABLE detalle_nc OWNER TO pguser;

--
-- Name: detalle_oc; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE detalle_oc (
    id_ordencompra integer,
    id_articulo integer,
    doc_preciounit integer,
    doc_cantidad real
);


ALTER TABLE detalle_oc OWNER TO pguser;

--
-- Name: detalle_orden; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE detalle_orden (
    id_local integer,
    id_orden bigint,
    id_articulo bigint,
    precio bigint,
    cantidad double precision
);


ALTER TABLE detalle_orden OWNER TO pguser;

--
-- Name: detalle_tipo_convenio; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE detalle_tipo_convenio (
    id_tipo_convenio integer NOT NULL,
    preciounit real,
    id_producto integer DEFAULT 0,
    captura integer DEFAULT 0
);


ALTER TABLE detalle_tipo_convenio OWNER TO pguser;

--
-- Name: detalle_tipo_convenio_id_tipo_convenio_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE detalle_tipo_convenio_id_tipo_convenio_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE detalle_tipo_convenio_id_tipo_convenio_seq OWNER TO pguser;

--
-- Name: detalle_tipo_convenio_id_tipo_convenio_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE detalle_tipo_convenio_id_tipo_convenio_seq OWNED BY detalle_tipo_convenio.id_tipo_convenio;


--
-- Name: detmovart; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE detmovart (
    id_local smallint NOT NULL,
    id_detmovart bigint NOT NULL,
    id_mov bigint NOT NULL,
    id_tipo bigint,
    nmov bigint,
    id_articulo bigint,
    preciounit double precision,
    cant double precision,
    enstock double precision,
    id_bodorigen bigint,
    id_boddestino bigint,
    mov bigint,
    saldo double precision,
    debe double precision,
    haber double precision,
    total double precision,
    costounitant double precision,
    stockant double precision,
    id_bodega bigint,
    costounit double precision,
    id_centroingreso bigint,
    borigen character varying(50),
    bdestino character varying(50)
);


ALTER TABLE detmovart OWNER TO pguser;

--
-- Name: dias_atencion; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE dias_atencion (
    id_local integer,
    numero_dia integer,
    hora_apertura time without time zone,
    hora_cierra time without time zone
);


ALTER TABLE dias_atencion OWNER TO pguser;


--
-- Name: did; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE did (
    id_local bigint,
    id_did bigint,
    id_facturalocal bigint,
    id_guialocal bigint,
    fecha date,
    id_facturacentralizador bigint,
    id_guiacentralizador bigint,
    total numeric(12,2)
);


ALTER TABLE did OWNER TO pguser;


--
-- Name: docto_anul; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE docto_anul (
    id_tipodocto smallint NOT NULL,
    numero integer NOT NULL,
    fecha date,
    id_mesa integer,
    id_operador smallint,
    monto integer,
    nmesa integer,
    id_local smallint NOT NULL,
    id_docto_anul bigint NOT NULL,
    id integer NOT NULL
);


ALTER TABLE docto_anul OWNER TO pguser;

--
-- Name: docto_anul_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE docto_anul_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE docto_anul_id_seq OWNER TO pguser;

--
-- Name: docto_anul_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE docto_anul_id_seq OWNED BY docto_anul.id;


--
-- Name: docto_cliente; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE docto_cliente (
    id_mesa integer NOT NULL,
    id_tipodocto integer NOT NULL,
    ndocto character varying(50) NOT NULL,
    monto integer,
    fecha date,
    id_local integer NOT NULL,
    estado character varying(1),
    id integer NOT NULL
);


ALTER TABLE docto_cliente OWNER TO pguser;

--
-- Name: docto_cliente_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE docto_cliente_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE docto_cliente_id_seq OWNER TO pguser;

--
-- Name: docto_cliente_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE docto_cliente_id_seq OWNED BY docto_cliente.id;


--
-- Name: doctoscompra; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE doctoscompra
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE doctoscompra OWNER TO pguser;

--
-- Name: doctosventas; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE doctosventas
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE doctosventas OWNER TO pguser;

--
-- Name: factura; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE factura (
    id_factura integer NOT NULL,
    fac_ndocto bigint,
    fac_fecha date,
    fac_monto bigint,
    fac_estado integer,
    fac_tipopago integer,
    fac_pagado integer,
    fac_fvencimiento date,
    fac_proveedor integer,
    fac_desc_monto integer,
    fac_desc_porce integer,
    fac_recargo_monto integer,
    fac_recargo_porce integer,
    fac_observaciones text,
    id_orden integer,
    fac_impuesto1 integer,
    fac_impuesto2 integer,
    fac_clasifica integer
);


ALTER TABLE factura OWNER TO pguser;

--
-- Name: familia; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE familia (
    id_familia integer NOT NULL,
    id_familiabase integer,
    id_familiareq integer,
    fam_nombre character varying(12),
    fam_descripcion character varying(50),
    fam_fmodificacion date,
    fam_clase integer DEFAULT 1,
    fam_id_grupomayor integer DEFAULT 1,
    fam_max_descuento integer DEFAULT 100 NOT NULL,
    fam_exenta smallint DEFAULT 0 NOT NULL,
    fam_maxreq integer DEFAULT 0,
    ecommerce smallint DEFAULT 0,
    fam_color character varying(20),
    fam_fondo character varying(20),
    mensaje integer DEFAULT 0,
    prioridad integer DEFAULT 0,
    accesorio integer DEFAULT 0
);


ALTER TABLE familia OWNER TO pguser;


--
-- Name: familia_tipo_local; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE familia_tipo_local (
    id_familia integer NOT NULL,
    id_tipolocal integer NOT NULL,
    estado integer
);


ALTER TABLE familia_tipo_local OWNER TO pguser;


--
-- Name: fpago_mesa; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE fpago_mesa (
    id_mesa bigint,
    id_tipopago integer,
    monto bigint,
    fecha date,
    infopago text,
    id_fpago_mesa bigint,
    id_centroingreso integer,
    id_turno integer,
    id_cliente integer,
    id_local integer,
    id_tipo_pago integer,
    id integer NOT NULL
);


ALTER TABLE fpago_mesa OWNER TO pguser;

--
-- Name: fpago_mesa_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE fpago_mesa_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE fpago_mesa_id_seq OWNER TO pguser;

--
-- Name: fpago_mesa_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE fpago_mesa_id_seq OWNED BY fpago_mesa.id;


--
-- Name: general; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE general
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE general OWNER TO pguser;

--
-- Name: grupo_mayor; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE grupo_mayor (
    id_grupomayor integer NOT NULL,
    grm_nombre character varying(60),
    grm_descripcion text
);


ALTER TABLE grupo_mayor OWNER TO pguser;

--
-- Name: guia_despacho; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE guia_despacho (
    id_guiadespacho integer NOT NULL,
    id_transportista integer,
    id_factura integer,
    gd_fecha date,
    gd_ndocto bigint,
    gd_estado integer,
    gd_local_origen integer,
    gd_local_destino integer,
    gd_tipo integer,
    gd_proveedor bigint,
    gd_desc_monto integer,
    gd_desc_porce integer,
    gd_recargo_monto integer,
    gd_recargo_porce integer,
    id_orden integer
);


ALTER TABLE guia_despacho OWNER TO pguser;

--
-- Name: guia_despacho_compra; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE guia_despacho_compra (
    id_guiadespachocompra integer NOT NULL,
    id_proveedor integer,
    id_ordencompra integer,
    gdc_ndocto bigint,
    gdc_fecha date,
    gdc_nrodid bigint,
    gdc_estado integer,
    gdc_local integer NOT NULL,
    gdc_tipo integer,
    id_transportista integer,
    id_facturacompra integer,
    id_notacredito integer,
    did_ndocto integer,
    did_fecha date,
    did_estado integer,
    desc_porcent bigint DEFAULT 0,
    desc_monto bigint DEFAULT 0,
    recargo_porcent bigint DEFAULT 0,
    recargo_monto bigint DEFAULT 0
);


ALTER TABLE guia_despacho_compra OWNER TO pguser;


--
-- Name: historico_cpp; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE historico_cpp (
    id_histcpp integer DEFAULT nextval(('"public"."historico_cpp_id_seq"'::text)::regclass) NOT NULL,
    id_movfco integer,
    id_articulo integer,
    cantidad numeric(11,2),
    costo_compra numeric(11,2),
    costo_anterior numeric(11,2),
    fecha timestamp(0) without time zone,
    usuario integer,
    tipo_mov character varying(1)
);


ALTER TABLE historico_cpp OWNER TO pguser;

--
-- Name: historico_cpp_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE historico_cpp_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE historico_cpp_id_seq OWNER TO pguser;

--
-- Name: historico_traspasogd; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE historico_traspasogd (
    "id_histTrasGD" integer DEFAULT nextval(('"public"."historico_traspasogd_id_seq"'::text)::regclass),
    id_movguia integer,
    id_articulo integer,
    cantidad integer,
    costo_traspaso integer,
    fecha timestamp without time zone,
    usuario integer,
    costo_anterior integer
);


ALTER TABLE historico_traspasogd OWNER TO pguser;

--
-- Name: historico_traspasogd_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE historico_traspasogd_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE historico_traspasogd_id_seq OWNER TO pguser;

--
-- Name: horarioatencion; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE horarioatencion
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 2500
    CACHE 1;


ALTER TABLE horarioatencion OWNER TO pguser;

--
-- Name: horario_atencion; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE horario_atencion (
    id_horario integer DEFAULT nextval('horarioatencion'::regclass) NOT NULL,
    dia integer,
    apertura time without time zone,
    cierre time without time zone,
    id_local integer,
    abierto integer
);


ALTER TABLE horario_atencion OWNER TO pguser;

--
-- Name: id_tipo_log; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE id_tipo_log
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE id_tipo_log OWNER TO pguser;

--
-- Name: id_token; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE id_token
    START WITH 10
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 999999999999
    CACHE 1;


ALTER TABLE id_token OWNER TO pguser;

--
-- Name: id_ventadia; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE id_ventadia
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 5555555555555
    CACHE 1;


ALTER TABLE id_ventadia OWNER TO pguser;

--
-- Name: impresora; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE impresora (
    id_impresora integer,
    imp_nombre character varying(20)
);


ALTER TABLE impresora OWNER TO pguser;

--
-- Name: impresora_local; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE impresora_local (
    id_impresora integer NOT NULL,
    id_tipolocal integer NOT NULL
);


ALTER TABLE impresora_local OWNER TO pguser;

--
-- Name: impresora_tipo_local; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE impresora_tipo_local (
    id_tipolocal integer,
    id_impresora integer,
    itl_tipo integer
);


ALTER TABLE impresora_tipo_local OWNER TO pguser;


--
-- Name: inventario_parcial; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE inventario_parcial (
    id_local bigint NOT NULL,
    id bigint NOT NULL,
    id_articulo bigint,
    id_bodega bigint,
    fecha date,
    stock_actual double precision,
    stock_real double precision,
    stock_teorico double precision,
    compras numeric(11,2) DEFAULT 0,
    stock_ini numeric(11,2) DEFAULT 0,
    precio_compra numeric(11,2) DEFAULT 0
);


ALTER TABLE inventario_parcial OWNER TO pguser;

--
-- Name: COLUMN inventario_parcial.precio_compra; Type: COMMENT; Schema: public; Owner: pguser
--

COMMENT ON COLUMN inventario_parcial.precio_compra IS 'es el precio que tiene el artculo cuando se compra con ivas incluidos';


--
-- Name: local; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE local (
    id_local integer NOT NULL,
    id_tipolocal integer,
    loc_nombre character varying(60),
    loc_direccion character varying(60),
    loc_ip character varying(50),
    loc_rut character varying(10),
    activo integer DEFAULT 0,
    apertura time(0) without time zone,
    cierre time(0) without time zone,
    id_cadena integer,
    monto_minimo integer DEFAULT 0,
    despacho integer DEFAULT 0,
    telefono character varying(15),
    id_fbh integer,
    dia_conexion integer,
    hora_conexion time(0) without time zone,
    dia character varying(10),
    ult_conexion date,
    inicio time(6) without time zone,
    fin time(6) without time zone,
    turno_cortado integer DEFAULT 0
);
ALTER TABLE ONLY local ALTER COLUMN activo SET STATISTICS 0;


ALTER TABLE local OWNER TO pguser;

--
-- Name: local_articulo; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE local_articulo (
    id_local bigint NOT NULL,
    id_articulo bigint NOT NULL,
    lar_smin integer,
    lar_smax integer
);


ALTER TABLE local_articulo OWNER TO pguser;

--
-- Name: log; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE log (
    id_usuario integer,
    log_tipoaccion integer,
    log_hora character varying(10),
    log_fecha date,
    log_descripcion text
);


ALTER TABLE log OWNER TO pguser;

--
-- Name: seq_form; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE seq_form
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE seq_form OWNER TO pguser;


--
-- Name: log_form; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE log_form (
    id_form integer DEFAULT nextval('seq_form'::regclass) NOT NULL,
    nombre text
);


ALTER TABLE log_form OWNER TO pguser;

--
-- Name: log_sesion; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE log_sesion (
    id_usuario integer NOT NULL,
    fecha date DEFAULT now(),
    hora time(0) without time zone DEFAULT ('now'::text)::time with time zone,
    accion integer
);


ALTER TABLE log_sesion OWNER TO pguser;

--
-- Name: COLUMN log_sesion.accion; Type: COMMENT; Schema: public; Owner: pguser
--

COMMENT ON COLUMN log_sesion.accion IS '1: Inicio sesion-2: Cerro sesion';



--
-- Name: log_sincronizacion; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE log_sincronizacion (
    id_logsincronizacion integer DEFAULT nextval(('"public"."log_sincronizacion_id_logsincronizacion_seq"'::text)::regclass) NOT NULL,
    id_local integer,
    ls_fecha date,
    ls_inicio character varying(10),
    ls_fin character varying(10),
    ls_estado character varying(50),
    numero_ip character varying(20),
    nombre_pc character varying(20),
    id_operador integer
);


ALTER TABLE log_sincronizacion OWNER TO pguser;

--
-- Name: log_sincronizacion_id_logsincronizacion_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE log_sincronizacion_id_logsincronizacion_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 2147483647
    CACHE 1;


ALTER TABLE log_sincronizacion_id_logsincronizacion_seq OWNER TO pguser;

--
-- Name: reg_transaccion; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE reg_transaccion
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE reg_transaccion OWNER TO pguser;


--
-- Name: log_transaccion; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE log_transaccion (
    id_transaccion integer DEFAULT nextval('reg_transaccion'::regclass) NOT NULL,
    id_usuario integer,
    id_tipo_reg integer,
    fecha timestamp(0) without time zone,
    detalle text,
    id_log_form integer
);


ALTER TABLE log_transaccion OWNER TO pguser;

--
-- Name: mailecommerce; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE mailecommerce
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 50000
    CACHE 1;


ALTER TABLE mailecommerce OWNER TO pguser;

--
-- Name: mail_ecommerce; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE mail_ecommerce (
    id_mail integer DEFAULT nextval('mailecommerce'::regclass) NOT NULL,
    detalle character varying(200),
    tipo_mail integer
);


ALTER TABLE mail_ecommerce OWNER TO pguser;


--
-- Name: mayor_articulo; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE mayor_articulo (
    id_mayorarticulo integer NOT NULL,
    id_subgrupomayor integer,
    mar_nombre character varying(60),
    mar_descripcion character varying(100),
    id_grupomayor integer
);


ALTER TABLE mayor_articulo OWNER TO pguser;


--
-- Name: menu_especial; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE menu_especial (
    id_menu_especial integer NOT NULL,
    nombre character varying(12) NOT NULL,
    descripcion character varying(50) NOT NULL,
    maximo_descto integer NOT NULL,
    valor_menu double precision NOT NULL,
    activo integer NOT NULL,
    fk_clase_producto integer NOT NULL,
    fk_grupo_mayor integer NOT NULL,
    fk_local integer NOT NULL
);


ALTER TABLE menu_especial OWNER TO pguser;

--
-- Name: menu_especial_id_menu_especial_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE menu_especial_id_menu_especial_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE menu_especial_id_menu_especial_seq OWNER TO pguser;

--
-- Name: menu_especial_id_menu_especial_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE menu_especial_id_menu_especial_seq OWNED BY menu_especial.id_menu_especial;


--
-- Name: mesaecommerce; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE mesaecommerce
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 5555555555555555
    CACHE 1;


ALTER TABLE mesaecommerce OWNER TO pguser;

--
-- Name: mesa_ecommerce; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE mesa_ecommerce (
    id_mesaecommerce integer DEFAULT nextval('mesaecommerce'::regclass) NOT NULL,
    fecha date,
    id_local integer,
    id_usuarioecommerce integer,
    estado integer,
    hora time without time zone,
    tipo_envio integer DEFAULT 0,
    calle character varying,
    numero character varying,
    depto character varying,
    comuna character varying,
    ciudad character varying,
    tiempo_entrega integer,
    hora_entrega character varying(8),
    entregado_mail integer DEFAULT 0,
    a_reparto integer DEFAULT 0,
    descuento integer DEFAULT 0,
    sell_id integer DEFAULT 0,
    block character varying(10) DEFAULT 0,
    estado_coneccion_pos integer DEFAULT 0,
    provider character varying(10),
    finalizado integer DEFAULT 0,
    monto_descuento double precision,
    cancelado integer DEFAULT 0,
    observacion character varying(300),
    direccion_mac character varying
);


ALTER TABLE mesa_ecommerce OWNER TO pguser;


--
-- Name: mesahist; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE mesahist (
    id_local bigint NOT NULL,
    id_mesa bigint NOT NULL,
    operador integer NOT NULL,
    abierta time without time zone NOT NULL,
    cerrada time without time zone,
    numero integer,
    invitados integer,
    consumo integer,
    propina integer,
    descuento integer,
    fecha date,
    id_centroingreso integer,
    id_tipoventa integer,
    id_turno integer,
    id_cliente integer,
    tdocto integer,
    tipo_docto character varying(30),
    ecommerce integer
);


ALTER TABLE mesahist OWNER TO pguser;

--
-- Name: TABLE mesahist; Type: COMMENT; Schema: public; Owner: pguser
--

COMMENT ON TABLE mesahist IS 'Tabla que contiene la informacion conserniente a la venta de una mesa, esta relacionada con la tabla de documentos del cliente (docto_cliente) la cual tiene todos los movimientos de los papeles generados por la venta';


--
-- Name: migrations; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE migrations (
    id integer NOT NULL,
    migration character varying(255) NOT NULL,
    batch integer NOT NULL
);


ALTER TABLE migrations OWNER TO pguser;

--
-- Name: migrations_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE migrations_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE migrations_id_seq OWNER TO pguser;

--
-- Name: migrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE migrations_id_seq OWNED BY migrations.id;


--
-- Name: modulo; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE modulo (
    id_modulo integer DEFAULT nextval(('"public"."modulo_id_modulo_seq"'::text)::regclass) NOT NULL,
    mod_nombre character varying(60),
    mod_titulo character varying(60),
    mod_directorio character varying(256)
);


ALTER TABLE modulo OWNER TO pguser;

--
-- Name: modulo_id_modulo_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE modulo_id_modulo_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 2147483647
    CACHE 1;


ALTER TABLE modulo_id_modulo_seq OWNER TO pguser;

--
-- Name: monitor_cocinas; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE monitor_cocinas (
    id bigint NOT NULL,
    alerta_1 integer,
    alerta_2 integer,
    centro_de_produccion text,
    centro_de_produccion_id integer,
    created_at timestamp without time zone NOT NULL,
    updated_at timestamp without time zone NOT NULL,
    alerta_3 integer
);


ALTER TABLE monitor_cocinas OWNER TO pguser;

--
-- Name: monitor_cocinas_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE monitor_cocinas_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE monitor_cocinas_id_seq OWNER TO pguser;

--
-- Name: monitor_cocinas_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE monitor_cocinas_id_seq OWNED BY monitor_cocinas.id;


--
-- Name: movart; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE movart (
    id_local smallint NOT NULL,
    id_mov bigint NOT NULL,
    descripcion character varying(50),
    fecha date,
    borigen character varying(50),
    bdestino character varying(50),
    tipo bigint,
    exportado smallint DEFAULT 0
);


ALTER TABLE movart OWNER TO pguser;

--
-- Name: nota_credito; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE nota_credito (
    id_notacredito integer NOT NULL,
    id_proveedor integer,
    nc_fecha date,
    nc_ndocto bigint,
    nc_estado integer,
    nc_local integer,
    nc_tipo integer
);


ALTER TABLE nota_credito OWNER TO pguser;

--
-- Name: opcion_id_opcion_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE opcion_id_opcion_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 2147483647
    CACHE 1;


ALTER TABLE opcion_id_opcion_seq OWNER TO pguser;

--
-- Name: opcion; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE opcion (
    id_opcion integer DEFAULT nextval('opcion_id_opcion_seq'::regclass) NOT NULL,
    id_modulo integer,
    opc_nombre character varying(60),
    opc_subtitulo character varying(60),
    opc_path character varying(256),
    opc_submenu integer,
    opc_solo_methodo integer DEFAULT 0
);


ALTER TABLE opcion OWNER TO pguser;

--
-- Name: operador; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE operador (
    id_operador bigint NOT NULL,
    nombre character varying(50) DEFAULT 'nuevo'::character varying NOT NULL,
    id_perfil bigint DEFAULT 1 NOT NULL,
    clave character varying(12) DEFAULT 1234 NOT NULL,
    id_centroingreso bigint DEFAULT 1 NOT NULL,
    id_sector bigint DEFAULT 1,
    horaentrada date DEFAULT '2007-01-01'::date,
    horasalida date DEFAULT '2007-01-01'::date,
    login character varying(8) NOT NULL,
    id_salon bigint DEFAULT 1 NOT NULL,
    comision real DEFAULT 0 NOT NULL,
    activo smallint DEFAULT 1 NOT NULL,
    capturador smallint DEFAULT 0 NOT NULL,
    repartidor smallint DEFAULT 0 NOT NULL,
    id_local integer,
    usa_sincronizador integer DEFAULT 0
);


ALTER TABLE operador OWNER TO pguser;

--
-- Name: operador_transaccion; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE operador_transaccion (
    id_local integer NOT NULL,
    id_transaccion integer NOT NULL,
    id_operador integer,
    login character varying(30),
    id_tipo_registro integer,
    n_registro integer,
    fecha date,
    observacion character varying(255),
    hora time without time zone,
    id_mesa integer,
    id_producto integer,
    id_turno integer,
    id integer NOT NULL
);


ALTER TABLE operador_transaccion OWNER TO pguser;

--
-- Name: operador_transaccion_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE operador_transaccion_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE operador_transaccion_id_seq OWNER TO pguser;

--
-- Name: operador_transaccion_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE operador_transaccion_id_seq OWNED BY operador_transaccion.id;


--
-- Name: orden; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE orden (
    id_local integer NOT NULL,
    id_orden bigint NOT NULL,
    norden bigint,
    id_proveedor bigint,
    fecha_creacion date,
    estado character varying(1),
    fecha_modificacion date,
    id_operador integer,
    total_orden double precision,
    guia character varying(1),
    observacion character varying(100),
    id_guiadespacho bigint,
    ext_nombre character varying(40),
    ext_direccion character varying(30),
    ext_fono character varying(20),
    externa integer
);


ALTER TABLE orden OWNER TO pguser;

--
-- Name: orden_backup; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE orden_backup (
    id_local integer NOT NULL,
    id_orden bigint NOT NULL,
    norden bigint,
    id_proveedor bigint,
    fecha_creacion date,
    estado character varying(1),
    fecha_modificacion date,
    id_operador integer,
    total_orden bigint,
    guia character varying(1),
    observacion character varying(100),
    id_guiadespacho bigint
);


ALTER TABLE orden_backup OWNER TO pguser;

--
-- Name: TABLE orden_backup; Type: COMMENT; Schema: public; Owner: pguser
--

COMMENT ON TABLE orden_backup IS 'Tabla de encabezado de la orden de compras';


--
-- Name: sequence_orden_compra; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE sequence_orden_compra
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 999999999999999999
    CACHE 1;


ALTER TABLE sequence_orden_compra OWNER TO pguser;

--
-- Name: orden_compra; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE orden_compra (
    id_ordencompra integer DEFAULT nextval('sequence_orden_compra'::regclass) NOT NULL,
    id_proveedor integer,
    id_local integer,
    oc_ndocto integer,
    oc_fecha date,
    oc_obs text,
    oc_estado integer,
    oc_tipo integer,
    id_guiadespachocompra integer
);


ALTER TABLE orden_compra OWNER TO pguser;

--
-- Name: orders; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE orders (
    id integer NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    id_local integer NOT NULL
);


ALTER TABLE orders OWNER TO pguser;

--
-- Name: orders_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE orders_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE orders_id_seq OWNER TO pguser;

--
-- Name: orders_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE orders_id_seq OWNED BY orders.id;


--
-- Name: pedido_anul; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE pedido_anul (
    id_local integer NOT NULL,
    id_pedidolocal integer,
    id_mesa integer,
    id_operador integer,
    id_producto integer,
    preciounit numeric,
    cantidad numeric,
    hora time without time zone,
    id_centroingreso integer,
    nsilla integer,
    estado character varying(1),
    id_bodega integer,
    estado_anul integer,
    id_razon integer,
    tipo_accion character varying(10),
    claseproducto integer,
    fecha date,
    descripcion_razon character varying(100),
    id_pedidoanul integer NOT NULL
);


ALTER TABLE pedido_anul OWNER TO pguser;

--
-- Name: pedido_anul_id_pedidoanul_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE pedido_anul_id_pedidoanul_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE pedido_anul_id_pedidoanul_seq OWNER TO pguser;

--
-- Name: pedido_anul_id_pedidoanul_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE pedido_anul_id_pedidoanul_seq OWNED BY pedido_anul.id_pedidoanul;


--
-- Name: pedidoecommerce; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE pedidoecommerce
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 555555555555555555
    CACHE 1;


ALTER TABLE pedidoecommerce OWNER TO pguser;


--
-- Name: pedido_ecommerce; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE pedido_ecommerce (
    id_pedido integer DEFAULT nextval('pedidoecommerce'::regclass) NOT NULL,
    id_producto integer,
    cantidad integer,
    precio integer,
    estado character varying(1),
    id_padre integer,
    id_mesaecommerce integer NOT NULL,
    hora time without time zone
);


ALTER TABLE pedido_ecommerce OWNER TO pguser;


--
-- Name: perfil; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE perfil (
    id_perfil integer NOT NULL,
    per_nombre character varying(60),
    per_descripcion text,
    per_methodo integer DEFAULT 0,
    per_adm_local integer
);


ALTER TABLE perfil OWNER TO pguser;


--
-- Name: perfil_local; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE perfil_local (
    id_perfil_local integer NOT NULL,
    nombre character varying(20) NOT NULL,
    descripcion character varying(20)
);


ALTER TABLE perfil_local OWNER TO pguser;

--
-- Name: COLUMN perfil_local.nombre; Type: COMMENT; Schema: public; Owner: pguser
--

COMMENT ON COLUMN perfil_local.nombre IS 'nombre del perfil';


--
-- Name: COLUMN perfil_local.descripcion; Type: COMMENT; Schema: public; Owner: pguser
--

COMMENT ON COLUMN perfil_local.descripcion IS 'descripcion gral del perfil';


--
-- Name: periodo_atencion; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE periodo_atencion (
    id_periodoatencion integer NOT NULL,
    pa_nombre character varying(20),
    pa_hora_inicio time without time zone,
    pa_hora_fin time without time zone,
    pa_lun integer,
    pa_mar integer,
    pa_mie integer,
    pa_jue integer,
    pa_vie integer,
    pa_sab integer,
    pa_dom integer,
    id_local integer
);
ALTER TABLE ONLY periodo_atencion ALTER COLUMN id_periodoatencion SET STATISTICS 0;


ALTER TABLE periodo_atencion OWNER TO pguser;

--
-- Name: periodo_venta; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE periodo_venta (
    id_pv integer NOT NULL,
    pv_nombre character varying(20),
    pv_horainicio time without time zone,
    pv_horafin time without time zone
);


ALTER TABLE periodo_venta OWNER TO pguser;

--
-- Name: periodo_venta_local; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE periodo_venta_local (
    id_tipolocal integer NOT NULL,
    id_pv integer NOT NULL
);


ALTER TABLE periodo_venta_local OWNER TO pguser;


--
-- Name: permiso; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE permiso (
    id_perfil integer NOT NULL,
    id_opcion integer NOT NULL
);


ALTER TABLE permiso OWNER TO pguser;

--
-- Name: pga_diagrams; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE pga_diagrams (
    diagramname character varying(64) NOT NULL,
    diagramtables text,
    diagramlinks text
);


ALTER TABLE pga_diagrams OWNER TO pguser;

--
-- Name: pga_forms; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE pga_forms (
    formname character varying(64) NOT NULL,
    formsource text
);


ALTER TABLE pga_forms OWNER TO pguser;

--
-- Name: pga_graphs; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE pga_graphs (
    graphname character varying(64) NOT NULL,
    graphsource text,
    graphcode text
);


ALTER TABLE pga_graphs OWNER TO pguser;

--
-- Name: pga_images; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE pga_images (
    imagename character varying(64) NOT NULL,
    imagesource text
);


ALTER TABLE pga_images OWNER TO pguser;

--
-- Name: pga_layout; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE pga_layout (
    tablename character varying(64) NOT NULL,
    nrcols smallint,
    colnames text,
    colwidth text
);


ALTER TABLE pga_layout OWNER TO pguser;

--
-- Name: pga_queries; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE pga_queries (
    queryname character varying(64) NOT NULL,
    querytype character(1),
    querycommand text,
    querytables text,
    querylinks text,
    queryresults text,
    querycomments text
);


ALTER TABLE pga_queries OWNER TO pguser;

--
-- Name: pga_reports; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE pga_reports (
    reportname character varying(64) NOT NULL,
    reportsource text,
    reportbody text,
    reportprocs text,
    reportoptions text
);


ALTER TABLE pga_reports OWNER TO pguser;

--
-- Name: pga_scripts; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE pga_scripts (
    scriptname character varying(64) NOT NULL,
    scriptsource text
);


ALTER TABLE pga_scripts OWNER TO pguser;

--
-- Name: precio_tipo_local; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE precio_tipo_local (
    id_tipolocal integer NOT NULL,
    id_producto integer NOT NULL,
    ptl_precio1 integer,
    ptl_precio2 integer,
    ptl_precio3 integer,
    ptl_precio4 integer,
    ptl_smax integer,
    ptl_smin integer,
    ptl_fmodificacion date DEFAULT now() NOT NULL,
    porcentaje_descto integer DEFAULT 0,
    estado integer,
    activo_ecommerce integer DEFAULT 0
);
ALTER TABLE ONLY precio_tipo_local ALTER COLUMN activo_ecommerce SET STATISTICS 0;


ALTER TABLE precio_tipo_local OWNER TO pguser;


--
-- Name: precios_tmp; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE precios_tmp (
    id_tipolocal integer,
    id_producto integer,
    precio1 numeric,
    precio2 numeric,
    precio3 numeric,
    fecha date
);


ALTER TABLE precios_tmp OWNER TO pguser;


--
-- Name: producto; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE producto (
    id_producto integer NOT NULL,
    id_familia integer,
    id_receta integer,
    id_familiareq integer,
    pro_nombre character varying(60),
    pro_fmodificacion date,
    id_claseproducto smallint,
    costo bigint DEFAULT 0,
    activo_cadena integer DEFAULT 1,
    maxfamreq integer DEFAULT 0,
    cod_barra character varying(100),
    ecommerce_pro smallint DEFAULT 0,
    edestacado smallint DEFAULT 0,
    detallepro character varying(300),
    urlecommerce character varying(150),
    prioridad_pro integer DEFAULT 1,
    despacho_ecommerce integer DEFAULT 0
);


ALTER TABLE producto OWNER TO pguser;

--
-- Name: COLUMN producto.activo_cadena; Type: COMMENT; Schema: public; Owner: pguser
--

COMMENT ON COLUMN producto.activo_cadena IS 'determina si el producto est activo para la cadena; 1: activo; 0:desactivo';


--
-- Name: producto_local; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE producto_local (
    id_producto bigint NOT NULL,
    id_tipolocal integer NOT NULL
);


ALTER TABLE producto_local OWNER TO pguser;

--
-- Name: TABLE producto_local; Type: COMMENT; Schema: public; Owner: pguser
--

COMMENT ON TABLE producto_local IS 'Tabla de Normalizacion de productos por local';



--
-- Name: productos; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE productos (
    id_prod integer NOT NULL,
    nomb_prod character varying(100),
    tipo_prod character varying(50),
    precio_unit real,
    precio_dist real,
    fecha_reg date
);


ALTER TABLE productos OWNER TO pguser;


--
-- Name: products; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE products (
    id integer NOT NULL,
    created_at timestamp(0) without time zone,
    updated_at timestamp(0) without time zone,
    name character varying(255) NOT NULL,
    description character varying(255) NOT NULL,
    price integer NOT NULL
);


ALTER TABLE products OWNER TO pguser;

--
-- Name: products_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE products_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE products_id_seq OWNER TO pguser;

--
-- Name: products_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE products_id_seq OWNED BY products.id;



--
-- Name: programa_cambio_precio; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE programa_cambio_precio (
    id integer NOT NULL,
    estado integer NOT NULL,
    fk_local integer NOT NULL,
    fk_usuario integer NOT NULL,
    hora time(0) without time zone NOT NULL,
    fecha date NOT NULL,
    fecha_bajada date,
    hora_bajada time(0) without time zone
);


ALTER TABLE programa_cambio_precio OWNER TO pguser;

--
-- Name: programa_cambio_precio_detalle; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE programa_cambio_precio_detalle (
    id integer NOT NULL,
    fk_cabecera integer NOT NULL,
    id_producto integer NOT NULL,
    precio1 integer NOT NULL,
    precio2 integer NOT NULL,
    precio3 integer NOT NULL,
    antiguo_precio1 integer NOT NULL,
    antiguo_precio2 integer NOT NULL,
    antiguo_precio3 integer NOT NULL
);


ALTER TABLE programa_cambio_precio_detalle OWNER TO pguser;

--
-- Name: programa_cambio_precio_detalle_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE programa_cambio_precio_detalle_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE programa_cambio_precio_detalle_id_seq OWNER TO pguser;

--
-- Name: programa_cambio_precio_detalle_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE programa_cambio_precio_detalle_id_seq OWNED BY programa_cambio_precio_detalle.id;


--
-- Name: programa_cambio_precio_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE programa_cambio_precio_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE programa_cambio_precio_id_seq OWNER TO pguser;

--
-- Name: programa_cambio_precio_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE programa_cambio_precio_id_seq OWNED BY programa_cambio_precio.id;


--
-- Name: programa_menu_especial; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE programa_menu_especial (
    id integer NOT NULL,
    fk_menu_especial integer NOT NULL,
    fk_usuario integer NOT NULL,
    fk_local integer NOT NULL,
    hora time(0) without time zone NOT NULL,
    fecha date NOT NULL,
    hora_bajada time(0) without time zone,
    fecha_bajada date,
    estado integer DEFAULT 0,
    menu_nombre character varying(12) NOT NULL,
    menu_descripcion character varying(50) NOT NULL,
    menu_maximo_descto integer NOT NULL,
    menu_valor_menu integer NOT NULL,
    menu_activo integer NOT NULL,
    menu_id_clase_producto integer NOT NULL,
    menu_id_grupo_mayor integer NOT NULL
);


ALTER TABLE programa_menu_especial OWNER TO pguser;

--
-- Name: programa_menu_especial_detalle; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE programa_menu_especial_detalle (
    id integer NOT NULL,
    fk_cabecera integer NOT NULL,
    menu_detalle_fk_producto integer NOT NULL,
    menu_detalle_cantidad integer NOT NULL
);


ALTER TABLE programa_menu_especial_detalle OWNER TO pguser;

--
-- Name: programa_menu_especial_detalle_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE programa_menu_especial_detalle_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE programa_menu_especial_detalle_id_seq OWNER TO pguser;

--
-- Name: programa_menu_especial_detalle_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE programa_menu_especial_detalle_id_seq OWNED BY programa_menu_especial_detalle.id;


--
-- Name: programa_menu_especial_id_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE programa_menu_especial_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE programa_menu_especial_id_seq OWNER TO pguser;

--
-- Name: programa_menu_especial_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE programa_menu_especial_id_seq OWNED BY programa_menu_especial.id;



--
-- Name: proveedor; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE proveedor (
    id_proveedor integer NOT NULL,
    pro_nombre character varying(60),
    pro_rut numeric(8,0),
    pro_dv character(1),
    pro_direccion character varying(60),
    pro_comuna character varying(20),
    pro_ciudad character varying(20),
    pro_giro character varying(30),
    pro_telefono1 character varying(15),
    pro_telefono2 character varying(15),
    pro_fcreacion date,
    pro_fmodificacion date,
    pro_tipo character varying(15),
    id_local integer
);


ALTER TABLE proveedor OWNER TO pguser;

--
-- Name: rebaje; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE rebaje (
    id_local integer NOT NULL,
    id_articulo integer NOT NULL,
    cantidad real NOT NULL,
    fecha date NOT NULL,
    tipo_rebaje integer,
    id_borigen integer DEFAULT 0,
    id_bdestino integer DEFAULT 0,
    descripcion character varying(150),
    id_unidad integer,
    id_rebaje integer NOT NULL
);


ALTER TABLE rebaje OWNER TO pguser;

--
-- Name: rebaje_id_rebaje_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE rebaje_id_rebaje_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE rebaje_id_rebaje_seq OWNER TO pguser;

--
-- Name: rebaje_id_rebaje_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE rebaje_id_rebaje_seq OWNED BY rebaje.id_rebaje;


--
-- Name: receta; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE receta (
    id_receta integer NOT NULL,
    rec_nombre character varying(25),
    rec_descripcion character varying(40),
    rec_fcreacion date,
    rec_fmodificacion date,
    rec_precio numeric(12,2),
    rec_nporcion numeric(12,2),
    rec_costoporcion numeric(12,2),
    rec_variacion_costo numeric(12,2),
    rec_costo_inicial numeric(12,2)
);


ALTER TABLE receta OWNER TO pguser;

--
-- Name: receta_ingrediente; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE receta_ingrediente (
    id_unidad integer NOT NULL,
    id_subreceta integer,
    id_receta integer NOT NULL,
    id_articulo integer,
    rin_cantidad numeric(12,2),
    rin_costo numeric(12,2)
);


ALTER TABLE receta_ingrediente OWNER TO pguser;


--
-- Name: receta_tipo_local; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE receta_tipo_local (
    id_tipolocal integer NOT NULL,
    id_receta integer NOT NULL,
    estado integer
);


ALTER TABLE receta_tipo_local OWNER TO pguser;


--
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE schema_migrations (
    version character varying NOT NULL
);


ALTER TABLE schema_migrations OWNER TO pguser;

--
-- Name: sec_usuario_ecommerce; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE sec_usuario_ecommerce
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 99999999999999
    CACHE 1;


ALTER TABLE sec_usuario_ecommerce OWNER TO pguser;

--
-- Name: sec_usuario_token; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE sec_usuario_token
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 99999999999
    CACHE 1
    CYCLE;


ALTER TABLE sec_usuario_token OWNER TO pguser;

--
-- Name: secuencia_arqueo; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE secuencia_arqueo
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 9000000000
    CACHE 1;


ALTER TABLE secuencia_arqueo OWNER TO pguser;

--
-- Name: secuencia_pedido_anul; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE secuencia_pedido_anul
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 999999999999
    CACHE 1;


ALTER TABLE secuencia_pedido_anul OWNER TO pguser;

--
-- Name: secuencia_ventahist; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE secuencia_ventahist
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE secuencia_ventahist OWNER TO pguser;

--
-- Name: sel_recetas; Type: VIEW; Schema: public; Owner: pguser
--

CREATE VIEW sel_recetas AS
 SELECT receta.id_receta,
    receta.rec_nombre,
    receta.rec_descripcion,
    receta.rec_fcreacion,
    receta.rec_fmodificacion,
    receta.rec_precio,
    receta.rec_nporcion,
    receta.rec_costoporcion,
    receta.rec_variacion_costo,
    receta.rec_costo_inicial
   FROM receta;


ALTER TABLE sel_recetas OWNER TO pguser;

--
-- Name: seqboleta; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE seqboleta
    START WITH 0
    INCREMENT BY 1
    MINVALUE 0
    NO MAXVALUE
    CACHE 10;


ALTER TABLE seqboleta OWNER TO pguser;

--
-- Name: seqmesa; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE seqmesa
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE seqmesa OWNER TO pguser;

--
-- Name: stock_bodega; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE stock_bodega (
    id_bodega integer NOT NULL,
    id_articulo integer NOT NULL,
    cantidad numeric(11,2),
    nombre character varying(40),
    id_subreceta integer,
    stockini numeric(11,2),
    unid character varying(15)
);


ALTER TABLE stock_bodega OWNER TO pguser;

--
-- Name: stock_bodega_new; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE stock_bodega_new (
    id_stockbodega integer NOT NULL,
    id_local integer NOT NULL,
    id_bodega integer NOT NULL,
    id_articulo integer NOT NULL,
    cantidad numeric(11,2),
    nombre character varying(40),
    id_subreceta integer,
    stockini numeric(11,2),
    fecha date NOT NULL,
    unid character varying(15)
);


ALTER TABLE stock_bodega_new OWNER TO pguser;

--
-- Name: stock_bodega_new_id_stockbodega_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE stock_bodega_new_id_stockbodega_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE stock_bodega_new_id_stockbodega_seq OWNER TO pguser;

--
-- Name: stock_bodega_new_id_stockbodega_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE stock_bodega_new_id_stockbodega_seq OWNED BY stock_bodega_new.id_stockbodega;



--
-- Name: stock_locales; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE stock_locales (
    id_local integer,
    id_bodega integer,
    id_articulo integer,
    nombre_bodega character varying(20),
    nombre_articulo character varying(30),
    cantidad numeric(12,2),
    costo numeric(12,2)
);


ALTER TABLE stock_locales OWNER TO pguser;


--
-- Name: subgrupo_mayor; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE subgrupo_mayor (
    id_subgrupomayor integer NOT NULL,
    id_grupomayor integer,
    sub_nombre character varying(60),
    sub_descripcion character varying(100)
);


ALTER TABLE subgrupo_mayor OWNER TO pguser;

--
-- Name: subreceta; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE subreceta (
    id_subreceta integer NOT NULL,
    sre_nombre character varying(25),
    sre_descripcion character varying(40),
    sre_fcreacion date,
    sre_fmodificacion date,
    sre_nporcion integer,
    sre_costoporcion numeric(12,2) NOT NULL,
    sre_unidad_produccion integer
);


ALTER TABLE subreceta OWNER TO pguser;

--
-- Name: subreceta_ingrediente; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE subreceta_ingrediente (
    id_articulo integer,
    id_unidad integer,
    id_subreceta integer,
    sri_cantidad double precision,
    sri_costo numeric(12,2)
);


ALTER TABLE subreceta_ingrediente OWNER TO pguser;


--
-- Name: subreceta_tipo_local; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE subreceta_tipo_local (
    id_tipolocal integer NOT NULL,
    id_subreceta integer NOT NULL,
    estado integer
);


ALTER TABLE subreceta_tipo_local OWNER TO pguser;


--
-- Name: test; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE test (
    id_producto integer
);


ALTER TABLE test OWNER TO pguser;

--
-- Name: tipo_convenio; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE tipo_convenio (
    id_tipo_convenio integer NOT NULL,
    nombre character varying(30) DEFAULT NULL::character varying,
    descripcion character varying(100) DEFAULT NULL::character varying
);


ALTER TABLE tipo_convenio OWNER TO pguser;

--
-- Name: tipo_convenio_id_tipo_convenio_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE tipo_convenio_id_tipo_convenio_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE tipo_convenio_id_tipo_convenio_seq OWNER TO pguser;

--
-- Name: tipo_convenio_id_tipo_convenio_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pguser
--

ALTER SEQUENCE tipo_convenio_id_tipo_convenio_seq OWNED BY tipo_convenio.id_tipo_convenio;


--
-- Name: tipo_docto; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE tipo_docto (
    id_tipodocto smallint NOT NULL,
    documento character varying(40)
);


ALTER TABLE tipo_docto OWNER TO pguser;

--
-- Name: tipo_local; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE tipo_local (
    id_tipolocal integer NOT NULL,
    tlo_nombre character varying(60),
    tlo_descripcion text
);


ALTER TABLE tipo_local OWNER TO pguser;

--
-- Name: tipo_pago; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE tipo_pago (
    id_tipo_pago integer NOT NULL,
    tip_nombre character varying(60),
    tip_descripcion text,
    tip_valor integer,
    tip_prioridad integer,
    tip_factor integer,
    tip_propina integer
);


ALTER TABLE tipo_pago OWNER TO pguser;

--
-- Name: tipopagoe; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE tipopagoe
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 5000000
    CACHE 1;


ALTER TABLE tipopagoe OWNER TO pguser;


--
-- Name: tipo_pago_ecommerce; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE tipo_pago_ecommerce (
    id_tipo_pagoe integer DEFAULT nextval('tipopagoe'::regclass) NOT NULL,
    descripcion character varying,
    id_pago integer
);


ALTER TABLE tipo_pago_ecommerce OWNER TO pguser;

--
-- Name: tipo_reg_log; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE tipo_reg_log (
    id_tipo_reg integer DEFAULT nextval('id_tipo_log'::regclass) NOT NULL,
    nombre text
);


ALTER TABLE tipo_reg_log OWNER TO pguser;

--
-- Name: tipo_registro; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE tipo_registro (
    id_tipo_registro integer NOT NULL,
    nombre character varying(60) DEFAULT 0
);


ALTER TABLE tipo_registro OWNER TO pguser;

--
-- Name: tipoenvio; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE tipoenvio
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 500000
    CACHE 1;


ALTER TABLE tipoenvio OWNER TO pguser;

--
-- Name: tipo_venta_ecommerce; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE tipo_venta_ecommerce (
    id_tipo_venta integer DEFAULT nextval('tipoenvio'::regclass) NOT NULL,
    descripcion character varying,
    tipo_venta integer DEFAULT 0
);


ALTER TABLE tipo_venta_ecommerce OWNER TO pguser;


--
-- Name: token; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE token (
    id_token integer DEFAULT nextval(('"public"."id_token"'::text)::regclass) NOT NULL,
    id_usuarioecommerce integer,
    user_token character varying(200)
);


ALTER TABLE token OWNER TO pguser;

--
-- Name: transaccion; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE transaccion (
    id_operador smallint,
    observacion character varying(200),
    fecha date,
    hora time without time zone,
    id_local smallint,
    id_transaccion integer,
    id_tipo_registro integer,
    n_registro integer,
    id_mesa integer,
    id_producto integer
);


ALTER TABLE transaccion OWNER TO pguser;

--
-- Name: transportista; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE transportista (
    id_transportista integer NOT NULL,
    tra_nombre character varying(60),
    tra_descripcion text
);


ALTER TABLE transportista OWNER TO pguser;


--
-- Name: turno_cortado; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE turno_cortado (
    inicio time(6) without time zone,
    fin time without time zone
);


ALTER TABLE turno_cortado OWNER TO pguser;


--
-- Name: unidad; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE unidad (
    id_unidad integer NOT NULL,
    uni_nombre character varying(60),
    uni_abreviacion character varying(20)
);


ALTER TABLE unidad OWNER TO pguser;

--
-- Name: usuario; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE usuario (
    id_usuario integer DEFAULT nextval(('"public"."usuario_id_usuario_seq"'::text)::regclass) NOT NULL,
    id_perfil integer,
    usu_nombre character varying(60),
    usu_login character varying(20),
    usu_password character varying(32),
    usu_comision numeric(3,2),
    usu_log timestamp(0) without time zone,
    foto bytea,
    usu_activo integer
);


ALTER TABLE usuario OWNER TO pguser;

--
-- Name: usuario_ecommerce; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE usuario_ecommerce (
    id_usuarioecommerce integer NOT NULL,
    nombre character varying(40),
    email character varying(100),
    password character varying(10),
    telefono character varying(20),
    facebook_id character varying(50),
    google_id character varying(50),
    registrado integer,
    estado integer,
    calle character varying(100) DEFAULT NULL::character varying,
    numero character varying(15) DEFAULT NULL::character varying,
    depto character varying(15) DEFAULT NULL::character varying,
    block character varying(15) DEFAULT NULL::character varying,
    comuna character varying(50) DEFAULT NULL::character varying,
    ciudad character varying(50) DEFAULT NULL::character varying,
    user_token character varying(100) DEFAULT NULL::character varying
);


ALTER TABLE usuario_ecommerce OWNER TO pguser;

--
-- Name: usuario_id_usuario_seq; Type: SEQUENCE; Schema: public; Owner: pguser
--

CREATE SEQUENCE usuario_id_usuario_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    MAXVALUE 2147483647
    CACHE 1;


ALTER TABLE usuario_id_usuario_seq OWNER TO pguser;


--
-- Name: venta_diaria_ecommerce; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE venta_diaria_ecommerce (
    id_ventadiaria integer DEFAULT nextval('id_ventadia'::regclass) NOT NULL,
    id_producto integer,
    dia_venta integer
);


ALTER TABLE venta_diaria_ecommerce OWNER TO pguser;


--
-- Name: ventahist; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE ventahist (
    id_local integer NOT NULL,
    id_ventahist bigint NOT NULL,
    id_mesa bigint,
    id_producto bigint,
    desc_prod character varying(50),
    preciounit double precision,
    cantidad double precision,
    hora time without time zone,
    fecha date,
    id_periodo smallint,
    id_familia integer,
    centroingreso integer,
    id_turno integer,
    id_operador integer,
    pago_prepago integer DEFAULT 0 NOT NULL,
    desctoxprod numeric(12,2) DEFAULT 0,
    productohijo integer,
    id_productopadre integer,
    descripcion character varying(300),
    url_producto character varying(200)
);


ALTER TABLE ventahist OWNER TO pguser;

--
-- Name: TABLE ventahist; Type: COMMENT; Schema: public; Owner: pguser
--

COMMENT ON TABLE ventahist IS 'Movimientos de venta de productos unificados para no perder consistencia.';


--
-- Name: COLUMN ventahist.pago_prepago; Type: COMMENT; Schema: public; Owner: pguser
--

COMMENT ON COLUMN ventahist.pago_prepago IS 'Puede tener slo dos valores "0" o "1".
0:Indica que se pago fue normal
1:indica que el pago fue mediante una tarjeta de prepago';



--
-- Name: ventas; Type: TABLE; Schema: public; Owner: pguser
--

CREATE TABLE ventas (
    id_venta integer NOT NULL,
    fecha_venta date,
    monto_venta integer
);


ALTER TABLE ventas OWNER TO pguser;

--
-- Name: id; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY arqueo_caja ALTER COLUMN id SET DEFAULT nextval('arqueo_caja_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY clientes ALTER COLUMN id SET DEFAULT nextval('clientes_id_seq'::regclass);


--
-- Name: id_convenio; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY convenio ALTER COLUMN id_convenio SET DEFAULT nextval('convenio_id_convenio_seq'::regclass);


--
-- Name: id_credito; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY credito_cliente ALTER COLUMN id_credito SET DEFAULT nextval('credito_cliente_id_credito_seq'::regclass);


--
-- Name: id_tipo_convenio; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY detalle_tipo_convenio ALTER COLUMN id_tipo_convenio SET DEFAULT nextval('detalle_tipo_convenio_id_tipo_convenio_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY docto_anul ALTER COLUMN id SET DEFAULT nextval('docto_anul_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY docto_cliente ALTER COLUMN id SET DEFAULT nextval('docto_cliente_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY fpago_mesa ALTER COLUMN id SET DEFAULT nextval('fpago_mesa_id_seq'::regclass);


--
-- Name: id_menu_especial; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY menu_especial ALTER COLUMN id_menu_especial SET DEFAULT nextval('menu_especial_id_menu_especial_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY migrations ALTER COLUMN id SET DEFAULT nextval('migrations_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY monitor_cocinas ALTER COLUMN id SET DEFAULT nextval('monitor_cocinas_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY operador_transaccion ALTER COLUMN id SET DEFAULT nextval('operador_transaccion_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY orders ALTER COLUMN id SET DEFAULT nextval('orders_id_seq'::regclass);


--
-- Name: id_pedidoanul; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY pedido_anul ALTER COLUMN id_pedidoanul SET DEFAULT nextval('pedido_anul_id_pedidoanul_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY products ALTER COLUMN id SET DEFAULT nextval('products_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY programa_cambio_precio ALTER COLUMN id SET DEFAULT nextval('programa_cambio_precio_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY programa_cambio_precio_detalle ALTER COLUMN id SET DEFAULT nextval('programa_cambio_precio_detalle_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY programa_menu_especial ALTER COLUMN id SET DEFAULT nextval('programa_menu_especial_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY programa_menu_especial_detalle ALTER COLUMN id SET DEFAULT nextval('programa_menu_especial_detalle_id_seq'::regclass);


--
-- Name: id_rebaje; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY rebaje ALTER COLUMN id_rebaje SET DEFAULT nextval('rebaje_id_rebaje_seq'::regclass);


--
-- Name: id_stockbodega; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY stock_bodega_new ALTER COLUMN id_stockbodega SET DEFAULT nextval('stock_bodega_new_id_stockbodega_seq'::regclass);


--
-- Name: id_tipo_convenio; Type: DEFAULT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY tipo_convenio ALTER COLUMN id_tipo_convenio SET DEFAULT nextval('tipo_convenio_id_tipo_convenio_seq'::regclass);


--
-- Name: ar_internal_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY ar_internal_metadata
    ADD CONSTRAINT ar_internal_metadata_pkey PRIMARY KEY (key);


--
-- Name: cliente_ecommerce_pkey; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY cliente_ecommerce
    ADD CONSTRAINT cliente_ecommerce_pkey PRIMARY KEY (id_cadena);


--
-- Name: docto_anul_pkey; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY docto_anul
    ADD CONSTRAINT docto_anul_pkey PRIMARY KEY (id);


--
-- Name: docto_cliente_pkey; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY docto_cliente
    ADD CONSTRAINT docto_cliente_pkey PRIMARY KEY (id);


--
-- Name: fpago_mesa_pkey; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY fpago_mesa
    ADD CONSTRAINT fpago_mesa_pkey PRIMARY KEY (id);


--
-- Name: index1; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY horario_atencion
    ADD CONSTRAINT index1 PRIMARY KEY (id_horario);


--
-- Name: mesahist_pkey; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY mesahist
    ADD CONSTRAINT mesahist_pkey PRIMARY KEY (id_local, id_mesa);


--
-- Name: monitor_cocinas_pkey; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY monitor_cocinas
    ADD CONSTRAINT monitor_cocinas_pkey PRIMARY KEY (id);


--
-- Name: operador_transaccion_pkey; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY operador_transaccion
    ADD CONSTRAINT operador_transaccion_pkey PRIMARY KEY (id);


--
-- Name: pedido_anul_pkey; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY pedido_anul
    ADD CONSTRAINT pedido_anul_pkey PRIMARY KEY (id_pedidoanul);


--
-- Name: pk_arqueo; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY arqueo_caja
    ADD CONSTRAINT pk_arqueo PRIMARY KEY (id, id_local);


--
-- Name: pk_articulo; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY articulo
    ADD CONSTRAINT pk_articulo PRIMARY KEY (id_articulo);


--
-- Name: pk_boletas_id_local; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY boletas
    ADD CONSTRAINT pk_boletas_id_local PRIMARY KEY (id_local, id);


--
-- Name: pk_clientes; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY clientes
    ADD CONSTRAINT pk_clientes PRIMARY KEY (id_cliente, id_local);


--
-- Name: pk_familia; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY familia
    ADD CONSTRAINT pk_familia PRIMARY KEY (id_familia);


--
-- Name: pk_grupo_mayor; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY grupo_mayor
    ADD CONSTRAINT pk_grupo_mayor PRIMARY KEY (id_grupomayor);


--
-- Name: pk_local; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY local
    ADD CONSTRAINT pk_local PRIMARY KEY (id_local);


--
-- Name: pk_mayor_articulo; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY mayor_articulo
    ADD CONSTRAINT pk_mayor_articulo PRIMARY KEY (id_mayorarticulo);


--
-- Name: pk_preciopk_precio; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY precio_tipo_local
    ADD CONSTRAINT pk_preciopk_precio PRIMARY KEY (id_tipolocal, id_producto, ptl_fmodificacion);


--
-- Name: pk_proveedor; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY proveedor
    ADD CONSTRAINT pk_proveedor PRIMARY KEY (id_proveedor);


--
-- Name: pk_receta; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY receta
    ADD CONSTRAINT pk_receta PRIMARY KEY (id_receta);


--
-- Name: pk_subgrupo_articulo; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY subgrupo_mayor
    ADD CONSTRAINT pk_subgrupo_articulo PRIMARY KEY (id_subgrupomayor);


--
-- Name: pk_unidad; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY unidad
    ADD CONSTRAINT pk_unidad PRIMARY KEY (id_unidad);


--
-- Name: pk_ventahist; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY ventahist
    ADD CONSTRAINT pk_ventahist PRIMARY KEY (id_local, id_ventahist);


--
-- Name: producto_new_pk_producto; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY producto
    ADD CONSTRAINT producto_new_pk_producto PRIMARY KEY (id_producto);


--
-- Name: programa_cambio_precio_pkey; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY programa_cambio_precio
    ADD CONSTRAINT programa_cambio_precio_pkey PRIMARY KEY (id);


--
-- Name: receta_tipo_local_pkey; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY receta_tipo_local
    ADD CONSTRAINT receta_tipo_local_pkey PRIMARY KEY (id_tipolocal, id_receta);


--
-- Name: schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY schema_migrations
    ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);


--
-- Name: stock_bodega_new_pkey; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY stock_bodega_new
    ADD CONSTRAINT stock_bodega_new_pkey PRIMARY KEY (id_local, id_stockbodega);


--
-- Name: usuario_ecommerce_pkey; Type: CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY usuario_ecommerce
    ADD CONSTRAINT usuario_ecommerce_pkey PRIMARY KEY (id_usuarioecommerce);


--
-- Name: _local__pk; Type: INDEX; Schema: public; Owner: pguser
--

CREATE UNIQUE INDEX _local__pk ON public.local USING btree (id_local);


--
-- Name: arqueo_datos; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX arqueo_datos ON public.arqueo_caja USING btree (id_local, id_turno, id_operador, id_tipopago, id);


--
-- Name: docto_anul_numero; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX docto_anul_numero ON public.docto_anul USING btree (id_local, id_tipodocto, numero);


--
-- Name: familia_pk; Type: INDEX; Schema: public; Owner: pguser
--

CREATE UNIQUE INDEX familia_pk ON public.familia USING btree (id_familia);


--
-- Name: fecha; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX fecha ON public.ventahist USING btree (fecha);


--
-- Name: grupo_mayor_pk; Type: INDEX; Schema: public; Owner: pguser
--

CREATE UNIQUE INDEX grupo_mayor_pk ON public.grupo_mayor USING btree (id_grupomayor);


--
-- Name: id_familia; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX id_familia ON public.ventahist USING btree (id_familia);


--
-- Name: idenx_local; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idenx_local ON public.ventahist USING btree (id_local);


--
-- Name: idx_articulo; Type: INDEX; Schema: public; Owner: pguser
--

CREATE UNIQUE INDEX idx_articulo ON public.articulo USING btree (id_articulo);


--
-- Name: idx_dfecha; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idx_dfecha ON public.boletas USING btree (dfecha);


--
-- Name: idx_dfecha_bol; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idx_dfecha_bol ON public.boletas USING btree (dfecha);


--
-- Name: idx_dfecha_boleini_bolefin; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idx_dfecha_boleini_bolefin ON public.boletas USING btree (dfecha, nboleini, nbolefin);


--
-- Name: idx_fecha_ac; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idx_fecha_ac ON public.arqueo_caja USING btree (fecha);


--
-- Name: idx_fecha_fm; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idx_fecha_fm ON public.fpago_mesa USING btree (fecha);


--
-- Name: idx_fecha_mh; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idx_fecha_mh ON public.mesahist USING btree (fecha);


--
-- Name: idx_id_receta; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idx_id_receta ON public.receta_ingrediente USING btree (id_receta);


--
-- Name: idx_id_tipopago; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idx_id_tipopago ON public.fpago_mesa USING btree (id_tipopago);


--
-- Name: idx_id_tipopago_ac; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idx_id_tipopago_ac ON public.arqueo_caja USING btree (id_tipopago);


--
-- Name: idx_local_bol; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idx_local_bol ON public.boletas USING btree (id_local);


--
-- Name: idx_local_fm; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idx_local_fm ON public.fpago_mesa USING btree (id_local);


--
-- Name: idx_mesa; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idx_mesa ON public.fpago_mesa USING btree (id_mesa);


--
-- Name: idx_nbolefin; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idx_nbolefin ON public.boletas USING btree (nbolefin);


--
-- Name: idx_nboleini; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX idx_nboleini ON public.boletas USING btree (nboleini);


--
-- Name: index_familia; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX index_familia ON public.ventahist USING btree (id_familia);


--
-- Name: index_local; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX index_local ON public.mesahist USING btree (id_local);

ALTER TABLE mesahist CLUSTER ON index_local;


--
-- Name: index_mesa; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX index_mesa ON public.mesahist USING btree (id_mesa);


--
-- Name: index_opelocal; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX index_opelocal ON public.mesahist USING btree (id_local, operador);


--
-- Name: index_opelocal_ventahist; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX index_opelocal_ventahist ON public.ventahist USING btree (id_local, id_operador);


--
-- Name: index_prod_ventahist; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX index_prod_ventahist ON public.ventahist USING btree (id_producto);


--
-- Name: mayor_articulo_pk; Type: INDEX; Schema: public; Owner: pguser
--

CREATE UNIQUE INDEX mayor_articulo_pk ON public.mayor_articulo USING btree (id_mayorarticulo);


--
-- Name: mesahist_fecha; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX mesahist_fecha ON public.mesahist USING btree (fecha);


--
-- Name: mesahist_loc_fecha; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX mesahist_loc_fecha ON public.mesahist USING btree (id_local, fecha);


--
-- Name: operador_transaccion_id_local_i; Type: INDEX; Schema: public; Owner: pguser
--

CREATE UNIQUE INDEX operador_transaccion_id_local_i ON public.operador_transaccion USING btree (id_local, id_transaccion);


--
-- Name: producto_new_idx_producto; Type: INDEX; Schema: public; Owner: pguser
--

CREATE UNIQUE INDEX producto_new_idx_producto ON public.producto USING btree (id_producto);


--
-- Name: proveedor_pk; Type: INDEX; Schema: public; Owner: pguser
--

CREATE UNIQUE INDEX proveedor_pk ON public.proveedor USING btree (id_proveedor);


--
-- Name: receta_pk; Type: INDEX; Schema: public; Owner: pguser
--

CREATE UNIQUE INDEX receta_pk ON public.receta USING btree (id_receta);


--
-- Name: relationship_10_fk; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX relationship_10_fk ON public.local USING btree (id_tipolocal);


--
-- Name: relationship_38_fk; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX relationship_38_fk ON public.precio_tipo_local USING btree (id_tipolocal);


--
-- Name: relationship_39_fk; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX relationship_39_fk ON public.precio_tipo_local USING btree (id_producto);


--
-- Name: relationship_62_fk; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX relationship_62_fk ON public.mayor_articulo USING btree (id_subgrupomayor);


--
-- Name: unidad_pk; Type: INDEX; Schema: public; Owner: pguser
--

CREATE UNIQUE INDEX unidad_pk ON public.unidad USING btree (id_unidad);


--
-- Name: ventahist_localfamilia; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX ventahist_localfamilia ON public.ventahist USING btree (id_local, id_familia);


--
-- Name: ventahist_opefamilia; Type: INDEX; Schema: public; Owner: pguser
--

CREATE INDEX ventahist_opefamilia ON public.ventahist USING btree (id_familia, id_operador);


--
-- Name: fk_articulo_relaionsh_unidad; Type: FK CONSTRAINT; Schema: public; Owner: pguser
--

ALTER TABLE ONLY articulo
    ADD CONSTRAINT fk_articulo_relaionsh_unidad FOREIGN KEY (id_unidadinventario) REFERENCES unidad(id_unidad) ON UPDATE RESTRICT ON DELETE RESTRICT;


--
-- Name: public; Type: ACL; Schema: -; Owner: pguser
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM pguser;
GRANT ALL ON SCHEMA public TO pguser;
GRANT ALL ON SCHEMA public TO PUBLIC;


--
-- Name: arqueo_caja; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE arqueo_caja FROM PUBLIC;
REVOKE ALL ON TABLE arqueo_caja FROM pguser;
GRANT ALL ON TABLE arqueo_caja TO pguser;


--
-- Name: articulo; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE articulo FROM PUBLIC;
REVOKE ALL ON TABLE articulo FROM pguser;
GRANT ALL ON TABLE articulo TO pguser;


--
-- Name: boletas; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE boletas FROM PUBLIC;
REVOKE ALL ON TABLE boletas FROM pguser;
GRANT ALL ON TABLE boletas TO pguser;


--
-- Name: docto_anul; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE docto_anul FROM PUBLIC;
REVOKE ALL ON TABLE docto_anul FROM pguser;
GRANT ALL ON TABLE docto_anul TO pguser;


--
-- Name: familia; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE familia FROM PUBLIC;
REVOKE ALL ON TABLE familia FROM pguser;
GRANT ALL ON TABLE familia TO pguser;


--
-- Name: fpago_mesa; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE fpago_mesa FROM PUBLIC;
REVOKE ALL ON TABLE fpago_mesa FROM pguser;
GRANT ALL ON TABLE fpago_mesa TO pguser;


--
-- Name: grupo_mayor; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE grupo_mayor FROM PUBLIC;
REVOKE ALL ON TABLE grupo_mayor FROM pguser;
GRANT ALL ON TABLE grupo_mayor TO pguser;


--
-- Name: horario_atencion; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE horario_atencion FROM PUBLIC;
REVOKE ALL ON TABLE horario_atencion FROM pguser;
GRANT ALL ON TABLE horario_atencion TO pguser;
GRANT SELECT ON TABLE horario_atencion TO PUBLIC;


--
-- Name: local; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE local FROM PUBLIC;
REVOKE ALL ON TABLE local FROM pguser;
GRANT ALL ON TABLE local TO pguser;


--
-- Name: mayor_articulo; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE mayor_articulo FROM PUBLIC;
REVOKE ALL ON TABLE mayor_articulo FROM pguser;
GRANT ALL ON TABLE mayor_articulo TO pguser;


--
-- Name: mesahist; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE mesahist FROM PUBLIC;
REVOKE ALL ON TABLE mesahist FROM pguser;
GRANT ALL ON TABLE mesahist TO pguser;


--
-- Name: operador_transaccion; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE operador_transaccion FROM PUBLIC;
REVOKE ALL ON TABLE operador_transaccion FROM pguser;
GRANT ALL ON TABLE operador_transaccion TO pguser;


--
-- Name: precio_tipo_local; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE precio_tipo_local FROM PUBLIC;
REVOKE ALL ON TABLE precio_tipo_local FROM pguser;
GRANT ALL ON TABLE precio_tipo_local TO pguser;


--
-- Name: proveedor; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE proveedor FROM PUBLIC;
REVOKE ALL ON TABLE proveedor FROM pguser;
GRANT ALL ON TABLE proveedor TO pguser;


--
-- Name: receta; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE receta FROM PUBLIC;
REVOKE ALL ON TABLE receta FROM pguser;
GRANT ALL ON TABLE receta TO pguser;


--
-- Name: receta_ingrediente; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE receta_ingrediente FROM PUBLIC;
REVOKE ALL ON TABLE receta_ingrediente FROM pguser;
GRANT ALL ON TABLE receta_ingrediente TO pguser;


--
-- Name: subgrupo_mayor; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE subgrupo_mayor FROM PUBLIC;
REVOKE ALL ON TABLE subgrupo_mayor FROM pguser;
GRANT ALL ON TABLE subgrupo_mayor TO pguser;


--
-- Name: unidad; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE unidad FROM PUBLIC;
REVOKE ALL ON TABLE unidad FROM pguser;
GRANT ALL ON TABLE unidad TO pguser;


--
-- Name: ventahist; Type: ACL; Schema: public; Owner: pguser
--

REVOKE ALL ON TABLE ventahist FROM PUBLIC;
REVOKE ALL ON TABLE ventahist FROM pguser;
GRANT ALL ON TABLE ventahist TO pguser;


--
-- pguserQL database dump complete
--

