add goose

This commit is contained in:
user-penguin 2024-11-10 01:48:28 +07:00
parent 4a104923c7
commit 5567875910
3 changed files with 29 additions and 0 deletions

View File

@ -31,10 +31,14 @@ steps:
- smm_core
- docker-compose.yml
- Dockerfile
- migrations
rm: true
- name: deploy
image: appleboy/drone-ssh
environment:
DB_PASS:
from_secret: db_pass
settings:
host:
from_secret: server_ip
@ -47,6 +51,8 @@ steps:
command_timeout: 50s
script:
- cd deploys/smm_core
- export PATH=$PATH:/usr/local/go/bin:/$HOME/go/bin
- goose -allow-missing -dir ./migrations postgres "user=crab password=$${DB_PASS} dbname=smm-core host=localhost port=5432 sslmode=disable" up
- docker-compose up -d --build --force-recreate
trigger:

View File

@ -1,6 +1,17 @@
LOCAL_BIN := $(CURDIR)/bin
PATH := $(LOCAL_BIN):$(PATH)
ifeq (local-migrations-create,$(firstword $(MAKECMDGOALS)))
migrationName := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(migrationName):;@:)
endif
local-migrate-up:
@goose -allow-missing -dir ./migrations postgres "user=crab dbname=smm-core host=localhost port=5432 sslmode=disable" up
local-migrations-create:
@goose -dir ./migrations postgres "user=crab dbname=smm-core host=localhost port=5432 sslmode=disable" create "${migrationName}" sql
local-go-init: export GOBIN := $(LOCAL_BIN)
local-go-init:
go get github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway

View File

@ -0,0 +1,12 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE IF NOT EXISTS "user" (
id SERIAL PRIMARY KEY,
chat_id TEXT NOT NULL
);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE IF EXISTS "user";
-- +goose StatementEnd