英文:
How to perform migrations in golang migrate when the sql files are located in a github folder?
问题
我正在使用migrate/migrate来执行我的本地Postgres数据库的迁移。
我曾经在本地文件夹中使用迁移文件,并且迁移按预期运行,但我将迁移文件夹移动到GitHub的不同存储库中。
我的GitHub存储库中包含迁移的位置:
https://github.com/guimassoqueto/db-migrations
我在本地的compose.yml文件中定义了数据库和迁移:
version: '3.9'
services:
postgres:
container_name: postgres
image: postgres:alpine
restart: always
networks:
- local
ports:
- "${POSTGRES_PORT}:${POSTGRES_PORT}"
healthcheck:
test: ["CMD-SHELL", "pg_isready -d ${POSTGRES_DB} -U ${POSTGRES_USER}"]
interval: 15s
timeout: 5s
retries: 5
start_period: 30s
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_USER: ${POSTGRES_USER}
migrate:
container_name: migrate
image: migrate/migrate
networks:
- local
command: "-source https://github.com/guimassoqueto/db-migrations/blob/main/migrations -database postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:${POSTGRES_PORT}/${POSTGRES_DB}?sslmode=disable -verbose up"
links:
- postgres
depends_on:
postgres:
condition: service_healthy
networks:
local:
name: local
driver: bridge
我认为我在compose文件中的command
键上可能犯了一些错误,但我不确定具体哪里出错了。
英文:
I am using the migrate/migrate to perform migrations of my postgres local database.
I was using the migrations files inside a local folder and the migrations were running as expected, but I moved the migrations folder to a different repository in github.
Github repository where my migrations are located:
https://github.com/guimassoqueto/db-migrations
My local compose.yml file in which I define database and migrations:
version: '3.9'
services:
postgres:
container_name: postgres
image: postgres:alpine
restart: always
networks:
- local
ports:
- "${POSTGRES_PORT}:${POSTGRES_PORT}"
healthcheck:
test: ["CMD-SHELL", "pg_isready -d ${POSTGRES_DB} -U ${POSTGRES_USER}"]
interval: 15s
timeout: 5s
retries: 5
start_period: 30s
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_USER: ${POSTGRES_USER}
migrate:
container_name: migrate
image: migrate/migrate
networks:
- local
command: "-source https://github.com/guimassoqueto/db-migrations/blob/main/migrations -database postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:${POSTGRES_PORT}/${POSTGRES_DB}?sslmode=disable -verbose up"
links:
- postgres
depends_on:
postgres:
condition: service_healthy
networks:
local:
name: local
driver: bridge
I think I am making some mistake at the command
key in the compose file, but I have no idea precisely what I am doing wrong.
答案1
得分: 1
答案在文档中,我没有注意:
https://github.com/golang-migrate/migrate/tree/master/source/github
英文:
The answer is in the docs, I didn't pay attention:
https://github.com/golang-migrate/migrate/tree/master/source/github
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论