Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Fix migration of the postgres DB #1

Merged
merged 1 commit into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions migrations/1_initial.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ type user struct {
ID int
Username string `sql:"username,notnull,unique"`
Token string `sql:"token"`
ExtraProperties map[string]string `sql:"extraProperties,hstore"`
ExtraProperties map[string]string `sql:"extraProperties" pg:"hstore"`
}

func init() {
migrations.Register(func(db migrations.DB) error {
migrations.RegisterTx(func(db migrations.DB) error {
err := orm.CreateTable(db, &user{}, &orm.CreateTableOptions{
Temp: false,
IfNotExists: true,
Expand Down
2 changes: 1 addition & 1 deletion migrations/2_user_lastquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

func init() {
migrations.Register(func(db migrations.DB) error {
migrations.RegisterTx(func(db migrations.DB) error {
_, err := db.Exec(`ALTER TABLE users ADD lastquery timestamptz`)
return err
}, func(db migrations.DB) error {
Expand Down
5 changes: 1 addition & 4 deletions migrations/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import (
func EnsureCurrentSchema(db *pg.DB) error {
var oldVersion, newVersion int64

err := db.RunInTransaction(func(tx *pg.Tx) (err error) {
oldVersion, newVersion, err = migrations.Run(tx, "")
return
})
oldVersion, newVersion, err := migrations.Run(db, "up")
if err != nil {
return err
}
Expand Down