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
1
vote
1 answer

How to write a wrapper function for FindOptions in go mongo-driver

I want to write a wrapper function for FindOptions in my dbobject code so that I can avoid importing package options in my service code . Basically i'm trying to accomodate three func under one interface SetSkip() SetLimit() SetSort() so that i…
Gopher_k
  • 273
  • 2
  • 9
1
vote
1 answer

Issues running Find().All() using go mongo-driver

I'm new to mongoDB , Currently we are trying to migrate our old mgo driver to go mongo-driver In our old code we use something like below from global sign mgo driver //where apps is a struct apps := []model.App{} err =…
Gopher_k
  • 273
  • 2
  • 9
1
vote
1 answer

Getting Error 'NoCredentialProviders: no valid providers in chain. Deprecated.' while calling acmpca.GetCertificate() in golang

I am facing error while calling acmpca.GetCertificate() function to get certificate, NoCredentialProviders: no valid providers in chain caused by: EnvAccessKeyNotFound: AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment SharedCredsLoad:…
1
vote
0 answers

Error in multiple insert with sqlmock golang

I am using the sqlmock library to test with mysql's GORM database. However, I have a statement that requires executing an INSERT command multiple times with the same information, so I add my code snippet file_test.go - Mock database func…
1
vote
1 answer

Getting error while fetching certificate from windows certificate store in Golang using `certtostore`?

I want to use certificate bundle from windows certificate store, can anyone please tell me what wrong I am doing here? My Code: package main import ( "fmt" "runtime" "github.com/google/certtostore" ) type certmgr struct { …
1
vote
2 answers

How to write a migration to add not null in table field GOLANG

I want to alter a column in User Model type User struct { gorm.Model Email string `gorm:"unique;type:varchar(50)"` Password string Active bool FirstName string `gorm:"type:varchar(10)"` LastName …
1
vote
2 answers

How to avoid duplicate elements in slice in json validation?

Although I am not a pro-Golang developer, I am trying to restrict the duplicate elements from my array in struct during JSON validation. type Test struct { Test []*string `json:"test" validate:"required,min=1,max=10,excludes=duplicate"` } I am…
1
vote
0 answers

There is already an object named 'company_names' in the database

I use Gorm for Golang like this code, func Connect() (*gorm.DB, error) { var ( err error db *gorm.DB ) dsn := "sqlserver://User:12345@127.0.0.1:1433?database=gorm" db, err = gorm.Open(sqlserver.Open(dsn), &gorm.Config{}) if err != nil { …
sunny
  • 2,670
  • 5
  • 24
  • 39
1
vote
1 answer

Is there a way to achieve postgres table partitioning using gorm v2?

In gorm v2 https://gorm.io/docs/index.html, is there any way to specify that this table is partitioned by some column like https://pg.uptrace.dev/table-partitioning/?
1
vote
1 answer

Is it possible to use SQL IIF function in GORM?

I have a a table for assignments, one for solutions and another for students. I want to retrieve all assignments and against each I want to add a 'flag' showing that the currently logged-in student has attempted the assignment or not. I have tried…
1
vote
2 answers

gorm multiple databases connection management

I have a requirement where my application talks to different databases . How do i manage connections in the gorm. Is there any way gorm supports connection management for multiple database. or i need to create map which holds all database…
user1844634
  • 1,221
  • 2
  • 17
  • 35
1
vote
1 answer

Golang Sql.Open undefined (type string has no field or method Open)

I have below code its giving undefined error on the sql.Open line. unsure how to fix this error. Any help to resolve this error? 79:16 sql.Open undefined (type string has no field or method Open) Process exiting with code: 2 signal: false package…
sfgroups
  • 18,151
  • 28
  • 132
  • 204
1
vote
2 answers

Detecting a development App Server in Go, without the App Engine standalone SDK?

The Go package, google.golang.org/appengine, provides IsDevAppServer which reports whether an App Engine app is running in the development App Server (e.g. localhost:8080). However, this does not work unless the (deprecated) standalone SDK is used.…
Jack
  • 10,313
  • 15
  • 75
  • 118
1
vote
2 answers

Slice display in list with row and column

I have slice with 24 words, I want to display it with 4 row with 6 column in list format. I am trying to implement it in Go. package main import ( "fmt" ) func main() { words := []string{"peace", "note", "vapor", "notice", "meat", "shed",…
Nagaraj M
  • 387
  • 1
  • 5
  • 16
1
vote
0 answers

Unpickling python dict object

I have some data stored in Redis which is saved by python app by pickling the data. So basically this is a pickled python dict object. I want to get this stored data in golang. I found a library :…
skysoft999
  • 540
  • 1
  • 6
  • 27