Provide all needed correct values.
go run ./cmd/abr-plus \
-dsn="postgres://password:pa55word@localhost:5432/lecture6?sslmode=disable" \
-migrations=file://pkg/abr-plus/migrations \
-fill=true \
-env=development \
-port=8081dsn — postgress connection string with username, password, address, port, database name, and SSL mode. Default: Value is not correct by security reasons.
migrations — Path to folder with migration files. If not provided, migrations do not applied.
fill — Fill database with dummy data. Default: false.
env - App running mode. Default: development
port - App port. Default: 8081
env POSTGRES_PASSWORD="STRONG_PASSWORD" APP_DSN="postgres://postgres:postgres@db:5432/example?sslmode=disable" docker-compose --env-file .env.example up --buildenv POSTGRES_PASSWORD="postgres" this command adds envoirment variable then available in docker compose.
APP_DSN contains connection string to the dockerezed postgres.
❗IMPORTANT: Host value in DSN must have name of service from docker-compose. In our case hostname is db.
Also, port have to be right side value after semicolon, it's a port of service available in docker isolated network, the left port for access from outside (host OS). In our case:
"5433:5432" port 5432 for docker isolated network.
Overall, your DSN for docker should be like this:
postgres://postgres:postgres@db:5432/example?sslmode=disable.
--build flag force docker compose to rebuild app. For example, if you have changed source code, you need this flag.
-- Add write menus permission to user with id 1
INSERT INTO users_permissions
SELECT 1, permissions.id
FROM permissions
WHERE permissions.code = 'menus:write';# list of all menu items
GET /menus
POST /menus
GET /menus/:id
PUT /menus/:id
DELETE /menus/:id
// Use DBML to define your database structure
// Docs: https://dbml.dbdiagram.io/docs
Table restaurants {
id bigserial [primary key]
created_at timestamp
updated_at timestamp
title text
coordinates text
address text
cousine text
}
Table menu {
id bigserial [primary key]
created_at timestamp
updated_at timestamp
title text
description text
nutrition_value text
}
// many-to-many
Table restaurants_and_menu {
id bigserial [primary key]
created_at timestamp
updated_at timestamp
restaurant bigserial
menu bigserial
}
Ref: restaurants_and_menu.restaurant < restaurants.id
Ref: restaurants_and_menu.menu < menu.id