Answer the question
In order to leave comments, you need to log in
How to specify in which database to create a table?
Hello.
To test the application, I want to use disposable containers with the postgres database. That is, run the container, conduct tests with saving the data in it, then delete the container and create the container again based on image.
To do this, I wrote init.sql with the following content:
CREATE USER parser WITH PASSWORD 'password';
CREATE DATABASE r;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO parser;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT INSERT ON TABLES TO parser;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT UPDATE ON TABLES TO parser;
CREATE table reviews (
id integer NOT NULL PRIMARY KEY
);
COMMIT;
version: "3.1"
services:
db_test:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: pass
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
ports:
- "5444:5432"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question