add users table migrations. Need to install goose into migrator
This commit is contained in:
@@ -4,6 +4,7 @@ DB_NAME=postgres
|
||||
DB_PORT=5432
|
||||
HOST_DB=db
|
||||
SERVER_PORT=8000
|
||||
SSLmode=disable
|
||||
POSTGRESQL_URL='postgres://postgres:postgres@db:5432/postgres?sslmode=disable'
|
||||
|
||||
# MIGRATOR
|
||||
|
||||
@@ -30,7 +30,6 @@ services:
|
||||
- .env
|
||||
ports:
|
||||
- "${MIGRATOR_PORT}:${MIGRATOR_PORT}"
|
||||
command: "goose -dir ./migratios postgres 'user=postgres dbname=postgres sslmode=disable' up"
|
||||
|
||||
volumes:
|
||||
postgres-db:
|
||||
+5
-4
@@ -1,10 +1,11 @@
|
||||
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" ]
|
||||
COPY go.mod app/
|
||||
|
||||
RUN go install github.com/pressly/goose/v3/cmd/goose@latest
|
||||
|
||||
CMD ["goose", "-dir=/app/migrations", "user=${DB_USER}", "dbname=${DB_NAME}", "sslmode=${SSLmode}" "up"]
|
||||
@@ -0,0 +1,3 @@
|
||||
module migrator
|
||||
|
||||
go 1.22.5
|
||||
@@ -1,6 +1,6 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE users(
|
||||
CREATE TABLE IF NOT EXISTS users(
|
||||
id UUID NOT NULL PRIMARY KEY,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
email VARCHAR(50) NOT NULL UNIQUE INDEX,
|
||||
@@ -11,5 +11,5 @@ CREATE TABLE users(
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE users;
|
||||
DROP TABLE IF EXISTS users;
|
||||
-- +goose StatementEnd
|
||||
|
||||
Reference in New Issue
Block a user