one more microservice migrator goose
This commit is contained in:
@@ -4,4 +4,7 @@ DB_NAME=postgres
|
||||
DB_PORT=5432
|
||||
HOST_DB=db
|
||||
SERVER_PORT=8000
|
||||
POSTGRESQL_URL='postgres://postgres:postgres@db:5432/postgres?sslmode=disable'
|
||||
POSTGRESQL_URL='postgres://postgres:postgres@db:5432/postgres?sslmode=disable'
|
||||
|
||||
# MIGRATOR
|
||||
MIGRATOR_PORT=3000
|
||||
+8
-4
@@ -4,10 +4,6 @@ services:
|
||||
image: postgres:16
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
- POSTGRES_USER=${DB_USER}
|
||||
- POSTGRES_PASSWORD=${DB_PASSWORD}
|
||||
- POSTGRES_DB=${DB_NAME}
|
||||
ports:
|
||||
- "${DB_PORT}:${DB_PORT}"
|
||||
volumes:
|
||||
@@ -28,5 +24,13 @@ services:
|
||||
- db
|
||||
command: ./bin/api.exe
|
||||
|
||||
migrator:
|
||||
build: ./migrator
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "${MIGRATOR_PORT}:${MIGRATOR_PORT}"
|
||||
command: "goose -dir ./migratios postgres 'user=postgres dbname=postgres sslmode=disable' up"
|
||||
|
||||
volumes:
|
||||
postgres-db:
|
||||
@@ -1,15 +0,0 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE IF NOT EXISTS users(
|
||||
Id UUID PRIMARY KEY NOT NULL,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
email VARCHAR(50),
|
||||
password VARCHAR(1000) NOT NULL,
|
||||
phone VARCHAR(30) NOT NULL
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS users;
|
||||
-- +goose StatementEnd
|
||||
@@ -1,3 +0,0 @@
|
||||
GOOSE_DRIVER=postgres
|
||||
GOOSE_DBSTRING="user=postgres dbname=postgres sslmode=disable"
|
||||
GOOSE_MIGRATION_DIR=/
|
||||
@@ -0,0 +1,10 @@
|
||||
FROM golang:1.22.5
|
||||
|
||||
RUN go get github.com/pressly/goose/cmd/goose
|
||||
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY migrations/* app/migrations/
|
||||
|
||||
CMD [ "goose", "up", "-dir=/app/migrations" ]
|
||||
@@ -0,0 +1,15 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE users(
|
||||
id UUID NOT NULL PRIMARY KEY,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
email VARCHAR(50) NOT NULL UNIQUE INDEX,
|
||||
password VARCHAR(500) NOT NULL,
|
||||
phone VARCHAR(50)
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE users;
|
||||
-- +goose StatementEnd
|
||||
Reference in New Issue
Block a user