create schema if not exists gis;

CREATE TABLE if not exists gis.widgets
(
  widget_id text NOT NULL DEFAULT next_id(),
  map_id text NOT NULL,
  name text,
  type text NOT NULL,
  title text,
  position text,
  config jsonb,
  created_by text NOT NULL,
  updated_by text,
  updated_at timestamp without time zone,
  created_at timestamp without time zone NOT NULL DEFAULT now(),
  CONSTRAINT widgets_pkey PRIMARY KEY (widget_id),
  CONSTRAINT widgets_map_id_fkey FOREIGN KEY (map_id)
      REFERENCES gis.maps (map_id)
);

COMMENT ON TABLE gis.widgets IS 'Map widgets';