Skip to content

Commit eb9841f

Browse files
author
Fedor Kotov
committed
init
0 parents  commit eb9841f

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM postgres
2+
3+
ENV POSTGRES_USER=postgres
4+
ENV POSTGRES_PASSWORD=postgres
5+
ENV POSTGRES_DB=postgres
6+
7+
COPY ./init.sql /docker-entrypoint-initdb.d/
8+
9+
EXPOSE 5432

cmd.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
docker image build . -t taskmanager_postgres:latest
2+
3+
docker run -d -p 5432:5432 --name taskmanager_db taskmanager_postgres:latest

init.sql

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
CREATE TABLE public.task
2+
(
3+
id numeric,
4+
name character varying(200) COLLATE pg_catalog."default",
5+
done boolean,
6+
created timestamp(6) with time zone NOT NULL,
7+
priority character varying(30) COLLATE pg_catalog."default"
8+
);
9+
10+
ALTER TABLE public.task OWNER TO postgres;
11+
12+
CREATE SEQUENCE public.task_id_generator
13+
AS integer
14+
START WITH 1
15+
INCREMENT BY 1
16+
NO MINVALUE
17+
NO MAXVALUE
18+
CACHE 1;
19+
20+
21+
ALTER TABLE public.task_id_generator OWNER TO postgres;
22+
23+
ALTER TABLE ONLY public.task ALTER COLUMN id SET DEFAULT nextval('public.task_id_generator'::regclass);
24+
25+
COPY public.task (id, name, done, created, priority) FROM stdin;
26+
1 Task 1 false 2024-11-11 11:29:21.99998+00 NORMAL
27+
2 Task 2 false 2024-11-11 11:30:21.99998+00 LOW
28+
\.
29+
30+
SELECT pg_catalog.setval('public.task_id_generator', 2, true);
31+
32+
33+
ALTER TABLE ONLY public.task
34+
ADD CONSTRAINT task_pkey PRIMARY KEY (id);

0 commit comments

Comments
 (0)