333 lines
7.6 KiB
SQL
333 lines
7.6 KiB
SQL
--
|
|
-- PostgreSQL database dump
|
|
--
|
|
|
|
-- Dumped from database version 17.3 (Debian 17.3-3.pgdg120+1)
|
|
-- Dumped by pg_dump version 17.3 (Debian 17.3-3.pgdg120+1)
|
|
|
|
SET statement_timeout = 0;
|
|
SET lock_timeout = 0;
|
|
SET idle_in_transaction_session_timeout = 0;
|
|
SET transaction_timeout = 0;
|
|
SET client_encoding = 'UTF8';
|
|
SET standard_conforming_strings = on;
|
|
SELECT pg_catalog.set_config('search_path', '', false);
|
|
SET check_function_bodies = false;
|
|
SET xmloption = content;
|
|
SET client_min_messages = warning;
|
|
SET row_security = off;
|
|
|
|
SET default_tablespace = '';
|
|
|
|
SET default_table_access_method = heap;
|
|
|
|
--
|
|
-- Name: blog; Type: TABLE; Schema: public; Owner: postgres
|
|
--
|
|
|
|
CREATE TABLE public.blog (
|
|
id integer NOT NULL,
|
|
owner_id integer NOT NULL,
|
|
name character varying NOT NULL,
|
|
description character varying NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public.blog OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: blog_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
|
--
|
|
|
|
CREATE SEQUENCE public.blog_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.blog_id_seq OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: blog_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER SEQUENCE public.blog_id_seq OWNED BY public.blog.id;
|
|
|
|
|
|
--
|
|
-- Name: comment; Type: TABLE; Schema: public; Owner: postgres
|
|
--
|
|
|
|
CREATE TABLE public.comment (
|
|
id integer NOT NULL,
|
|
text character varying NOT NULL,
|
|
author_id integer NOT NULL,
|
|
post_id integer NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public.comment OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: comment_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
|
--
|
|
|
|
CREATE SEQUENCE public.comment_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.comment_id_seq OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: comment_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER SEQUENCE public.comment_id_seq OWNED BY public.comment.id;
|
|
|
|
|
|
--
|
|
-- Name: post; Type: TABLE; Schema: public; Owner: postgres
|
|
--
|
|
|
|
CREATE TABLE public.post (
|
|
id integer NOT NULL,
|
|
header character varying NOT NULL,
|
|
text character varying NOT NULL,
|
|
author_id integer NOT NULL,
|
|
blog_id integer NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public.post OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: post_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
|
--
|
|
|
|
CREATE SEQUENCE public.post_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.post_id_seq OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: post_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER SEQUENCE public.post_id_seq OWNED BY public.post.id;
|
|
|
|
|
|
--
|
|
-- Name: user; Type: TABLE; Schema: public; Owner: postgres
|
|
--
|
|
|
|
CREATE TABLE public."user" (
|
|
id integer NOT NULL,
|
|
email character varying NOT NULL,
|
|
login character varying NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public."user" OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: user_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
|
|
--
|
|
|
|
CREATE SEQUENCE public.user_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.user_id_seq OWNER TO postgres;
|
|
|
|
--
|
|
-- Name: user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER SEQUENCE public.user_id_seq OWNED BY public."user".id;
|
|
|
|
|
|
--
|
|
-- Name: blog id; Type: DEFAULT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY public.blog ALTER COLUMN id SET DEFAULT nextval('public.blog_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: comment id; Type: DEFAULT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY public.comment ALTER COLUMN id SET DEFAULT nextval('public.comment_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: post id; Type: DEFAULT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY public.post ALTER COLUMN id SET DEFAULT nextval('public.post_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: user id; Type: DEFAULT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY public."user" ALTER COLUMN id SET DEFAULT nextval('public.user_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Data for Name: blog; Type: TABLE DATA; Schema: public; Owner: postgres
|
|
--
|
|
|
|
INSERT INTO public.blog (id, owner_id, name, description) VALUES (2, 1, 'мой новый блог', 'описание');
|
|
INSERT INTO public.blog (id, owner_id, name, description) VALUES (3, 2, 'мой старый блог', 'такое же описание');
|
|
|
|
|
|
--
|
|
-- Data for Name: comment; Type: TABLE DATA; Schema: public; Owner: postgres
|
|
--
|
|
|
|
INSERT INTO public.comment (id, text, author_id, post_id) VALUES (1, 'хороший пост', 1, 1);
|
|
INSERT INTO public.comment (id, text, author_id, post_id) VALUES (2, 'тоже норм', 1, 2);
|
|
INSERT INTO public.comment (id, text, author_id, post_id) VALUES (3, 'другой комент', 2, 2);
|
|
|
|
|
|
--
|
|
-- Data for Name: post; Type: TABLE DATA; Schema: public; Owner: postgres
|
|
--
|
|
|
|
INSERT INTO public.post (id, header, text, author_id, blog_id) VALUES (1, 'заголовок', 'текст', 1, 2);
|
|
INSERT INTO public.post (id, header, text, author_id, blog_id) VALUES (2, 'другой заголовок', 'другой текст', 2, 2);
|
|
|
|
|
|
--
|
|
-- Data for Name: user; Type: TABLE DATA; Schema: public; Owner: postgres
|
|
--
|
|
|
|
INSERT INTO public."user" (id, email, login) VALUES (1, 'matv864@gmail.com', 'matv864');
|
|
INSERT INTO public."user" (id, email, login) VALUES (2, 'another@gmail.com', 'another');
|
|
|
|
|
|
--
|
|
-- Name: blog_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
|
|
--
|
|
|
|
SELECT pg_catalog.setval('public.blog_id_seq', 3, true);
|
|
|
|
|
|
--
|
|
-- Name: comment_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
|
|
--
|
|
|
|
SELECT pg_catalog.setval('public.comment_id_seq', 3, true);
|
|
|
|
|
|
--
|
|
-- Name: post_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
|
|
--
|
|
|
|
SELECT pg_catalog.setval('public.post_id_seq', 2, true);
|
|
|
|
|
|
--
|
|
-- Name: user_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
|
|
--
|
|
|
|
SELECT pg_catalog.setval('public.user_id_seq', 2, true);
|
|
|
|
|
|
--
|
|
-- Name: blog blog_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY public.blog
|
|
ADD CONSTRAINT blog_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: comment comment_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY public.comment
|
|
ADD CONSTRAINT comment_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: post post_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY public.post
|
|
ADD CONSTRAINT post_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: user user_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY public."user"
|
|
ADD CONSTRAINT user_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: blog blog_owner_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY public.blog
|
|
ADD CONSTRAINT blog_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES public."user"(id);
|
|
|
|
|
|
--
|
|
-- Name: comment comment_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY public.comment
|
|
ADD CONSTRAINT comment_author_id_fkey FOREIGN KEY (author_id) REFERENCES public."user"(id);
|
|
|
|
|
|
--
|
|
-- Name: comment comment_post_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY public.comment
|
|
ADD CONSTRAINT comment_post_id_fkey FOREIGN KEY (post_id) REFERENCES public.post(id);
|
|
|
|
|
|
--
|
|
-- Name: post post_author_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY public.post
|
|
ADD CONSTRAINT post_author_id_fkey FOREIGN KEY (author_id) REFERENCES public."user"(id);
|
|
|
|
|
|
--
|
|
-- Name: post post_blog_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: postgres
|
|
--
|
|
|
|
ALTER TABLE ONLY public.post
|
|
ADD CONSTRAINT post_blog_id_fkey FOREIGN KEY (blog_id) REFERENCES public.blog(id);
|
|
|
|
|
|
--
|
|
-- PostgreSQL database dump complete
|
|
--
|
|
|