英文:
golang-migrate no change error on initial migration
问题
我正在使用golang-migrate
来管理迁移,当在github actions
CI上运行测试时,一切似乎都正常工作,但是当在Docker镜像上运行时,我无法使其工作。我一直收到一个no change
错误。与数据库的连接已经建立,并且.sql
迁移也正常工作。有什么建议可以帮助我调试实际发生了什么?
英文:
I'm using golang-migrate
for managing migrations everything seems to work correctly when running tests on github actions
CI, but I can't make it work when running on docker image. I just keep getting a no change
error. Connection to database is established and .sql
migrations work as well. Any suggestions on how could I debug what's actually going on?
func runMigrations(databaseUrl string) {
m, err := migrate.New(
"file://migrations/",
databaseUrl,
)
if err != nil {
log.Fatalf("Error loading migrations: %v", err)
}
if err := m.Up(); err != nil {
log.Printf("Error migrating Up: %v", err)
}
}
答案1
得分: 4
你可能需要在你的代码中添加一个检查err != migrate.ErrNoChange
。在这种情况下,"migrate"是包的名称。
https://github.com/golang-migrate/migrate/issues/100
英文:
Probably you need to add a check err != migrate.ErrNoChange
to your code. In this case, "migrate" is the name of the package
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论