MarseyWorld/migrations/20241022-cleanup-videos.sql

31 lines
884 B
MySQL
Raw Normal View History

2024-10-22 17:57:23 +00:00
create table media_usages (
2024-10-23 20:01:09 +00:00
id integer primary key,
filename character varying(55) NOT NULL,
2024-10-22 17:57:23 +00:00
post_id integer,
comment_id integer,
created_utc integer not null,
deleted_utc integer,
removed_utc integer
);
CREATE SEQUENCE public.media_usages_id_seq
2024-10-23 20:01:09 +00:00
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);
2024-10-22 17:57:23 +00:00
ALTER SEQUENCE public.media_usages_id_seq OWNED BY public.media_usages.id;
ALTER TABLE ONLY public.media_usages ALTER COLUMN id SET DEFAULT nextval('public.media_usages_id_seq'::regclass);
alter table media_usages
2024-10-23 20:01:09 +00:00
add constraint media_usages_post_fkey foreign key (post_id) references posts(id);
2024-10-22 17:57:23 +00:00
alter table media_usages
2024-10-23 20:01:09 +00:00
add constraint media_usages_comment_fkey foreign key (comment_id) references comments(id);