Questions tagged [golang-migrate]

golang-migrate is a database migration tool written in Go. Questions tagged golang-migrate should be directly related to database migrations in Go.

See https://github.com/golang-migrate/migrate

Database migrations written in Go. Use as CLI or import as library.

  • Migrate reads migrations from sources and applies them in correct order to a database.
  • Drivers are "dumb", migrate glues everything together and makes sure the logic is bulletproof. (Keeps the drivers lightweight, too.)
  • Database drivers don't assume things or try to correct user input. When in doubt, fail.
107 questions
20
votes
5 answers

Dirty database version error when using golang-migrate

I am a new user of golang-migrate. I have run some migrations that executed with success. I am on development mode so I want to fore re-run the migrations so in psql shell and after connecting to my database, I executed drop database…
pkaramol
  • 16,451
  • 43
  • 149
  • 324
15
votes
6 answers

Gorm Migration using golang-migrate/migrate

I decided to use gorm as my ORM. I wanted to do a migration using golang-migrate/migrate because, it looks like, GORM does not have versioned migration files. And I rather, do migration using CLI, than using auto-migration. I read the gorm…
flemadap
  • 639
  • 8
  • 18
6
votes
1 answer

Can you use golang-migrate with go's embed function?

I'm trying to use golang-migrate to migrate a sql file into my postgresql database. I'm likely doing this wrong, but when I run the command to migrate it says that no scheme is found: $ go run ./cmd/ migrate 2022/04/05 16:20:29 no scheme exit…
Jon Leopard
  • 835
  • 1
  • 12
  • 24
6
votes
6 answers

Unable to install golang migrate library on Ubuntu 20.4

Steps followed as in the documentation $ curl -L https://packagecloud.io/golang-migrate/migrate/gpgkey | apt-key add - $ echo "deb https://packagecloud.io/golang-migrate/migrate/ubuntu/ $(lsb_release -sc) main" >…
sajir mohamed
  • 355
  • 1
  • 3
  • 9
6
votes
2 answers

golang-migrate unable to find postgres driver

In my internal/platform/database/database.go import ( "github.com/golang-migrate/migrate" "github.com/jmoiron/sqlx" _ "github.com/lib/pq" ) func RunMigrations() error { m, err := migrate.New( "file://schema", …
pkaramol
  • 16,451
  • 43
  • 149
  • 324
4
votes
1 answer

How can get go-socket.io from github to use in Go

My Go version is: go version go1.12.9 windows/amd64 From this link: https://github.com/googollee/go-socket.io/tree/v1.0 I run this code in cmd: go get github.com/googollee/go-socket.io But i cant run this code : package main import ( "log" …
melina
  • 195
  • 1
  • 8
3
votes
2 answers

Is there no migration file at all in GORM?

If I use GORM, there is no migration file?? So far, I googled and searched for this information, there is no migration file in GORM based on my understanding, and If I want to generate a migration file I have to use CLI. The reason why the GORM…
jjeon17 jjeon17
  • 389
  • 3
  • 10
3
votes
1 answer

Migrate down in golang migrate does not drop tables

I have the following down script named 000001_init_schema.down.sql DROP TABLE IF EXISTS entries; DROP TABLE IF EXISTS transfers; DROP TABLE IF EXISTS accounts; When I run migrate -path db/migrations --database…
pkaramol
  • 16,451
  • 43
  • 149
  • 324
3
votes
1 answer

How to do Migration using golang-migrate

I have a simple application using golang-migrate/migrate with postgresql database. However, I think I receive an error when I call Migration function since my either sourceURL or databaseURL in migrate.New() is invalid memory address or nil…
husky
  • 831
  • 3
  • 10
  • 24
3
votes
0 answers

Is there any way to middleware router with group router?

I am beginner in beego framework, I have completed few R&D inside on it. But I need few helps related routers. I have created few route with middleware and group router but I need few suggestions from expert. Let me share example which I…
kiran malvi
  • 1,058
  • 10
  • 21
2
votes
1 answer

Go Language: I used singleton pattern for a database instance in go. But I'm not able to access the database conn returned by the patter. why?

This is Database config file.config.go type Database struct { conn *sql.DB } // global db instance var ( dbInstance *Database dbOnce sync.Once ) // creates a new database instance if not exist // otherwise return the existing…
2
votes
1 answer

How do I create a table in database only if it does not exists

I need to create a table in Go using gorm only if the table does not exists, I have the following. Generally this is used for REST API and used to make REST Calls package database import ( "fmt" "log" "gorm.io/driver/postgres" …
2
votes
1 answer

Is it possible to auto migrate tables with circular relationships in GORM?

I Been trying to implement the GORM Orm in our Golang project but it seems that I have a slight problem. one of the structs has a circular dependency, so now when I try to AutoMigrate for the tables creation, I get errors since GORM is trying to…
Roman Sterlin
  • 1,485
  • 3
  • 10
  • 25
2
votes
1 answer

Golang migrate installation failing on Ubuntu 22.04 with the following GPG error public key is not available: NO_PUBKEY B53DC80D13EDEF05

I am trying to install Golang Migrate on Ubutu 22.4 and I get the following error while trying to execute the commands. Error public key is not available: NO_PUBKEY B53DC80D13EDEF05 This is what I have tried so far, and it throws the Public Key not…
Chikku Jacob
  • 2,114
  • 1
  • 18
  • 33
2
votes
0 answers

Bulk Upsert in Couchbase with using Golang

I'm new to Golang Please help with understanding I want to use bulk upsert operation via gocb.collection_bulk.go. How does it work if at the time of replacing the document, it will be blocked Is this operation responsible for the moment of blocking…
oliaaa_s
  • 59
  • 5
1
2 3 4 5 6 7 8