db, functional: make value column in key not pkey
go-oidc increased the size of the generated keys, which were too large to be used as primary keys in postgres.
This commit is contained in:
parent
71f5021678
commit
c1f8effe1a
5 changed files with 35 additions and 52 deletions
|
@ -27,7 +27,6 @@ func init() {
|
||||||
name: keyTableName,
|
name: keyTableName,
|
||||||
model: privateKeySetBlob{},
|
model: privateKeySetBlob{},
|
||||||
autoinc: false,
|
autoinc: false,
|
||||||
pkey: []string{"value"},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
db/migrations/0009_key_not_primary_key.sql
Normal file
5
db/migrations/0009_key_not_primary_key.sql
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
-- +migrate Up
|
||||||
|
ALTER TABLE key ADD COLUMN tmp_value bytea;
|
||||||
|
UPDATE KEY SET tmp_value = value;
|
||||||
|
ALTER TABLE key DROP COLUMN value;
|
||||||
|
ALTER TABLE key RENAME COLUMN "tmp_value" to "value";
|
File diff suppressed because one or more lines are too long
|
@ -2,5 +2,5 @@ package migrations
|
||||||
|
|
||||||
// To download go-bindata run `go get -u github.com/jteeuwen/go-bindata/...`
|
// To download go-bindata run `go get -u github.com/jteeuwen/go-bindata/...`
|
||||||
|
|
||||||
//go:generate go-bindata -modtime=1 -pkg migrations -o assets.go ../
|
//go:generate go-bindata -modtime=1 -pkg migrations -o assets.go -ignore \.go$ -prefix "../.." ../../db/migrations
|
||||||
//go:generate gofmt -w assets.go
|
//go:generate gofmt -w assets.go
|
||||||
|
|
|
@ -45,7 +45,9 @@ func connect(t *testing.T) *gorp.DbMap {
|
||||||
panic(fmt.Sprintf("Unable to drop migration table: %v", err))
|
panic(fmt.Sprintf("Unable to drop migration table: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
db.MigrateToLatest(c)
|
if _, err = db.MigrateToLatest(c); err != nil {
|
||||||
|
panic(fmt.Sprintf("Unable to migrate: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue