Skip to content

Commit

Permalink
feat: use golang migrate (#1504)
Browse files Browse the repository at this point in the history
* feat: use golang-migrate for DB migrations

* chore: mechanical changes for migration function

* chore: additional migration tests

* chore: move migration logger to logger package

* chore: cleaned up sql file comments

* chore: don't export migration table
  • Loading branch information
kian99 authored Jan 6, 2025
1 parent b480a9a commit 88482bf
Show file tree
Hide file tree
Showing 75 changed files with 451 additions and 352 deletions.
2 changes: 1 addition & 1 deletion cmd/jimmctl/cmd/purge_logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (s *purgeLogsSuite) TestPurgeLogsFromDb(c *gc.C) {
IdentityTag: names.NewUserTag("alice@canonical.com").String(),
}

err := s.JIMM.Database.Migrate(context.Background(), false)
err := s.JIMM.Database.Migrate(context.Background())
c.Assert(err, gc.IsNil)
err = s.JIMM.Database.AddAuditLogEntry(ctx, &ale)
c.Assert(err, gc.IsNil)
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ services:
OPENFGA_AUTHN_PRESHARED_KEYS: "jimm"
OPENFGA_DATASTORE_ENGINE: "postgres"
OPENFGA_DATASTORE_URI: "postgresql://jimm:jimm@db/jimm?sslmode=disable"
OPENFGA_LOG_LEVEL: "warn"
volumes:
- ./openfga/authorisation_model.fga:/app/authorisation_model.fga
ports:
Expand Down
33 changes: 21 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions v1.3.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.1.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
github.com/Rican7/retry v0.3.1 // indirect
github.com/adrg/xdg v0.3.3 // indirect
Expand Down Expand Up @@ -113,7 +113,7 @@ require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cjlapao/common-go v0.0.39 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/creack/pty v1.1.15 // indirect
github.com/creack/pty v1.1.18 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/distribution/reference v0.5.0 // indirect
Expand All @@ -131,7 +131,7 @@ require (
github.com/getkin/kin-openapi v0.125.0 // indirect
github.com/go-goose/goose/v5 v5.0.0-20230421180421-abaee9096e3a // indirect
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-macaroon-bakery/macaroonpb v1.0.0 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
Expand All @@ -147,13 +147,13 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/renameio v1.0.1 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/googleapis/gax-go/v2 v2.12.2 // indirect
github.com/gorilla/schema v1.4.1 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
Expand Down Expand Up @@ -237,7 +237,7 @@ require (
github.com/lestrrat/go-jsval v0.0.0-20161012045717-b1258a10419f // indirect
github.com/lestrrat/go-pdebug v0.0.0-20160817063333-2e6eaaa5717f // indirect
github.com/lestrrat/go-structinfo v0.0.0-20160308131105-f74c056fe41f // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/lunixbochs/vtclean v1.0.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand All @@ -260,7 +260,7 @@ require (
github.com/mittwald/vaultgo v0.1.4 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/sys/mountinfo v0.7.1 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
Expand Down Expand Up @@ -307,10 +307,10 @@ require (
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/zitadel/oidc/v2 v2.12.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/mock v0.5.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
Expand All @@ -322,7 +322,7 @@ require (
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.26.0 // indirect
google.golang.org/api v0.154.0 // indirect
google.golang.org/api v0.169.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/grpc v1.66.0 // indirect
Expand All @@ -346,6 +346,15 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)

require github.com/golang-migrate/migrate/v4 v4.17.1

require (
github.com/klauspost/compress v1.17.7 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.6.0 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
)

replace (
github.com/altoros/gosigma => github.com/juju/gosigma v0.0.0-20170523021020-a27b59fe2be9
gopkg.in/yaml.v2 => github.com/juju/yaml v0.0.0-20200420012109-12a32b78de07
Expand Down
Loading

0 comments on commit 88482bf

Please sign in to comment.