forked from MarseyWorld/MarseyWorld
add unique constraint
parent
f41c077d86
commit
1c34e1155c
|
@ -1,6 +1,6 @@
|
|||
create table media_usages (
|
||||
id integer primary key,
|
||||
filename character varying(55) NOT NULL,
|
||||
id integer primary key,
|
||||
filename character varying(55) NOT NULL,
|
||||
post_id integer,
|
||||
comment_id integer,
|
||||
created_utc integer not null,
|
||||
|
@ -9,12 +9,15 @@ create table media_usages (
|
|||
);
|
||||
|
||||
CREATE SEQUENCE public.media_usages_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
ALTER TABLE ONLY public.media_usages
|
||||
ADD CONSTRAINT media_usages_unique UNIQUE NULLS NOT DISTINCT (filename, post_id, comment_id);
|
||||
|
||||
ALTER SEQUENCE public.media_usages_id_seq OWNED BY public.media_usages.id;
|
||||
|
||||
|
@ -22,7 +25,7 @@ ALTER TABLE ONLY public.media_usages ALTER COLUMN id SET DEFAULT nextval('public
|
|||
|
||||
|
||||
alter table media_usages
|
||||
add constraint media_usages_post_fkey foreign key (post_id) references posts(id);
|
||||
add constraint media_usages_post_fkey foreign key (post_id) references posts(id);
|
||||
|
||||
alter table media_usages
|
||||
add constraint media_usages_comment_fkey foreign key (comment_id) references comments(id);
|
||||
add constraint media_usages_comment_fkey foreign key (comment_id) references comments(id);
|
Loading…
Reference in New Issue