drop table if exists users_followers;
drop table if exists users_likers;
drop table if exists bands_followers;
drop table if exists bands_likers;

CREATE TABLE likes
(
  id character varying(64) NOT NULL DEFAULT uuid_generate_v4(),
  user_id character varying(64) NOT NULL,
  likable_id character varying(64) NOT NULL,
  likable_type character varying(25) NOT NULL,
  created_at timestamp without time zone NOT NULL DEFAULT now(),
  updated_at timestamp without time zone NOT NULL DEFAULT now(),
  CONSTRAINT likes_pkey PRIMARY KEY (id),
  CONSTRAINT likes_user_fkey FOREIGN KEY (user_id) REFERENCES users (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE CASCADE,
  CONSTRAINT likes_user_uniqkey UNIQUE (user_id, likable_id)
);

CREATE TABLE follows
(
  id character varying(64) NOT NULL DEFAULT uuid_generate_v4(),
  user_id character varying(64) NOT NULL,
  followable_id character varying(64) NOT NULL,
  followable_type character varying(25) NOT NULL,
  created_at timestamp without time zone NOT NULL DEFAULT now(),
  updated_at timestamp without time zone NOT NULL DEFAULT now(),
  CONSTRAINT follows_pkey PRIMARY KEY (id),
  CONSTRAINT follows_user_fkey FOREIGN KEY (user_id) REFERENCES users (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE CASCADE,
  CONSTRAINT follows_user_uniqkey UNIQUE (user_id, followable_id)
);