jam-cloud/db/up/like_follower_poly_assoc.sql

30 lines
1.3 KiB
MySQL
Raw Permalink Normal View History

2014-02-16 19:48:54 +00:00
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(),
2014-02-15 23:23:00 +00:00
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),
2014-02-16 01:24:51 +00:00
CONSTRAINT likes_user_fkey FOREIGN KEY (user_id) REFERENCES users (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE CASCADE,
2014-02-15 23:23:00 +00:00
CONSTRAINT likes_user_uniqkey UNIQUE (user_id, likable_id)
);
2014-02-15 23:23:00 +00:00
CREATE TABLE follows
(
id character varying(64) NOT NULL DEFAULT uuid_generate_v4(),
2014-02-15 23:23:00 +00:00
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(),
2014-02-15 23:23:00 +00:00
CONSTRAINT follows_pkey PRIMARY KEY (id),
2014-02-16 01:24:51 +00:00
CONSTRAINT follows_user_fkey FOREIGN KEY (user_id) REFERENCES users (id) MATCH SIMPLE ON UPDATE NO ACTION ON DELETE CASCADE,
2014-02-15 23:23:00 +00:00
CONSTRAINT follows_user_uniqkey UNIQUE (user_id, followable_id)
);