
-- Table: users

-- DROP TABLE users;

CREATE TABLE users
(
  id character varying(32) NOT NULL,
  username character varying(30),
  email character varying(100),
  password character varying(512) DEFAULT ''::character varying,
  record_status character(1),
  created_at bigint,
  created_by character varying(32),
  updated_at bigint,
  updated_by character varying(32),
  CONSTRAINT user_pkey PRIMARY KEY (id),
  CONSTRAINT users_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT users_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE users
  OWNER TO postgres;


-- Table: users_details

-- DROP TABLE users_details;

CREATE TABLE users_details
(
  id character varying(32) NOT NULL,
  user_id character varying(32) NOT NULL,
  username character varying(30),
  first_name character varying(100),
  last_name character varying(100),
  gender character varying(5),
  date_of_birth character varying(12),
  contact character varying(13),
  image character varying(256),
  designation character varying(30),
  cougar_id character varying(256),
  record_status character(1),
  created_at bigint,
  created_by character varying(32),
  updated_at bigint,
  updated_by character varying(32),
  CONSTRAINT user_details_pkey PRIMARY KEY (id),
  CONSTRAINT user_details_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT user_details_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE users_details
  OWNER TO postgres;




-- Table: roles

-- DROP TABLE roles;

CREATE TABLE roles
(
  id character varying(32) NOT NULL,
  name character varying(20),
  created_by character varying(32),
  created_at bigint,
  updated_by character varying(32),
  updated_at bigint,
  CONSTRAINT roles_pkey PRIMARY KEY (id),
  CONSTRAINT roles_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT roles_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE roles
  OWNER TO postgres;





-- Table: user_roles

-- DROP TABLE user_roles;

CREATE TABLE user_roles
(
  id character varying(32) NOT NULL,
  user_id character varying(32),
  role_id character varying(32),
  record_status character(1),
  created_by character varying(32),
  created_at bigint,
  updated_by character varying(32),
  updated_at bigint,
  CONSTRAINT user_roles_pkey PRIMARY KEY (id),
  CONSTRAINT user_roles_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT user_roles_role_id_fk FOREIGN KEY (role_id)
      REFERENCES roles (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT user_roles_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT user_roles_user_id_fk FOREIGN KEY (user_id)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE user_roles
  OWNER TO postgres;



-- Table: user_connections

-- DROP TABLE user_connections;

CREATE TABLE user_connections
(
  id character varying(32) NOT NULL,
  user_id character varying(32),
  connection_id character varying(32),
  connection_status character varying(32),
  record_status character(1),
  created_by character varying(32),
  created_at bigint,
  updated_by character varying(32),
  updated_at bigint,
  CONSTRAINT user_connections_pkey PRIMARY KEY (id),
  CONSTRAINT user_connections_connection_id_fk FOREIGN KEY (connection_id)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT user_connections_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT user_connections_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT user_connections_user_id_fk FOREIGN KEY (user_id)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE user_connections
  OWNER TO postgres;




-- Table: cougar_100

-- DROP TABLE cougar_100;

CREATE TABLE cougar_100
(
  id character varying(32) NOT NULL,
  company_name character varying(32),
  ranking bigint,
  image character varying(256),
  record_status character(1),
  created_by character varying(32),
  created_at bigint,
  updated_by character varying(32),
  updated_at bigint,
  CONSTRAINT cougar_100_pkey PRIMARY KEY (id),
  CONSTRAINT cougar_100_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT cougar_100_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE cougar_100
  OWNER TO postgres;



-- Table: company_details

-- DROP TABLE company_details;

CREATE TABLE company_details
(
  id character varying(32) NOT NULL,
  cougar_id character varying(32),
  large_image character varying(256),
  tags character varying(256),
  website character varying(256),
  about_content text,
  foundation_year character varying(4),
  address_line_1 character varying(256),
  address_line_2 character varying(256),
  city character varying(30),
  state character varying(30),
  country character varying(30),
  email character varying(100),
  contact_number character varying(13),
  record_status character(1),
  created_by character varying(32),
  created_at bigint,
  updated_by character varying(32),
  updated_at bigint,
  CONSTRAINT company_details_pkey PRIMARY KEY (id),
  CONSTRAINT company_details_cougar_id_fk FOREIGN KEY (cougar_id)
      REFERENCES cougar_100 (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT cougar_100_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT cougar_100_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE company_details
  OWNER TO postgres;



CREATE TABLE company_owner
(
  id character varying(32) NOT NULL,
  cougar_id character varying(32),
  user_id character varying(32),
  record_status character(1),
  created_by character varying(32),
  created_at bigint,
  updated_by character varying(32),
  updated_at bigint,
  CONSTRAINT company_owner_pkey PRIMARY KEY (id),
  CONSTRAINT company_owner_cougar_id_fk FOREIGN KEY (cougar_id)
      REFERENCES cougar_100 (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT company_owner_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT company_owner_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT company_owner_user_id_fk FOREIGN KEY (user_id)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE company_owner
  OWNER TO postgres;




-- Table: company_products

-- DROP TABLE company_products;

CREATE TABLE company_products
(
  id character varying(32) NOT NULL,
  cougar_id character varying(32),
  product_name character varying(100),
  image character varying(256),
  description text,
  record_status character(1),
  created_by character varying(32),
  created_at bigint,
  updated_by character varying(32),
  updated_at bigint,
  CONSTRAINT company_products_pkey PRIMARY KEY (id),
  CONSTRAINT company_products_cougar_id_fk FOREIGN KEY (cougar_id)
      REFERENCES cougar_100 (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT company_products_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT company_products_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE company_products
  OWNER TO postgres;




-- Table: sort_orders

-- DROP TABLE sort_orders;

CREATE TABLE sort_orders
(
  id character varying(32) NOT NULL,
  order_type character varying(32),
  record_status character(1),
  created_by character varying(32),
  created_at bigint,
  updated_by character varying(32),
  updated_at bigint,
  CONSTRAINT sort_orders_pkey PRIMARY KEY (id),
  CONSTRAINT sort_orders_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT sort_orders_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE sort_orders
  OWNER TO postgres;



-- Table: sessions

-- DROP TABLE sessions;

CREATE TABLE sessions
(
  id character varying(32) NOT NULL,
  user_id character varying(32),

  record_status character(1),
  created_by character varying(32),
  created_at bigint,
  updated_by character varying(32),
  updated_at bigint,
  CONSTRAINT sessions_pkey PRIMARY KEY (id),
  CONSTRAINT sessions_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT sessions_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT sessions_user_id_fk FOREIGN KEY (user_id)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE sessions
  OWNER TO postgres;



-- Table: user_notifications

-- DROP TABLE user_notifications;

CREATE TABLE user_notifications
(
  id character varying(32) NOT NULL,
  user_id character varying(32),
  cougar_id character varying(32),
  product_id character varying(32),
  title character varying(100),
  message text,
  record_status character(1),
  created_by character varying(32),
  created_at bigint,
  updated_by character varying(32),
  updated_at bigint,
  CONSTRAINT user_notifications_pkey PRIMARY KEY (id),
  CONSTRAINT user_notifications_user_id_fk FOREIGN KEY (user_id)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT user_notifications_cougar_id_fk FOREIGN KEY (cougar_id)
      REFERENCES cougar_100 (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT user_notifications_product_id_fk FOREIGN KEY (product_id)
      REFERENCES company_products (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,      
  CONSTRAINT user_notifications_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT user_notifications_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE user_notifications
  OWNER TO postgres;

ALTER TABLE cougar_100 ADD COLUMN active_status character(1);

ALTER TABLE user_notifications ADD COLUMN read_status character varying(1);

ALTER TABLE users ADD COLUMN active_status character(1);

ALTER TABLE company_products ADD COLUMN active_status character(1);

-- Table: company_services

-- DROP TABLE company_services;

CREATE TABLE company_services
(
  id character varying(32) NOT NULL,
  cougar_id character varying(32),
  service_name character varying(100),
  image character varying(256),
  description text,
  record_status character(1),
  created_by character varying(32),
  created_at bigint,
  updated_by character varying(32),
  updated_at bigint,
  active_status character(1),
  CONSTRAINT company_services_pkey PRIMARY KEY (id),
  CONSTRAINT company_services_cougar_id_fk FOREIGN KEY (cougar_id)
      REFERENCES cougar_100 (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT company_services_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT company_services_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE company_services
  OWNER TO postgres;



-- Table: links

-- DROP TABLE links;

CREATE TABLE links
(
  id character varying(32) NOT NULL,
  title character varying(256),
  url text,
  record_status character varying(1),
  created_by character varying(32),
  created_at bigint,
  updated_by character varying(32),
  updated_at bigint,
  CONSTRAINT links_pkey PRIMARY KEY (id),
  CONSTRAINT links_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT links_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE links
  OWNER TO postgres;

ALTER TABLE links ADD COLUMN image character varying(256);

ALTER TABLE user_notifications ADD COLUMN image character varying(256);



-- Table: chat_history

-- DROP TABLE chat_history;

CREATE TABLE chat_history
(
  id character varying(32) NOT NULL,
  sender_id character varying(32),
  receiver_id character varying(32),
  record_status character(1),
  created_by character varying(32),
  created_at bigint,
  updated_by character varying(32),
  updated_at bigint,
  CONSTRAINT chat_history_pkey PRIMARY KEY (id),
  CONSTRAINT chat_history_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT chat_history_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT chat_history_sender_id_fk FOREIGN KEY (sender_id)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT chat_history_receiver_id_fk FOREIGN KEY (receiver_id)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE chat_history
  OWNER TO postgres;


-- Table: registered_devices

-- DROP TABLE registered_devices;

CREATE TABLE registered_devices
(
  id character varying(32) NOT NULL,
  device_type character varying(512),
  device_push_token character varying(512),
  unique_device_key character varying(512),
  device_name character varying(512),
  device_model character varying(512),
  device_version character varying(10),
  mode character(1),
  is_notification_active character(1),
  created_at bigint,
  created_by character varying(32),
  updated_at bigint,
  updated_by character varying(32),
  CONSTRAINT registered_devices_pkey PRIMARY KEY (id)
 
)
WITH (
  OIDS=FALSE
);
ALTER TABLE registered_devices
  OWNER TO postgres;


-- Table: user_registered_devices

-- DROP TABLE user_registered_devices;

CREATE TABLE user_registered_devices
(
  id character varying(32) NOT NULL,
  registered_device_id character varying(512),
  user_id character varying(512),
  record_status character(1),
  created_at bigint,
  created_by character varying(32),
  updated_at bigint,
  updated_by character varying(32),
  CONSTRAINT user_registered_devices_pkey PRIMARY KEY (id),
  CONSTRAINT user_registered_devices_created_by_fk FOREIGN KEY (created_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT user_registered_devices_registered_device_id_fk FOREIGN KEY (registered_device_id)
      REFERENCES registered_devices (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT user_registered_devices_updated_by_fk FOREIGN KEY (updated_by)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION,
  CONSTRAINT user_registered_devices_user_id_fk FOREIGN KEY (user_id)
      REFERENCES users (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
  OIDS=FALSE
);
ALTER TABLE user_registered_devices
  OWNER TO postgres;

