add users table migrations. Need to install goose into migrator
This commit is contained in:
+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