add new
This commit is contained in:
52
RS_system/Migrations/sql_movimientos.sql
Normal file
52
RS_system/Migrations/sql_movimientos.sql
Normal file
@@ -0,0 +1,52 @@
|
||||
-- Table: public.movimientos_inventario
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.movimientos_inventario
|
||||
(
|
||||
id bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 ),
|
||||
articulo_id integer NOT NULL,
|
||||
tipo_movimiento character varying(50) COLLATE pg_catalog."default" NOT NULL,
|
||||
fecha timestamp without time zone NOT NULL DEFAULT (now() AT TIME ZONE 'utc'::text),
|
||||
ubicacion_origen_id integer,
|
||||
ubicacion_destino_id integer,
|
||||
estado_anterior_id integer,
|
||||
estado_nuevo_id integer,
|
||||
observacion character varying(500) COLLATE pg_catalog."default",
|
||||
usuario_id character varying(100) COLLATE pg_catalog."default",
|
||||
CONSTRAINT movimientos_inventario_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT fk_movimientos_articulos FOREIGN KEY (articulo_id)
|
||||
REFERENCES public.articulos (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE CASCADE,
|
||||
CONSTRAINT fk_movimientos_origen FOREIGN KEY (ubicacion_origen_id)
|
||||
REFERENCES public.ubicaciones (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE SET NULL,
|
||||
CONSTRAINT fk_movimientos_destino FOREIGN KEY (ubicacion_destino_id)
|
||||
REFERENCES public.ubicaciones (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE SET NULL,
|
||||
CONSTRAINT fk_movimientos_estado_ant FOREIGN KEY (estado_anterior_id)
|
||||
REFERENCES public.estados_articulos (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE SET NULL,
|
||||
CONSTRAINT fk_movimientos_estado_new FOREIGN KEY (estado_nuevo_id)
|
||||
REFERENCES public.estados_articulos (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE SET NULL
|
||||
)
|
||||
TABLESPACE pg_default;
|
||||
|
||||
ALTER TABLE IF EXISTS public.movimientos_inventario
|
||||
OWNER to postgres;
|
||||
|
||||
-- Indexes
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ix_movimientos_articulo_id
|
||||
ON public.movimientos_inventario USING btree
|
||||
(articulo_id ASC NULLS LAST)
|
||||
TABLESPACE pg_default;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ix_movimientos_fecha
|
||||
ON public.movimientos_inventario USING btree
|
||||
(fecha DESC NULLS LAST)
|
||||
TABLESPACE pg_default;
|
||||
Reference in New Issue
Block a user