CREATE SEQUENCE public.second_opinion_id_seq
  INCREMENT 1
  MINVALUE 1
  MAXVALUE 9223372036854775807
  START 1
  CACHE 1;
ALTER TABLE public.second_opinion_id_seq
  OWNER TO postgres;


-- Table: public.second_opinion

-- DROP TABLE public.second_opinion;

CREATE TABLE public.second_opinion
(
  id integer NOT NULL DEFAULT nextval('second_opinion_id_seq'::regclass),
  appointment_code character varying(10),
  id_user_request integer,
  requesting_comment text,
  requesting_date timestamp without time zone,
  id_requested_user integer,
  second_opinion text,
  status boolean,
  second_opinion_date timestamp without time zone,
  priority int4,
  CONSTRAINT id_secon_opinion PRIMARY KEY (id),
  CONSTRAINT id_requested_user FOREIGN KEY (id_requested_user)
      REFERENCES public.user_sonata (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT id_requesting_user FOREIGN KEY (id_user_request)
      REFERENCES public.user_sonata (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE public.second_opinion
  OWNER TO postgres;
