chore(migrations): refactored bad ass vibecode migrations
This commit is contained in:
@@ -1,59 +1,25 @@
|
|||||||
-- DROP SCHEMA public;
|
DROP TABLE IF EXISTS public.favorites;
|
||||||
-- CREATE SCHEMA public AUTHORIZATION pg_database_owner;
|
DROP TABLE IF EXISTS public.films;
|
||||||
-- COMMENT ON SCHEMA public IS 'standard public schema';
|
DROP TABLE IF EXISTS public.users;
|
||||||
|
|
||||||
-- public.genres определение
|
|
||||||
-- Drop table
|
|
||||||
DROP TABLE if exists public.genres;
|
|
||||||
CREATE TABLE public.genres (
|
|
||||||
id int4 GENERATED ALWAYS AS IDENTITY NOT NULL,
|
|
||||||
"name" varchar NULL,
|
|
||||||
CONSTRAINT genres_unique PRIMARY KEY (id)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
-- public.users определение
|
|
||||||
-- Drop table
|
|
||||||
DROP TABLE if exists public.users;
|
|
||||||
CREATE TABLE public.users (
|
CREATE TABLE public.users (
|
||||||
id int4 GENERATED ALWAYS AS IDENTITY NOT NULL,
|
id UUID PRIMARY KEY,
|
||||||
login varchar NOT NULL,
|
name VARCHAR(255) NOT NULL,
|
||||||
"password" varchar NOT NULL,
|
email VARCHAR(320) NOT NULL UNIQUE
|
||||||
CONSTRAINT users_unique UNIQUE (id)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
-- public.films определение
|
|
||||||
-- Drop table
|
|
||||||
DROP TABLE if exists public.films;
|
|
||||||
CREATE TABLE public.films (
|
CREATE TABLE public.films (
|
||||||
id int4 GENERATED ALWAYS AS IDENTITY NOT NULL,
|
id UUID PRIMARY KEY,
|
||||||
title varchar NOT NULL,
|
title VARCHAR(255) NOT NULL,
|
||||||
genre_id int4 NOT NULL,
|
description TEXT NOT NULL
|
||||||
issue_date date NULL,
|
|
||||||
CONSTRAINT films_unique UNIQUE(id)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
DROP TABLE if exists public.film_genres;
|
|
||||||
CREATE TABLE public.film_genres (
|
|
||||||
id int4 GENERATED ALWAYS AS IDENTITY NOT NULL,
|
|
||||||
genre_id int4 NOT NULL,
|
|
||||||
film_id int4 NOT NULL,
|
|
||||||
CONSTRAINT film_genres_genre_fk FOREIGN KEY (genre_id) REFERENCES public.genres(id),
|
|
||||||
CONSTRAINT film_genres_film_fk FOREIGN KEY (film_id) REFERENCES public.films(id)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
-- Drop table
|
|
||||||
DROP TABLE if exists public.favorites;
|
|
||||||
CREATE TABLE public.favorites (
|
CREATE TABLE public.favorites (
|
||||||
id int4 GENERATED ALWAYS AS IDENTITY NOT NULL,
|
id UUID PRIMARY KEY,
|
||||||
userid int4 NULL,
|
user_id UUID NOT NULL,
|
||||||
film_id int4 NULL,
|
film_id UUID NOT NULL,
|
||||||
"comment" varchar NULL,
|
comment VARCHAR(1024),
|
||||||
is_viewed bool NULL,
|
is_viewed BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
CONSTRAINT favorites_unique PRIMARY KEY (id),
|
CONSTRAINT favorites_user_fk FOREIGN KEY (user_id) REFERENCES public.users(id) ON DELETE CASCADE,
|
||||||
CONSTRAINT favorites_films_fk FOREIGN KEY (film_id) REFERENCES public.films(id),
|
CONSTRAINT favorites_film_fk FOREIGN KEY (film_id) REFERENCES public.films(id) ON DELETE CASCADE
|
||||||
CONSTRAINT favorites_users_fk FOREIGN KEY (user_id) REFERENCES public.users(id)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user