From 0d72d3f491911b0e8f2af427a65e287324218841 Mon Sep 17 00:00:00 2001 From: Wout Slakhorst Date: Fri, 19 Apr 2024 13:31:00 +0200 Subject: [PATCH 01/13] Change to golang-migrate and add sqlserver --- go.mod | 12 +- go.sum | 46 +++++- storage/engine.go | 144 +++++++++--------- storage/engine_test.go | 11 +- .../sql_migrations/001_credential.down.sql | 2 + ...1_credential.sql => 001_credential.up.sql} | 7 +- .../002_discoveryservice.down.sql | 4 + ...ervice.sql => 002_discoveryservice.up.sql} | 9 +- storage/sql_migrations/003_did.down.sql | 3 + .../{003_did.sql => 003_did.up.sql} | 7 +- ...coveryservice_client_registration.down.sql | 1 + ...scoveryservice_client_registration.up.sql} | 3 - .../sql_migrations/005_statuslist.down.sql | 3 + ...5_statuslist.sql => 005_statuslist.up.sql} | 9 +- storage/sql_migrations/006_wallet.down.sql | 2 + .../{006_wallet.sql => 006_wallet.up.sql} | 7 +- .../007_issued_credential.down.sql | 1 + ...ntial.sql => 007_issued_credential.up.sql} | 6 +- storage/test.go | 11 +- 19 files changed, 162 insertions(+), 126 deletions(-) create mode 100644 storage/sql_migrations/001_credential.down.sql rename storage/sql_migrations/{001_credential.sql => 001_credential.up.sql} (92%) create mode 100644 storage/sql_migrations/002_discoveryservice.down.sql rename storage/sql_migrations/{002_discoveryservice.sql => 002_discoveryservice.up.sql} (95%) create mode 100644 storage/sql_migrations/003_did.down.sql rename storage/sql_migrations/{003_did.sql => 003_did.up.sql} (93%) create mode 100644 storage/sql_migrations/004_discoveryservice_client_registration.down.sql rename storage/sql_migrations/{004_discoveryservice_client_registration.sql => 004_discoveryservice_client_registration.up.sql} (94%) create mode 100644 storage/sql_migrations/005_statuslist.down.sql rename storage/sql_migrations/{005_statuslist.sql => 005_statuslist.up.sql} (96%) create mode 100644 storage/sql_migrations/006_wallet.down.sql rename storage/sql_migrations/{006_wallet.sql => 006_wallet.up.sql} (73%) create mode 100644 storage/sql_migrations/007_issued_credential.down.sql rename storage/sql_migrations/{007_issued_credential.sql => 007_issued_credential.up.sql} (70%) diff --git a/go.mod b/go.mod index a3380bfa98..5bdfdcaf73 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.22 require ( github.com/PaesslerAG/jsonpath v0.1.2-0.20230323094847-3484786d6f97 github.com/alicebob/miniredis/v2 v2.32.1 - github.com/amacneil/dbmate/v2 v2.14.0 github.com/avast/retry-go/v4 v4.6.0 github.com/cbroglie/mustache v1.4.0 github.com/chromedp/chromedp v0.9.5 @@ -168,19 +167,28 @@ require ( ) require ( + github.com/golang-migrate/migrate/v4 v4.17.1 gorm.io/driver/mysql v1.5.6 gorm.io/driver/postgres v1.5.7 + gorm.io/driver/sqlserver v1.5.2 ) require ( filippo.io/edwards25519 v1.1.0 // indirect + github.com/Azure/go-autorest v14.2.0+incompatible // indirect + github.com/Azure/go-autorest/autorest/adal v0.9.16 // indirect + github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect + github.com/Azure/go-autorest/logger v0.2.1 // indirect + github.com/Azure/go-autorest/tracing v0.6.0 // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect + github.com/google/flatbuffers v24.3.25+incompatible // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect github.com/jackc/pgx/v5 v5.5.4 // indirect github.com/jackc/puddle/v2 v2.2.1 // indirect + github.com/joho/godotenv v1.5.1 // indirect github.com/microsoft/go-mssqldb v1.6.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/sync v0.6.0 // indirect - gorm.io/driver/sqlserver v1.5.2 // indirect + golang.org/x/tools v0.19.0 // indirect ) diff --git a/go.sum b/go.sum index ae56911d8a..9f7a7a93d6 100644 --- a/go.sum +++ b/go.sum @@ -17,10 +17,26 @@ github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.0 h1:yfJe15a github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.0/go.mod h1:Q28U+75mpCaSCDowNEmhIo/rmgdkqmkmzI7N6TGR4UY= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v0.8.0 h1:T028gtTPiYt/RMUfs8nVsAL7FDQrfLlrm/NnRG/zcC4= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v0.8.0/go.mod h1:cw4zVQgBby0Z5f2v0itn6se2dDP17nTjbZFXW5uPyHA= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= +github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= +github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= +github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= +github.com/Azure/go-autorest/autorest/adal v0.9.16 h1:P8An8Z9rH1ldbOLdFpxYorgOt2sywL9V24dAwWHPuGc= +github.com/Azure/go-autorest/autorest/adal v0.9.16/go.mod h1:tGMin8I49Yij6AQ+rvV+Xa/zwxYQB5hmsd6DkfAx2+A= +github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= +github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74= +github.com/Azure/go-autorest/autorest/mocks v0.4.1 h1:K0laFcLE6VLTOwNgSxaGbUcLPuGXlNkbVvq4cW4nIHk= +github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= +github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+ZtXWSmf4Tg= +github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= +github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= +github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.0 h1:HCc0+LpPfpCKs6LGGLAhwBARt9632unrVcI6i8s/8os= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.0/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PaesslerAG/gval v1.2.2 h1:Y7iBzhgE09IGTt5QgGQ2IdaYYYOU134YGHBThD+wm9E= @@ -41,8 +57,6 @@ github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGn github.com/alicebob/miniredis/v2 v2.32.1 h1:Bz7CciDnYSaa0mX5xODh6GUITRSx+cVhjNoOR4JssBo= github.com/alicebob/miniredis/v2 v2.32.1/go.mod h1:AqkLNAfUm0K07J28hnAyyQKf/x0YkCY/g5DCtuL01Mw= github.com/alvaroloes/enumer v1.1.2/go.mod h1:FxrjvuXoDAx9isTJrv4c+T410zFi0DtXIT0m65DJ+Wo= -github.com/amacneil/dbmate/v2 v2.14.0 h1:H/bFxk5qbq61NrRE008sKPgMGwMseOQPWsL97vFz+7I= -github.com/amacneil/dbmate/v2 v2.14.0/go.mod h1:RNc+B8o1VQkvd6O5C5Zqs7Jq6MNOQDvPl048bFIjFQo= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= @@ -122,10 +136,20 @@ github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWa github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/dhui/dktest v0.4.1 h1:/w+IWuDXVymg3IrRJCHHOkMK10m9aNVMOyD0X12YVTg= +github.com/dhui/dktest v0.4.1/go.mod h1:DdOqcUpL7vgyP4GlF3X3w7HbSlz8cEQzwewPveYEQbA= github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= +github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v24.0.9+incompatible h1:HPGzNmwfLZWdxHqK9/II92pyi1EpYKsAqcl4G0Of9v0= +github.com/docker/docker v24.0.9+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= +github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= @@ -197,11 +221,14 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/golang-migrate/migrate/v4 v4.17.1 h1:4zQ6iqL6t6AiItphxJctQb3cFqWiSpMnX7wLTPnnYO4= +github.com/golang-migrate/migrate/v4 v4.17.1/go.mod h1:m8hinFyWBn0SA4QKHuKh175Pm9wjmxj3S2Mia7dbXzM= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= @@ -446,12 +473,16 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= +github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= @@ -506,6 +537,10 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= +github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde h1:x0TT0RDC7UhAVbbWWBzr41ElhJx5tXPWkIHA2HWPRuw= github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -648,8 +683,6 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M= github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= -github.com/zenizh/go-capturer v0.0.0-20211219060012-52ea6c8fed04 h1:qXafrlZL1WsJW5OokjraLLRURHiw0OzKHD/RNdspp4w= -github.com/zenizh/go-capturer v0.0.0-20211219060012-52ea6c8fed04/go.mod h1:FiwNQxz6hGoNFBC4nIx+CxZhI3nne5RmIOlT/MXcSD4= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.etcd.io/bbolt v1.3.9 h1:8x7aARPEXiXbHmtUwAIv7eV2fQFHrLLavdiJ3uzJXoI= go.etcd.io/bbolt v1.3.9/go.mod h1:zaO32+Ti0PK1ivdPtgMESzuzL2VPoIG1PCQNvOdo/dE= @@ -674,6 +707,7 @@ golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= @@ -697,6 +731,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -841,6 +877,8 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= +golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/storage/engine.go b/storage/engine.go index 12cc5368d9..17228dbda4 100644 --- a/storage/engine.go +++ b/storage/engine.go @@ -25,25 +25,28 @@ import ( "errors" "fmt" "io" - "net/url" "path" "strings" "sync" "time" + "github.com/golang-migrate/migrate/v4" + migrationDatabase "github.com/golang-migrate/migrate/v4/database" + mysqlMigrate "github.com/golang-migrate/migrate/v4/database/mysql" + postgresMigrate "github.com/golang-migrate/migrate/v4/database/postgres" + sqlLiteMigrate "github.com/golang-migrate/migrate/v4/database/sqlite3" + sqlserverMigrate "github.com/golang-migrate/migrate/v4/database/sqlserver" + "github.com/golang-migrate/migrate/v4/source/iofs" "github.com/nuts-foundation/go-stoabs" "github.com/nuts-foundation/nuts-node/core" "github.com/nuts-foundation/nuts-node/storage/log" "github.com/redis/go-redis/v9" + "github.com/sirupsen/logrus" "gorm.io/driver/mysql" "gorm.io/driver/postgres" "gorm.io/driver/sqlite" + "gorm.io/driver/sqlserver" "gorm.io/gorm" - - "github.com/amacneil/dbmate/v2/pkg/dbmate" - _ "github.com/amacneil/dbmate/v2/pkg/driver/mysql" - _ "github.com/amacneil/dbmate/v2/pkg/driver/postgres" - _ "github.com/amacneil/dbmate/v2/pkg/driver/sqlite" ) const storeShutdownTimeout = 5 * time.Second @@ -73,7 +76,7 @@ type engine struct { sessionDatabase SessionDatabase sqlDB *gorm.DB config Config - sqlMigrationLogger io.Writer + sqlMigrationLogger migrationLogger } func (e *engine) Config() interface{} { @@ -179,84 +182,71 @@ func (e *engine) initSQLDatabase() error { connectionString = sqliteConnectionString(e.datadir) } - // Find right SQL adapter - type sqlAdapter struct { - connector func(sqlDB *sql.DB) gorm.Dialector - } - adapters := map[string]sqlAdapter{ - "sqlite": { - connector: func(sqlDB *sql.DB) gorm.Dialector { - return &sqlite.Dialector{Conn: sqlDB} - }, - }, - "postgres": { - connector: func(sqlDB *sql.DB) gorm.Dialector { - return postgres.New(postgres.Config{Conn: sqlDB}) - }, - }, - "mysql": { - connector: func(sqlDB *sql.DB) gorm.Dialector { - return mysql.New(mysql.Config{Conn: sqlDB}) + // Find right SQL adapter for ORM and migrations + var migrationDriver migrationDatabase.Driver + + dbType := strings.Split(connectionString, ":")[0] + switch dbType { + case "sqlite": + // sqlite3 uses the same driver as gorm + db, err := sql.Open("sqlite3", connectionString[7:]) + if err != nil { + return err + } + // SQLite does not support SELECT FOR UPDATE and allows only 1 active write transaction at any time, + // and any other attempt to acquire a write transaction will directly return an error. + // This is in contrast to most other SQL-databases, which let the 2nd thread wait for some time to acquire the lock. + // The general advice for SQLite is to retry the operation, which is just poor-man's scheduling. + // So to keep behavior consistent across databases, we'll just limit the number connections to 1 if it's a SQLite store. + // With 1 connection, all actions will be performed sequentially. This impacts performance, but SQLite should not be used in production. + // See https://github.com/nuts-foundation/nuts-node/pull/2589#discussion_r1399130608 + db.SetMaxOpenConns(1) + migrationDriver, _ = sqlLiteMigrate.WithInstance(db, &sqlLiteMigrate.Config{}) + dialector := sqlite.Dialector{Conn: db} + e.sqlDB, err = gorm.Open(dialector, &gorm.Config{ + TranslateError: true, + Logger: gormLogrusLogger{ + underlying: log.Logger(), + slowThreshold: sqlSlowQueryThreshold, }, - }, - } - var adapter *sqlAdapter - for prefix, curr := range adapters { - if strings.HasPrefix(connectionString, prefix+":") { - adapter = &curr - break + }) + if err != nil { + return err } - } - if adapter == nil { + case "mysql": + db, _ := sql.Open("mysql", connectionString) + migrationDriver, _ = mysqlMigrate.WithInstance(db, &mysqlMigrate.Config{}) + e.sqlDB, _ = gorm.Open(mysql.New(mysql.Config{ + Conn: db, + }), &gorm.Config{}) + case "postgres": + db, _ := sql.Open("postgresql", connectionString) + migrationDriver, _ = postgresMigrate.WithInstance(db, &postgresMigrate.Config{}) + e.sqlDB, _ = gorm.Open(postgres.New(postgres.Config{ + Conn: db, + }), &gorm.Config{}) + case "sqlserver": + db, _ := sql.Open("sqlserver", connectionString) + migrationDriver, _ = sqlserverMigrate.WithInstance(db, &sqlserverMigrate.Config{}) + e.sqlDB, _ = gorm.Open(sqlserver.New(sqlserver.Config{ + Conn: db, + }), &gorm.Config{}) + default: return errors.New("unsupported SQL database") } // Open connection and migrate var err error - connectionURL, err := url.Parse(connectionString) - if err != nil { - return err - } - dbMigrator := dbmate.New(connectionURL) - migratorDriver, err := dbMigrator.Driver() - if err != nil { - return err - } - sqlDB, err := migratorDriver.Open() + embeddedSource, err := iofs.New(sqlMigrationsFS, "sql_migrations") if err != nil { return err } - if strings.HasPrefix(connectionString, "sqlite:") { - // SQLite does not support SELECT FOR UPDATE and allows only 1 active write transaction at any time, - // and any other attempt to acquire a write transaction will directly return an error. - // This is in contrast to most other SQL-databases, which let the 2nd thread wait for some time to acquire the lock. - // The general advice for SQLite is to retry the operation, which is just poor-man's scheduling. - // So to keep behavior consistent across databases, we'll just limit the number connections to 1 if it's a SQLite store. - // With 1 connection, all actions will be performed sequentially. This impacts performance, but SQLite should not be used in production. - // See https://github.com/nuts-foundation/nuts-node/pull/2589#discussion_r1399130608 - sqlDB.SetMaxOpenConns(1) - } + dbMigrator, err := migrate.NewWithInstance("embedded", embeddedSource, dbType, migrationDriver) log.Logger().Debug("Running database migrations...") - - // we need the connectionString with adapter specific prefix here - dbMigrator.FS = sqlMigrationsFS - dbMigrator.MigrationsDir = []string{"sql_migrations"} - dbMigrator.AutoDumpSchema = false dbMigrator.Log = e.sqlMigrationLogger - if err = dbMigrator.CreateAndMigrate(); err != nil { + if err = dbMigrator.Up(); err != nil && !errors.Is(err, migrate.ErrNoChange) { return fmt.Errorf("failed to migrate database: %w", err) } - - e.sqlDB, err = gorm.Open(adapter.connector(sqlDB), &gorm.Config{ - TranslateError: true, - Logger: gormLogrusLogger{ - underlying: log.Logger(), - slowThreshold: sqlSlowQueryThreshold, - }, - }) - if err != nil { - return err - } return nil } @@ -319,6 +309,10 @@ func (p *provider) getStore(moduleName string, name string, adapter database) (s return store, err } +type migrationLogger interface { + migrate.Logger + io.Writer +} type logrusInfoLogWriter struct { } @@ -326,3 +320,11 @@ func (m logrusInfoLogWriter) Write(p []byte) (n int, err error) { log.Logger().Info(string(p)) return len(p), nil } + +func (m logrusInfoLogWriter) Printf(format string, v ...interface{}) { + log.Logger().Info(fmt.Sprintf(format, v...)) +} + +func (m logrusInfoLogWriter) Verbose() bool { + return log.Logger().Level >= logrus.DebugLevel +} diff --git a/storage/engine_test.go b/storage/engine_test.go index 4766c85053..737e60d756 100644 --- a/storage/engine_test.go +++ b/storage/engine_test.go @@ -117,7 +117,7 @@ func Test_engine_sqlDatabase(t *testing.T) { require.NoError(t, os.Remove(dataDir)) e := New() err := e.Configure(core.ServerConfig{Datadir: dataDir}) - assert.ErrorContains(t, err, "failed to initialize SQL database: failed to migrate database: unable to open database file") + assert.ErrorContains(t, err, "unable to open database file") }) t.Run("sqlite is restricted to 1 connection", func(t *testing.T) { e := New() @@ -163,11 +163,12 @@ func Test_engine_sqlDatabase(t *testing.T) { underlyingDB, err := e.GetSQLDatabase().DB() require.NoError(t, err) - row := underlyingDB.QueryRow("SELECT count(*) FROM schema_migrations") + row := underlyingDB.QueryRow("SELECT * FROM schema_migrations") require.NoError(t, row.Err()) - var count int - assert.NoError(t, row.Scan(&count)) - assert.Equal(t, len(sqlFiles), count) + var version int + var dirty bool + assert.NoError(t, row.Scan(&version, &dirty)) + assert.Equal(t, len(sqlFiles)/2, version) // up and down migration files }) t.Run("unsupported protocol doesn't log secrets", func(t *testing.T) { dataDir := io.TestDirectory(t) diff --git a/storage/sql_migrations/001_credential.down.sql b/storage/sql_migrations/001_credential.down.sql new file mode 100644 index 0000000000..ebcd59e337 --- /dev/null +++ b/storage/sql_migrations/001_credential.down.sql @@ -0,0 +1,2 @@ +drop table credential; +drop table credential_prop; diff --git a/storage/sql_migrations/001_credential.sql b/storage/sql_migrations/001_credential.up.sql similarity index 92% rename from storage/sql_migrations/001_credential.sql rename to storage/sql_migrations/001_credential.up.sql index bd76078641..59a545e3aa 100644 --- a/storage/sql_migrations/001_credential.sql +++ b/storage/sql_migrations/001_credential.up.sql @@ -1,4 +1,3 @@ --- migrate:up create table credential ( id varchar(415) not null primary key, @@ -21,8 +20,4 @@ create table credential_prop PRIMARY KEY (credential_id, path), -- cascading delete: if the presentation gets deleted, the properties get deleted as well constraint fk_discovery_credential_id foreign key (credential_id) references credential (id) on delete cascade -); - --- migrate:down -drop table credential; -drop table credential_prop; +); \ No newline at end of file diff --git a/storage/sql_migrations/002_discoveryservice.down.sql b/storage/sql_migrations/002_discoveryservice.down.sql new file mode 100644 index 0000000000..a15d73f0f9 --- /dev/null +++ b/storage/sql_migrations/002_discoveryservice.down.sql @@ -0,0 +1,4 @@ +drop table discovery_service; +drop table discovery_presentation; +drop table discovery_credential; + diff --git a/storage/sql_migrations/002_discoveryservice.sql b/storage/sql_migrations/002_discoveryservice.up.sql similarity index 95% rename from storage/sql_migrations/002_discoveryservice.sql rename to storage/sql_migrations/002_discoveryservice.up.sql index f1707c3171..d0c13e4c6e 100644 --- a/storage/sql_migrations/002_discoveryservice.sql +++ b/storage/sql_migrations/002_discoveryservice.up.sql @@ -1,4 +1,3 @@ --- migrate:up -- discovery contains the known discovery services and the associated tags. create table discovery_service ( @@ -40,10 +39,4 @@ create table discovery_credential credential_id varchar(415) not null, constraint fk_discovery_credential_presentation foreign key (presentation_id) references discovery_presentation (id) on delete cascade, constraint fk_discovery_credential foreign key (credential_id) references credential (id) -); - --- migrate:down -drop table discovery_service; -drop table discovery_presentation; -drop table discovery_credential; - +); \ No newline at end of file diff --git a/storage/sql_migrations/003_did.down.sql b/storage/sql_migrations/003_did.down.sql new file mode 100644 index 0000000000..80dbc8e543 --- /dev/null +++ b/storage/sql_migrations/003_did.down.sql @@ -0,0 +1,3 @@ +drop table did; +drop table did_verificationmethod; +drop table did_service; \ No newline at end of file diff --git a/storage/sql_migrations/003_did.sql b/storage/sql_migrations/003_did.up.sql similarity index 93% rename from storage/sql_migrations/003_did.sql rename to storage/sql_migrations/003_did.up.sql index fc413a232f..034ffe2f76 100644 --- a/storage/sql_migrations/003_did.sql +++ b/storage/sql_migrations/003_did.up.sql @@ -33,9 +33,4 @@ create table did_service data text not null, primary key (id), foreign key (did) references did (did) on delete cascade -); - --- migrate:down -drop table did; -drop table did_verificationmethod; -drop table did_service; \ No newline at end of file +); \ No newline at end of file diff --git a/storage/sql_migrations/004_discoveryservice_client_registration.down.sql b/storage/sql_migrations/004_discoveryservice_client_registration.down.sql new file mode 100644 index 0000000000..671db016ab --- /dev/null +++ b/storage/sql_migrations/004_discoveryservice_client_registration.down.sql @@ -0,0 +1 @@ +drop table discovery_presentation_refresh; diff --git a/storage/sql_migrations/004_discoveryservice_client_registration.sql b/storage/sql_migrations/004_discoveryservice_client_registration.up.sql similarity index 94% rename from storage/sql_migrations/004_discoveryservice_client_registration.sql rename to storage/sql_migrations/004_discoveryservice_client_registration.up.sql index a1a71bb812..be5b00b061 100644 --- a/storage/sql_migrations/004_discoveryservice_client_registration.sql +++ b/storage/sql_migrations/004_discoveryservice_client_registration.up.sql @@ -15,6 +15,3 @@ create table discovery_presentation_refresh ); -- index for the next_registration column, used when checking which registrations need to be refreshed create index idx_discovery_presentation_refresh on discovery_presentation_refresh (next_refresh); - --- migrate:down -drop table discovery_presentation_refresh; diff --git a/storage/sql_migrations/005_statuslist.down.sql b/storage/sql_migrations/005_statuslist.down.sql new file mode 100644 index 0000000000..9964dcb079 --- /dev/null +++ b/storage/sql_migrations/005_statuslist.down.sql @@ -0,0 +1,3 @@ +drop table status_list_credential; +drop table status_list; +drop table status_list_entry; diff --git a/storage/sql_migrations/005_statuslist.sql b/storage/sql_migrations/005_statuslist.up.sql similarity index 96% rename from storage/sql_migrations/005_statuslist.sql rename to storage/sql_migrations/005_statuslist.up.sql index 417062e543..73837eb015 100644 --- a/storage/sql_migrations/005_statuslist.sql +++ b/storage/sql_migrations/005_statuslist.up.sql @@ -1,5 +1,3 @@ --- migrate:up - -- status_list_credential: latest version of known credentials. create table status_list_credential ( @@ -50,9 +48,4 @@ create table status_list_entry constraint status_list_entry_id primary key (status_list_credential, status_list_index), -- Ties the status_list_credential to an issuer (did) via the status_list_issuer table constraint fk_status_list_credential foreign key (status_list_credential) references status_list (subject_id) on delete cascade -); - --- migrate:down -drop table status_list_credential; -drop table status_list; -drop table status_list_entry; +); \ No newline at end of file diff --git a/storage/sql_migrations/006_wallet.down.sql b/storage/sql_migrations/006_wallet.down.sql new file mode 100644 index 0000000000..b4628a5569 --- /dev/null +++ b/storage/sql_migrations/006_wallet.down.sql @@ -0,0 +1,2 @@ +drop index idx_wallet_holder_did; +drop table wallet_credential; diff --git a/storage/sql_migrations/006_wallet.sql b/storage/sql_migrations/006_wallet.up.sql similarity index 73% rename from storage/sql_migrations/006_wallet.sql rename to storage/sql_migrations/006_wallet.up.sql index 5fe2824e34..086b38ad26 100644 --- a/storage/sql_migrations/006_wallet.sql +++ b/storage/sql_migrations/006_wallet.up.sql @@ -1,4 +1,3 @@ --- migrate:up create table wallet_credential ( credential_id varchar(415) not null, @@ -6,8 +5,4 @@ create table wallet_credential constraint fk_wallet_credential foreign key (credential_id) references credential (id) ); -create index idx_wallet_holder_did on wallet_credential (holder_did); - --- migrate:down -drop index idx_wallet_holder_did; -drop table wallet_credential; +create index idx_wallet_holder_did on wallet_credential (holder_did); \ No newline at end of file diff --git a/storage/sql_migrations/007_issued_credential.down.sql b/storage/sql_migrations/007_issued_credential.down.sql new file mode 100644 index 0000000000..a15db60318 --- /dev/null +++ b/storage/sql_migrations/007_issued_credential.down.sql @@ -0,0 +1 @@ +drop table issued_credential; diff --git a/storage/sql_migrations/007_issued_credential.sql b/storage/sql_migrations/007_issued_credential.up.sql similarity index 70% rename from storage/sql_migrations/007_issued_credential.sql rename to storage/sql_migrations/007_issued_credential.up.sql index 9649ce0325..4c53aface3 100644 --- a/storage/sql_migrations/007_issued_credential.sql +++ b/storage/sql_migrations/007_issued_credential.up.sql @@ -1,9 +1,5 @@ --- migrate:up create table issued_credential ( id varchar(415) not null primary key, constraint fk_issued_credential foreign key (id) references credential (id) -); - --- migrate:down -drop table issued_credential; +); \ No newline at end of file diff --git a/storage/test.go b/storage/test.go index 1e41a51aa6..e537d9e750 100644 --- a/storage/test.go +++ b/storage/test.go @@ -23,7 +23,6 @@ import ( "errors" "github.com/nuts-foundation/go-stoabs" "github.com/nuts-foundation/nuts-node/test/io" - stdIO "io" "testing" "github.com/nuts-foundation/go-did/did" @@ -37,7 +36,7 @@ func NewTestStorageEngineInDir(t testing.TB, dir string) Engine { result := New().(*engine) // Prevent dbmate and gorm from logging database creation and applied schema migrations. // These are logged on INFO, which is good for production but annoying in unit tests. - result.sqlMigrationLogger = stdIO.Discard + result.sqlMigrationLogger = nilWriter{} result.config.SQL = SQLConfig{ConnectionString: sqliteConnectionString(dir)} err := result.Configure(core.TestServerConfig(func(config *core.ServerConfig) { @@ -100,3 +99,11 @@ func AddDIDtoSQLDB(t testing.TB, db *gorm.DB, dids ...did.DID) { require.NoError(t, db.Exec("INSERT INTO did ( did ) VALUES ( ? )", id.String()).Error) } } + +type nilWriter struct{} + +func (m nilWriter) Write(p []byte) (n int, err error) { return len(p), nil } + +func (m nilWriter) Printf(format string, v ...interface{}) {} + +func (m nilWriter) Verbose() bool { return false } From 6abcc86dd54ed147236ea07d51898f32ab070711 Mon Sep 17 00:00:00 2001 From: Joris Scharp Date: Mon, 22 Apr 2024 13:41:01 +0200 Subject: [PATCH 02/13] Added e2e test for sqlserver. Unfortunately the test still fails due to missing batch functionality (see https://github.com/golang-migrate/migrate/issues/756 & https://github.com/golang-migrate/migrate/pull/666). Also added 2 missing drop index statements in the golang-migrate down scripts. --- e2e-tests/oauth-flow/rfc021/README.md | 4 ++-- e2e-tests/oauth-flow/rfc021/run-test.sh | 3 ++- e2e-tests/oauth-flow/rfc021/sqlserver.sh | 4 ++++ e2e-tests/oauth-flow/rfc021/sqlserver.yml | 21 +++++++++++++++++++ .../002_discoveryservice.down.sql | 1 + ...coveryservice_client_registration.down.sql | 1 + 6 files changed, 31 insertions(+), 3 deletions(-) create mode 100755 e2e-tests/oauth-flow/rfc021/sqlserver.sh create mode 100644 e2e-tests/oauth-flow/rfc021/sqlserver.yml diff --git a/e2e-tests/oauth-flow/rfc021/README.md b/e2e-tests/oauth-flow/rfc021/README.md index 84ba5f1808..0f9901e968 100644 --- a/e2e-tests/oauth-flow/rfc021/README.md +++ b/e2e-tests/oauth-flow/rfc021/README.md @@ -1,3 +1,3 @@ This test can be executed against multiple SQL databases. -It's executed (by running `./run-test.sh`) on all supported databases (postgres, sqlite, mysql) by default. -To perform the test on a specific database, run `./do-test.sh ` where `` is one of the supported databases (postgres, sqlite, mysql). +It's executed (by running `./run-test.sh`) on all supported databases (postgres, sqlite, mysql, sqlserver) by default. +To perform the test on a specific database, run `./do-test.sh ` where `` is one of the supported databases (postgres, sqlite, mysql, sqlserver). diff --git a/e2e-tests/oauth-flow/rfc021/run-test.sh b/e2e-tests/oauth-flow/rfc021/run-test.sh index 3f5ffb24e2..9811e1b29c 100755 --- a/e2e-tests/oauth-flow/rfc021/run-test.sh +++ b/e2e-tests/oauth-flow/rfc021/run-test.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash ./do-test.sh postgres ./do-test.sh mysql -./do-test.sh sqlite \ No newline at end of file +./do-test.sh sqlite +./do-test.sh sqlserver \ No newline at end of file diff --git a/e2e-tests/oauth-flow/rfc021/sqlserver.sh b/e2e-tests/oauth-flow/rfc021/sqlserver.sh new file mode 100755 index 0000000000..292700fc6c --- /dev/null +++ b/e2e-tests/oauth-flow/rfc021/sqlserver.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +function createDB { + $1 exec db /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'MyStrong(!)Password' -Q "CREATE DATABASE node_a; CREATE DATABASE node_b;" +} \ No newline at end of file diff --git a/e2e-tests/oauth-flow/rfc021/sqlserver.yml b/e2e-tests/oauth-flow/rfc021/sqlserver.yml new file mode 100644 index 0000000000..653a7a94a8 --- /dev/null +++ b/e2e-tests/oauth-flow/rfc021/sqlserver.yml @@ -0,0 +1,21 @@ +services: + nodeA-backend: + environment: + NUTS_STORAGE_SQL_CONNECTION: sqlserver://sa:MyStrong(!)Password@db:1433/node_a?sslmode=disable + nodeB-backend: + environment: + NUTS_STORAGE_SQL_CONNECTION: sqlserver://sa:MyStrong(!)Password@db:1433/node_b?sslmode=disable + db: + image: mcr.microsoft.com/mssql/server:2022-latest + restart: always + ports: + - "1433:1433" + environment: + MSSQL_SA_PASSWORD: MyStrong(!)Password + ACCEPT_EULA: Y + healthcheck: + test: + ["CMD", "/opt/mssql-tools/bin/sqlcmd", "-U", "sa", "-P", "MyStrong(!)Password", "-Q", "SELECT 1"] + interval: 10s + timeout: 5s + retries: 5 diff --git a/storage/sql_migrations/002_discoveryservice.down.sql b/storage/sql_migrations/002_discoveryservice.down.sql index a15d73f0f9..8e2e96e20e 100644 --- a/storage/sql_migrations/002_discoveryservice.down.sql +++ b/storage/sql_migrations/002_discoveryservice.down.sql @@ -1,3 +1,4 @@ +drop index idx_discovery_presentation_expiration; drop table discovery_service; drop table discovery_presentation; drop table discovery_credential; diff --git a/storage/sql_migrations/004_discoveryservice_client_registration.down.sql b/storage/sql_migrations/004_discoveryservice_client_registration.down.sql index 671db016ab..f37852f67f 100644 --- a/storage/sql_migrations/004_discoveryservice_client_registration.down.sql +++ b/storage/sql_migrations/004_discoveryservice_client_registration.down.sql @@ -1 +1,2 @@ +drop index idx_discovery_presentation_refresh drop table discovery_presentation_refresh; From a5ba1c15ec38a40a8f12bee06ede53574be12bb1 Mon Sep 17 00:00:00 2001 From: Wout Slakhorst Date: Tue, 23 Apr 2024 09:34:24 +0200 Subject: [PATCH 03/13] switch to goose --- e2e-tests/oauth-flow/rfc021/mysql.yml | 4 + e2e-tests/oauth-flow/rfc021/postgres.yml | 4 + e2e-tests/oauth-flow/rfc021/sqlserver.yml | 11 +- go.mod | 32 +++-- go.sum | 125 ++++++++++-------- storage/engine.go | 70 +++++----- storage/engine_test.go | 19 ++- .../sql_migrations/001_credential.down.sql | 2 - ...1_credential.up.sql => 001_credential.sql} | 7 +- .../002_discoveryservice.down.sql | 5 - ...ervice.up.sql => 002_discoveryservice.sql} | 8 +- storage/sql_migrations/003_did.down.sql | 3 - .../{003_did.up.sql => 003_did.sql} | 9 +- ...coveryservice_client_registration.down.sql | 2 - ..._discoveryservice_client_registration.sql} | 5 +- .../sql_migrations/005_statuslist.down.sql | 3 - ...5_statuslist.up.sql => 005_statuslist.sql} | 8 +- storage/sql_migrations/006_wallet.down.sql | 2 - .../{006_wallet.up.sql => 006_wallet.sql} | 7 +- .../007_issued_credential.down.sql | 1 - ...ntial.up.sql => 007_issued_credential.sql} | 6 +- storage/sql_migrations/assets.go | 6 + 22 files changed, 200 insertions(+), 139 deletions(-) delete mode 100644 storage/sql_migrations/001_credential.down.sql rename storage/sql_migrations/{001_credential.up.sql => 001_credential.sql} (92%) delete mode 100644 storage/sql_migrations/002_discoveryservice.down.sql rename storage/sql_migrations/{002_discoveryservice.up.sql => 002_discoveryservice.sql} (95%) delete mode 100644 storage/sql_migrations/003_did.down.sql rename storage/sql_migrations/{003_did.up.sql => 003_did.sql} (92%) delete mode 100644 storage/sql_migrations/004_discoveryservice_client_registration.down.sql rename storage/sql_migrations/{004_discoveryservice_client_registration.up.sql => 004_discoveryservice_client_registration.sql} (93%) delete mode 100644 storage/sql_migrations/005_statuslist.down.sql rename storage/sql_migrations/{005_statuslist.up.sql => 005_statuslist.sql} (96%) delete mode 100644 storage/sql_migrations/006_wallet.down.sql rename storage/sql_migrations/{006_wallet.up.sql => 006_wallet.sql} (73%) delete mode 100644 storage/sql_migrations/007_issued_credential.down.sql rename storage/sql_migrations/{007_issued_credential.up.sql => 007_issued_credential.sql} (71%) create mode 100644 storage/sql_migrations/assets.go diff --git a/e2e-tests/oauth-flow/rfc021/mysql.yml b/e2e-tests/oauth-flow/rfc021/mysql.yml index 3ef7d3f84f..71ce38829e 100644 --- a/e2e-tests/oauth-flow/rfc021/mysql.yml +++ b/e2e-tests/oauth-flow/rfc021/mysql.yml @@ -1,8 +1,12 @@ services: nodeA-backend: + depends_on: + - db environment: NUTS_STORAGE_SQL_CONNECTION: mysql://root:root@db:3306/node_a?charset=utf8mb4&parseTime=True&loc=Local nodeB-backend: + depends_on: + - db environment: NUTS_STORAGE_SQL_CONNECTION: mysql://root:root@db:3306/node_b?charset=utf8mb4&parseTime=True&loc=Local db: diff --git a/e2e-tests/oauth-flow/rfc021/postgres.yml b/e2e-tests/oauth-flow/rfc021/postgres.yml index 1c5bbb1972..440cda2134 100644 --- a/e2e-tests/oauth-flow/rfc021/postgres.yml +++ b/e2e-tests/oauth-flow/rfc021/postgres.yml @@ -1,8 +1,12 @@ services: nodeA-backend: + depends_on: + - db environment: NUTS_STORAGE_SQL_CONNECTION: postgres://postgres:postgres@db:5432/node_a?sslmode=disable nodeB-backend: + depends_on: + - db environment: NUTS_STORAGE_SQL_CONNECTION: postgres://postgres:postgres@db:5432/node_b?sslmode=disable db: diff --git a/e2e-tests/oauth-flow/rfc021/sqlserver.yml b/e2e-tests/oauth-flow/rfc021/sqlserver.yml index 653a7a94a8..4ee45a2a96 100644 --- a/e2e-tests/oauth-flow/rfc021/sqlserver.yml +++ b/e2e-tests/oauth-flow/rfc021/sqlserver.yml @@ -1,21 +1,26 @@ services: nodeA-backend: + depends_on: + - db environment: NUTS_STORAGE_SQL_CONNECTION: sqlserver://sa:MyStrong(!)Password@db:1433/node_a?sslmode=disable nodeB-backend: + depends_on: + - db environment: NUTS_STORAGE_SQL_CONNECTION: sqlserver://sa:MyStrong(!)Password@db:1433/node_b?sslmode=disable db: - image: mcr.microsoft.com/mssql/server:2022-latest + image: mcr.microsoft.com/azure-sql-edge:latest restart: always ports: - "1433:1433" environment: + MSSQL_USER: SA MSSQL_SA_PASSWORD: MyStrong(!)Password ACCEPT_EULA: Y healthcheck: test: ["CMD", "/opt/mssql-tools/bin/sqlcmd", "-U", "sa", "-P", "MyStrong(!)Password", "-Q", "SELECT 1"] - interval: 10s + interval: 2s timeout: 5s - retries: 5 + retries: 10 diff --git a/go.mod b/go.mod index 5bdfdcaf73..84dd852bd7 100644 --- a/go.mod +++ b/go.mod @@ -110,11 +110,9 @@ require ( github.com/lestrrat-go/httprc v1.0.5 // indirect github.com/lestrrat-go/iter v1.0.2 // indirect github.com/lestrrat-go/option v1.0.1 // indirect - github.com/lib/pq v1.10.9 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-sqlite3 v1.14.22 // indirect github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect github.com/minio/highwayhash v1.0.2 // indirect @@ -161,34 +159,42 @@ require ( golang.org/x/text v0.14.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240325203815-454cdb8f5daa // indirect gopkg.in/Regis24GmbH/go-diacritics.v2 v2.0.3 // indirect - gorm.io/driver/sqlite v1.5.5 gorm.io/gorm v1.25.9 rsc.io/qr v0.2.0 // indirect ) require ( + github.com/glebarez/sqlite v1.11.0 github.com/golang-migrate/migrate/v4 v4.17.1 + github.com/pressly/goose/v3 v3.20.0 gorm.io/driver/mysql v1.5.6 gorm.io/driver/postgres v1.5.7 gorm.io/driver/sqlserver v1.5.2 + modernc.org/sqlite v1.29.8 ) require ( filippo.io/edwards25519 v1.1.0 // indirect - github.com/Azure/go-autorest v14.2.0+incompatible // indirect - github.com/Azure/go-autorest/autorest/adal v0.9.16 // indirect - github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect - github.com/Azure/go-autorest/logger v0.2.1 // indirect - github.com/Azure/go-autorest/tracing v0.6.0 // indirect + github.com/glebarez/go-sqlite v1.21.2 // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect github.com/google/flatbuffers v24.3.25+incompatible // indirect + github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect - github.com/jackc/pgx/v5 v5.5.4 // indirect + github.com/jackc/pgx/v5 v5.5.5 // indirect github.com/jackc/puddle/v2 v2.2.1 // indirect github.com/joho/godotenv v1.5.1 // indirect - github.com/microsoft/go-mssqldb v1.6.0 // indirect - golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/tools v0.19.0 // indirect + github.com/mfridman/interpolate v0.0.2 // indirect + github.com/microsoft/go-mssqldb v1.7.0 // indirect + github.com/ncruces/go-strftime v0.1.9 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect + github.com/sethvargo/go-retry v0.2.4 // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/sync v0.7.0 // indirect + modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect + modernc.org/libc v1.49.3 // indirect + modernc.org/mathutil v1.6.0 // indirect + modernc.org/memory v1.8.0 // indirect + modernc.org/strutil v1.2.0 // indirect + modernc.org/token v1.1.0 // indirect ) diff --git a/go.sum b/go.sum index 9f7a7a93d6..9742c2eee0 100644 --- a/go.sum +++ b/go.sum @@ -5,38 +5,28 @@ filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4 github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1 h1:/iHxaJhsFr0+xVFfbMr5vxz848jyiWuIEDhYq3y5odY= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 h1:lGlwhPtrX6EVml1hO0ivjkUxsSyl4dsiw9qcA1k/3IQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1/go.mod h1:RKUqNu35KJYcVG/fqTRqmuXJZYNhYkBrnC/hX7yGbTA= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1 h1:sO0/P7g68FrryJzljemN+6GTssUXdANk6aJ7T1ZxnsQ= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1/go.mod h1:h8hyGFDsU5HMivxiS2iYFZsgDbU9OnnJ163x5UGVKYo= github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= -github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.0 h1:yfJe15aSwEQ6Oo6J+gdfdulPNoZ3TEhmbhLIoxZcA+U= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 h1:6oNBlSdi1QqM1PNW7FPA6xOGA5UNsXnkaYZz9vdPGhA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.0/go.mod h1:Q28U+75mpCaSCDowNEmhIo/rmgdkqmkmzI7N6TGR4UY= -github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v0.8.0 h1:T028gtTPiYt/RMUfs8nVsAL7FDQrfLlrm/NnRG/zcC4= +github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.1 h1:MyVTgWR8qd/Jw1Le0NZebGBUCLbtak3bJ3z1OlqZBpw= +github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.1/go.mod h1:GpPjLhVR9dnUoJMyHWSPy71xY9/lcmpzIPZXmF0FCVY= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v0.8.0/go.mod h1:cw4zVQgBby0Z5f2v0itn6se2dDP17nTjbZFXW5uPyHA= -github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= -github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= -github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= -github.com/Azure/go-autorest/autorest/adal v0.9.16 h1:P8An8Z9rH1ldbOLdFpxYorgOt2sywL9V24dAwWHPuGc= -github.com/Azure/go-autorest/autorest/adal v0.9.16/go.mod h1:tGMin8I49Yij6AQ+rvV+Xa/zwxYQB5hmsd6DkfAx2+A= -github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= -github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74= -github.com/Azure/go-autorest/autorest/mocks v0.4.1 h1:K0laFcLE6VLTOwNgSxaGbUcLPuGXlNkbVvq4cW4nIHk= -github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= -github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+ZtXWSmf4Tg= -github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= -github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= -github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= +github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0 h1:D3occbWoio4EBLkbkevetNMAVX197GkzbUMtqjGWn80= +github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0/go.mod h1:bTSOgj05NGRuHHhQwAdPnYr9TOdNmKlZTgGLL6nyAdI= github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.0 h1:HCc0+LpPfpCKs6LGGLAhwBARt9632unrVcI6i8s/8os= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.0/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaCgOUdVHxE8QB52S6NiVdDQvGlny1qvPqA= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PaesslerAG/gval v1.2.2 h1:Y7iBzhgE09IGTt5QgGQ2IdaYYYOU134YGHBThD+wm9E= @@ -136,20 +126,10 @@ github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWa github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/dhui/dktest v0.4.1 h1:/w+IWuDXVymg3IrRJCHHOkMK10m9aNVMOyD0X12YVTg= -github.com/dhui/dktest v0.4.1/go.mod h1:DdOqcUpL7vgyP4GlF3X3w7HbSlz8cEQzwewPveYEQbA= github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= -github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= -github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v24.0.9+incompatible h1:HPGzNmwfLZWdxHqK9/II92pyi1EpYKsAqcl4G0Of9v0= -github.com/docker/docker v24.0.9+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= -github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= @@ -175,6 +155,10 @@ github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmV github.com/fxamacker/cbor v1.5.1 h1:XjQWBgdmQyqimslUh5r4tUGmoqzHmBFQOImkWGi2awg= github.com/fxamacker/cbor v1.5.1/go.mod h1:3aPGItF174ni7dDzd6JZ206H8cmr4GDNBGpPa971zsU= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo= +github.com/glebarez/go-sqlite v1.21.2/go.mod h1:sfxdZyhQjTM2Wry3gVYWaW072Ri1WMdWJi0k6+3382k= +github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw= +github.com/glebarez/sqlite v1.11.0/go.mod h1:h8/o8j5wiAsqSPoWELDUdJXhjAhsVliSn7bWZjOhrgQ= github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk= github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-co-op/gocron v1.28.3 h1:swTsge6u/1Ei51b9VLMz/YTzEzWpbsk5SiR7m5fklTI= @@ -221,12 +205,12 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw= +github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang-migrate/migrate/v4 v4.17.1 h1:4zQ6iqL6t6AiItphxJctQb3cFqWiSpMnX7wLTPnnYO4= github.com/golang-migrate/migrate/v4 v4.17.1/go.mod h1:m8hinFyWBn0SA4QKHuKh175Pm9wjmxj3S2Mia7dbXzM= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA= @@ -278,6 +262,8 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd h1:gbpYu9NMq8jhDVbvlGkMFWCjLFlqqEZjEmObmhUy6Vo= +github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -330,6 +316,8 @@ github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= @@ -351,8 +339,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgx/v5 v5.5.4 h1:Xp2aQS8uXButQdnCMWNmvx6UysWQQC+u1EoizjguY+8= -github.com/jackc/pgx/v5 v5.5.4/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= +github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw= +github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= @@ -418,8 +406,6 @@ github.com/lestrrat-go/jwx/v2 v2.0.21 h1:jAPKupy4uHgrHFEdjVjNkUgoBKtVDgrQPB/h55F github.com/lestrrat-go/jwx/v2 v2.0.21/go.mod h1:09mLW8zto6bWL9GbwnqAli+ArLf+5M33QLQPDggkUWM= github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU= github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= -github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= -github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= @@ -442,10 +428,13 @@ github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxU github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mdp/qrterminal/v3 v3.2.0 h1:qteQMXO3oyTK4IHwj2mWsKYYRBOp1Pj2WRYFYYNTCdk= github.com/mdp/qrterminal/v3 v3.2.0/go.mod h1:XGGuua4Lefrl7TLEsSONiD+UEjQXJZ4mPzF+gWYIJkk= +github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY= +github.com/mfridman/interpolate v0.0.2/go.mod h1:p+7uk6oE07mpE/Ik1b8EckO0O4ZXiGAfshKBWLUM9Xg= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= -github.com/microsoft/go-mssqldb v1.6.0 h1:mM3gYdVwEPFrlg/Dvr2DNVEgYFG7L42l+dGc67NNNpc= github.com/microsoft/go-mssqldb v1.6.0/go.mod h1:00mDtPbeQCRGC1HwOOR5K/gr30P1NcEG0vx6Kbv2aJU= +github.com/microsoft/go-mssqldb v1.7.0 h1:sgMPW0HA6Ihd37Yx0MzHyKD726C2kY/8KJsQtXHNaAs= +github.com/microsoft/go-mssqldb v1.7.0/go.mod h1:kOvZKUdrhhFQmxLZqbwUV0rHkNkZpthMITIb2Ko1IoA= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g= @@ -473,16 +462,12 @@ github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= -github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/montanaflynn/stats v0.7.0/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= -github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= @@ -508,6 +493,8 @@ github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI= github.com/nats-io/nkeys v0.4.7/go.mod h1:kqXRgRDPlGy7nGaEDMuYzmiJCIAAWDK0IMBtDmGD0nc= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= +github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/nightlyone/lockfile v1.0.0 h1:RHep2cFKK4PonZJDdEl4GmkabuhbsRMgk/k3uAmxBiA= github.com/nightlyone/lockfile v1.0.0/go.mod h1:rywoIealpdNse2r832aiD9jRk8ErCatROs6LzC841CI= github.com/npillmayer/nestext v0.1.3/go.mod h1:h2lrijH8jpicr25dFY+oAJLyzlya6jhnuG+zWp9L0Uk= @@ -537,10 +524,6 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= -github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= -github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= -github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde h1:x0TT0RDC7UhAVbbWWBzr41ElhJx5tXPWkIHA2HWPRuw= github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -552,8 +535,9 @@ github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCko github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f h1:HlPa7RcxTCrva5izPfTEfvYecO7LTahgmMRD1Qp13xg= github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f/go.mod h1:WZ501QQMbZZ+3pXFPhQKzNwS1+jls0oqov3uQ2WasLs= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -565,6 +549,8 @@ github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndr github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 h1:J9b7z+QKAmPf4YLrFg6oQUotqHQeUNWwkvo7jZp1GLU= github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= +github.com/pressly/goose/v3 v3.20.0 h1:uPJdOxF/Ipj7ABVNOAMJXSxwFXZGwMGHNqjC8e61VA0= +github.com/pressly/goose/v3 v3.20.0/go.mod h1:BRfF2GcG4FTG12QfdBVy3q1yveaf4ckL9vWwEcIO3lA= github.com/privacybydesign/gabi v0.0.0-20221212095008-68a086907750 h1:3RuYOQTlArQ6Uw2TgySusmZGluP+18WdQL56YSfkM3Q= github.com/privacybydesign/gabi v0.0.0-20221212095008-68a086907750/go.mod h1:QZI8hX8Ff2GfZ7UJuxyWw3nAGgt2s5+U4hxY6rmwQvs= github.com/privacybydesign/irmago v0.15.2 h1:xHtfrtsbQy79wiTlnoOGTYuwUyUS5xqrxIr0Y7VVOgM= @@ -595,6 +581,8 @@ github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3c github.com/redis/go-redis/v9 v9.0.2/go.mod h1:/xDTe9EF1LM61hek62Poq2nzQSGj0xSrEtEHbBQevps= github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8= github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= @@ -613,6 +601,8 @@ github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHi github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= +github.com/sethvargo/go-retry v0.2.4 h1:T+jHEQy/zKJf5s95UkguisicE0zuF9y7+/vgz08Ocec= +github.com/sethvargo/go-retry v0.2.4/go.mod h1:1afjQuvh7s4gflMObvjLPaWgluLLyhA1wmVZ6KLpICw= github.com/shengdoushi/base58 v1.0.0 h1:tGe4o6TmdXFJWoI31VoSWvuaKxf0Px3gqa3sUWhAxBs= github.com/shengdoushi/base58 v1.0.0/go.mod h1:m5uIILfzcKMw6238iWAhP4l3s5+uXyF3+bJKUNhAL9I= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= @@ -700,6 +690,8 @@ go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -707,7 +699,6 @@ golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= @@ -719,8 +710,8 @@ golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDf golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= +golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw= +golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= @@ -778,8 +769,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -949,8 +940,6 @@ gorm.io/driver/mysql v1.5.6 h1:Ld4mkIickM+EliaQZQx3uOJDJHtrd70MxAUqWqlx3Y8= gorm.io/driver/mysql v1.5.6/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM= gorm.io/driver/postgres v1.5.7 h1:8ptbNJTDbEmhdr62uReG5BGkdQyeasu/FZHxI0IMGnM= gorm.io/driver/postgres v1.5.7/go.mod h1:3e019WlBaYI5o5LIdNV+LyxCMNtLOQETBXL2h4chKpA= -gorm.io/driver/sqlite v1.5.5 h1:7MDMtUZhV065SilG62E0MquljeArQZNfJnjd9i9gx3E= -gorm.io/driver/sqlite v1.5.5/go.mod h1:6NgQ7sQWAIFsPrJJl1lSNSu2TABh0ZZ/zm5fosATavE= gorm.io/driver/sqlserver v1.5.2 h1:+o4RQ8w1ohPbADhFqDxeeZnSWjwOcBnxBckjTbcP4wk= gorm.io/driver/sqlserver v1.5.2/go.mod h1:gaKF0MO0cfTq9Q3/XhkowSw4g6nIwHPGAs4hzKCmvBo= gorm.io/gorm v1.25.2-0.20230610234218-206613868439/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= @@ -959,6 +948,32 @@ gorm.io/gorm v1.25.9 h1:wct0gxZIELDk8+ZqF/MVnHLkA1rvYlBWUMv2EdsK1g8= gorm.io/gorm v1.25.9/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +modernc.org/cc/v4 v4.20.0 h1:45Or8mQfbUqJOG9WaxvlFYOAQO0lQ5RvqBcFCXngjxk= +modernc.org/cc/v4 v4.20.0/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ= +modernc.org/ccgo/v4 v4.16.0 h1:ofwORa6vx2FMm0916/CkZjpFPSR70VwTjUCe2Eg5BnA= +modernc.org/ccgo/v4 v4.16.0/go.mod h1:dkNyWIjFrVIZ68DTo36vHK+6/ShBn4ysU61So6PIqCI= +modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE= +modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ= +modernc.org/gc/v2 v2.4.1 h1:9cNzOqPyMJBvrUipmynX0ZohMhcxPtMccYgGOJdOiBw= +modernc.org/gc/v2 v2.4.1/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU= +modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI= +modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4= +modernc.org/libc v1.49.3 h1:j2MRCRdwJI2ls/sGbeSk0t2bypOG/uvPZUsGQFDulqg= +modernc.org/libc v1.49.3/go.mod h1:yMZuGkn7pXbKfoT/M35gFJOAEdSKdxL0q64sF7KqCDo= +modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= +modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= +modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E= +modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU= +modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4= +modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= +modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc= +modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss= +modernc.org/sqlite v1.29.8 h1:nGKglNx9K5v0As+zF0/Gcl1kMkmaU1XynYyq92PbsC8= +modernc.org/sqlite v1.29.8/go.mod h1:lQPm27iqa4UNZpmr4Aor0MH0HkCLbt1huYDfWylLZFk= +modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= +modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0= +modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= +modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY= rsc.io/qr v0.2.0/go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs= schneider.vip/problem v1.9.1 h1:HYdGPzbTHnNziF7cC4ftbn/eTrjSIXhKfricAMaLIMk= diff --git a/storage/engine.go b/storage/engine.go index 17228dbda4..53c7708962 100644 --- a/storage/engine.go +++ b/storage/engine.go @@ -20,8 +20,6 @@ package storage import ( "context" - "database/sql" - "embed" "errors" "fmt" "io" @@ -30,21 +28,16 @@ import ( "sync" "time" - "github.com/golang-migrate/migrate/v4" - migrationDatabase "github.com/golang-migrate/migrate/v4/database" - mysqlMigrate "github.com/golang-migrate/migrate/v4/database/mysql" - postgresMigrate "github.com/golang-migrate/migrate/v4/database/postgres" - sqlLiteMigrate "github.com/golang-migrate/migrate/v4/database/sqlite3" - sqlserverMigrate "github.com/golang-migrate/migrate/v4/database/sqlserver" - "github.com/golang-migrate/migrate/v4/source/iofs" + "github.com/glebarez/sqlite" "github.com/nuts-foundation/go-stoabs" "github.com/nuts-foundation/nuts-node/core" "github.com/nuts-foundation/nuts-node/storage/log" + "github.com/nuts-foundation/nuts-node/storage/sql_migrations" + "github.com/pressly/goose/v3" "github.com/redis/go-redis/v9" "github.com/sirupsen/logrus" "gorm.io/driver/mysql" "gorm.io/driver/postgres" - "gorm.io/driver/sqlite" "gorm.io/driver/sqlserver" "gorm.io/gorm" ) @@ -55,9 +48,6 @@ const storeShutdownTimeout = 5 * time.Second // If SQL queries take longer than this threshold, they will be logged as warnings. const sqlSlowQueryThreshold = 200 * time.Millisecond -//go:embed sql_migrations/*.sql -var sqlMigrationsFS embed.FS - // New creates a new instance of the storage engine. func New() Engine { return &engine{ @@ -183,16 +173,17 @@ func (e *engine) initSQLDatabase() error { } // Find right SQL adapter for ORM and migrations - var migrationDriver migrationDatabase.Driver - dbType := strings.Split(connectionString, ":")[0] + if dbType == "sqlite" { + connectionString = strings.Join(strings.Split(connectionString, ":")[1:], ":") + } + db, err := goose.OpenDBWithDriver(dbType, connectionString) + if err != nil { + return err + } + var dialect goose.Dialect switch dbType { case "sqlite": - // sqlite3 uses the same driver as gorm - db, err := sql.Open("sqlite3", connectionString[7:]) - if err != nil { - return err - } // SQLite does not support SELECT FOR UPDATE and allows only 1 active write transaction at any time, // and any other attempt to acquire a write transaction will directly return an error. // This is in contrast to most other SQL-databases, which let the 2nd thread wait for some time to acquire the lock. @@ -201,7 +192,6 @@ func (e *engine) initSQLDatabase() error { // With 1 connection, all actions will be performed sequentially. This impacts performance, but SQLite should not be used in production. // See https://github.com/nuts-foundation/nuts-node/pull/2589#discussion_r1399130608 db.SetMaxOpenConns(1) - migrationDriver, _ = sqlLiteMigrate.WithInstance(db, &sqlLiteMigrate.Config{}) dialector := sqlite.Dialector{Conn: db} e.sqlDB, err = gorm.Open(dialector, &gorm.Config{ TranslateError: true, @@ -213,45 +203,54 @@ func (e *engine) initSQLDatabase() error { if err != nil { return err } + dialect = goose.DialectSQLite3 case "mysql": - db, _ := sql.Open("mysql", connectionString) - migrationDriver, _ = mysqlMigrate.WithInstance(db, &mysqlMigrate.Config{}) e.sqlDB, _ = gorm.Open(mysql.New(mysql.Config{ Conn: db, }), &gorm.Config{}) + dialect = goose.DialectMySQL case "postgres": - db, _ := sql.Open("postgresql", connectionString) - migrationDriver, _ = postgresMigrate.WithInstance(db, &postgresMigrate.Config{}) e.sqlDB, _ = gorm.Open(postgres.New(postgres.Config{ Conn: db, }), &gorm.Config{}) + dialect = goose.DialectPostgres case "sqlserver": - db, _ := sql.Open("sqlserver", connectionString) - migrationDriver, _ = sqlserverMigrate.WithInstance(db, &sqlserverMigrate.Config{}) e.sqlDB, _ = gorm.Open(sqlserver.New(sqlserver.Config{ Conn: db, }), &gorm.Config{}) + dialect = goose.DialectMSSQL default: return errors.New("unsupported SQL database") } - - // Open connection and migrate - var err error - embeddedSource, err := iofs.New(sqlMigrationsFS, "sql_migrations") + goose.SetVerbose(true) if err != nil { return err } - dbMigrator, err := migrate.NewWithInstance("embedded", embeddedSource, dbType, migrationDriver) + provider, err := goose.NewProvider(dialect, db, sql_migrations.SQLMigrationsFS) + if err != nil { + return err + } + log.Logger().Debug("Running database migrations...") - dbMigrator.Log = e.sqlMigrationLogger - if err = dbMigrator.Up(); err != nil && !errors.Is(err, migrate.ErrNoChange) { + result, err := provider.Up(context.Background()) + if err != nil { + for _, r := range result { + log.Logger().Info(r.String()) + } return fmt.Errorf("failed to migrate database: %w", err) } + log.Logger().Infof("Completed %d migrations", len(result)) + for _, r := range result { + log.Logger().Info(r.String()) + } + return nil } func sqliteConnectionString(datadir string) string { - return "sqlite:file:" + path.Join(datadir, "sqlite.db?_journal_mode=WAL&_foreign_keys=on") + // _pragma=foreign_keys(1)&_time_format=sqlite + // return "sqlite:file:" + path.Join(datadir, "sqlite.db?_journal_mode=WAL&_foreign_keys=on") + return "sqlite:file:" + path.Join(datadir, "sqlite.db?_pragma=foreign_keys(1)&journal_mode(WAL)") } type provider struct { @@ -310,7 +309,6 @@ func (p *provider) getStore(moduleName string, name string, adapter database) (s } type migrationLogger interface { - migrate.Logger io.Writer } type logrusInfoLogWriter struct { diff --git a/storage/engine_test.go b/storage/engine_test.go index 737e60d756..5b3a3a05ad 100644 --- a/storage/engine_test.go +++ b/storage/engine_test.go @@ -30,6 +30,7 @@ import ( "path" "strings" "testing" + "time" ) func Test_New(t *testing.T) { @@ -163,12 +164,18 @@ func Test_engine_sqlDatabase(t *testing.T) { underlyingDB, err := e.GetSQLDatabase().DB() require.NoError(t, err) - row := underlyingDB.QueryRow("SELECT * FROM schema_migrations") - require.NoError(t, row.Err()) - var version int - var dirty bool - assert.NoError(t, row.Scan(&version, &dirty)) - assert.Equal(t, len(sqlFiles)/2, version) // up and down migration files + rows, err := underlyingDB.Query("SELECT * FROM goose_db_version") + require.NoError(t, err) + var pKey, versionId, is_applied int + var tStamp time.Time + var totalMigrations int + rows.Next() + for err = rows.Scan(&pKey, &versionId, &is_applied, &tStamp); rows.Next() && err == nil; { + assert.Equal(t, 1, is_applied) + totalMigrations++ + } + require.NoError(t, err) + assert.Equal(t, len(sqlFiles), totalMigrations) // up and down migration files }) t.Run("unsupported protocol doesn't log secrets", func(t *testing.T) { dataDir := io.TestDirectory(t) diff --git a/storage/sql_migrations/001_credential.down.sql b/storage/sql_migrations/001_credential.down.sql deleted file mode 100644 index ebcd59e337..0000000000 --- a/storage/sql_migrations/001_credential.down.sql +++ /dev/null @@ -1,2 +0,0 @@ -drop table credential; -drop table credential_prop; diff --git a/storage/sql_migrations/001_credential.up.sql b/storage/sql_migrations/001_credential.sql similarity index 92% rename from storage/sql_migrations/001_credential.up.sql rename to storage/sql_migrations/001_credential.sql index 59a545e3aa..547319a294 100644 --- a/storage/sql_migrations/001_credential.up.sql +++ b/storage/sql_migrations/001_credential.sql @@ -1,3 +1,4 @@ +-- +goose Up create table credential ( id varchar(415) not null primary key, @@ -20,4 +21,8 @@ create table credential_prop PRIMARY KEY (credential_id, path), -- cascading delete: if the presentation gets deleted, the properties get deleted as well constraint fk_discovery_credential_id foreign key (credential_id) references credential (id) on delete cascade -); \ No newline at end of file +); + +-- +goose Down +drop table credential; +drop table credential_prop; diff --git a/storage/sql_migrations/002_discoveryservice.down.sql b/storage/sql_migrations/002_discoveryservice.down.sql deleted file mode 100644 index 8e2e96e20e..0000000000 --- a/storage/sql_migrations/002_discoveryservice.down.sql +++ /dev/null @@ -1,5 +0,0 @@ -drop index idx_discovery_presentation_expiration; -drop table discovery_service; -drop table discovery_presentation; -drop table discovery_credential; - diff --git a/storage/sql_migrations/002_discoveryservice.up.sql b/storage/sql_migrations/002_discoveryservice.sql similarity index 95% rename from storage/sql_migrations/002_discoveryservice.up.sql rename to storage/sql_migrations/002_discoveryservice.sql index d0c13e4c6e..b4ca544e9f 100644 --- a/storage/sql_migrations/002_discoveryservice.up.sql +++ b/storage/sql_migrations/002_discoveryservice.sql @@ -1,3 +1,4 @@ +-- +goose Up -- discovery contains the known discovery services and the associated tags. create table discovery_service ( @@ -39,4 +40,9 @@ create table discovery_credential credential_id varchar(415) not null, constraint fk_discovery_credential_presentation foreign key (presentation_id) references discovery_presentation (id) on delete cascade, constraint fk_discovery_credential foreign key (credential_id) references credential (id) -); \ No newline at end of file +); + +-- +goose Down +drop table discovery_service; +drop table discovery_presentation; +drop table discovery_credential; diff --git a/storage/sql_migrations/003_did.down.sql b/storage/sql_migrations/003_did.down.sql deleted file mode 100644 index 80dbc8e543..0000000000 --- a/storage/sql_migrations/003_did.down.sql +++ /dev/null @@ -1,3 +0,0 @@ -drop table did; -drop table did_verificationmethod; -drop table did_service; \ No newline at end of file diff --git a/storage/sql_migrations/003_did.up.sql b/storage/sql_migrations/003_did.sql similarity index 92% rename from storage/sql_migrations/003_did.up.sql rename to storage/sql_migrations/003_did.sql index 034ffe2f76..c06fdaab47 100644 --- a/storage/sql_migrations/003_did.up.sql +++ b/storage/sql_migrations/003_did.sql @@ -1,4 +1,4 @@ --- migrate:up +-- +goose Up -- this table is used to store locally managed DIDs create table did ( @@ -33,4 +33,9 @@ create table did_service data text not null, primary key (id), foreign key (did) references did (did) on delete cascade -); \ No newline at end of file +); + +-- +goose Down +drop table did; +drop table did_verificationmethod; +drop table did_service; \ No newline at end of file diff --git a/storage/sql_migrations/004_discoveryservice_client_registration.down.sql b/storage/sql_migrations/004_discoveryservice_client_registration.down.sql deleted file mode 100644 index f37852f67f..0000000000 --- a/storage/sql_migrations/004_discoveryservice_client_registration.down.sql +++ /dev/null @@ -1,2 +0,0 @@ -drop index idx_discovery_presentation_refresh -drop table discovery_presentation_refresh; diff --git a/storage/sql_migrations/004_discoveryservice_client_registration.up.sql b/storage/sql_migrations/004_discoveryservice_client_registration.sql similarity index 93% rename from storage/sql_migrations/004_discoveryservice_client_registration.up.sql rename to storage/sql_migrations/004_discoveryservice_client_registration.sql index be5b00b061..417c4a82e6 100644 --- a/storage/sql_migrations/004_discoveryservice_client_registration.up.sql +++ b/storage/sql_migrations/004_discoveryservice_client_registration.sql @@ -1,4 +1,4 @@ --- migrate:up +-- +goose Up -- discovery_did_registration contains the DIDs that should be registered on the specified Discovery Service(s). create table discovery_presentation_refresh ( @@ -15,3 +15,6 @@ create table discovery_presentation_refresh ); -- index for the next_registration column, used when checking which registrations need to be refreshed create index idx_discovery_presentation_refresh on discovery_presentation_refresh (next_refresh); + +-- +goose Down +drop table discovery_presentation_refresh; diff --git a/storage/sql_migrations/005_statuslist.down.sql b/storage/sql_migrations/005_statuslist.down.sql deleted file mode 100644 index 9964dcb079..0000000000 --- a/storage/sql_migrations/005_statuslist.down.sql +++ /dev/null @@ -1,3 +0,0 @@ -drop table status_list_credential; -drop table status_list; -drop table status_list_entry; diff --git a/storage/sql_migrations/005_statuslist.up.sql b/storage/sql_migrations/005_statuslist.sql similarity index 96% rename from storage/sql_migrations/005_statuslist.up.sql rename to storage/sql_migrations/005_statuslist.sql index 73837eb015..3c54cec2b2 100644 --- a/storage/sql_migrations/005_statuslist.up.sql +++ b/storage/sql_migrations/005_statuslist.sql @@ -1,3 +1,4 @@ +-- +goose Up -- status_list_credential: latest version of known credentials. create table status_list_credential ( @@ -48,4 +49,9 @@ create table status_list_entry constraint status_list_entry_id primary key (status_list_credential, status_list_index), -- Ties the status_list_credential to an issuer (did) via the status_list_issuer table constraint fk_status_list_credential foreign key (status_list_credential) references status_list (subject_id) on delete cascade -); \ No newline at end of file +); + +-- +goose Down +drop table status_list_credential; +drop table status_list; +drop table status_list_entry; diff --git a/storage/sql_migrations/006_wallet.down.sql b/storage/sql_migrations/006_wallet.down.sql deleted file mode 100644 index b4628a5569..0000000000 --- a/storage/sql_migrations/006_wallet.down.sql +++ /dev/null @@ -1,2 +0,0 @@ -drop index idx_wallet_holder_did; -drop table wallet_credential; diff --git a/storage/sql_migrations/006_wallet.up.sql b/storage/sql_migrations/006_wallet.sql similarity index 73% rename from storage/sql_migrations/006_wallet.up.sql rename to storage/sql_migrations/006_wallet.sql index 086b38ad26..c2524e159f 100644 --- a/storage/sql_migrations/006_wallet.up.sql +++ b/storage/sql_migrations/006_wallet.sql @@ -1,3 +1,4 @@ +-- +goose Up create table wallet_credential ( credential_id varchar(415) not null, @@ -5,4 +6,8 @@ create table wallet_credential constraint fk_wallet_credential foreign key (credential_id) references credential (id) ); -create index idx_wallet_holder_did on wallet_credential (holder_did); \ No newline at end of file +create index idx_wallet_holder_did on wallet_credential (holder_did); + +-- +goose Down +drop index idx_wallet_holder_did; +drop table wallet_credential; diff --git a/storage/sql_migrations/007_issued_credential.down.sql b/storage/sql_migrations/007_issued_credential.down.sql deleted file mode 100644 index a15db60318..0000000000 --- a/storage/sql_migrations/007_issued_credential.down.sql +++ /dev/null @@ -1 +0,0 @@ -drop table issued_credential; diff --git a/storage/sql_migrations/007_issued_credential.up.sql b/storage/sql_migrations/007_issued_credential.sql similarity index 71% rename from storage/sql_migrations/007_issued_credential.up.sql rename to storage/sql_migrations/007_issued_credential.sql index 4c53aface3..6e9a4afcec 100644 --- a/storage/sql_migrations/007_issued_credential.up.sql +++ b/storage/sql_migrations/007_issued_credential.sql @@ -1,5 +1,9 @@ +-- +goose Up create table issued_credential ( id varchar(415) not null primary key, constraint fk_issued_credential foreign key (id) references credential (id) -); \ No newline at end of file +); + +-- +goose Down +drop table issued_credential; diff --git a/storage/sql_migrations/assets.go b/storage/sql_migrations/assets.go new file mode 100644 index 0000000000..8b79f6340e --- /dev/null +++ b/storage/sql_migrations/assets.go @@ -0,0 +1,6 @@ +package sql_migrations + +import "embed" + +//go:embed *.sql +var SQLMigrationsFS embed.FS From f784e21860f14afad849d45955fb491f6a847fc1 Mon Sep 17 00:00:00 2001 From: Joris Scharp Date: Thu, 25 Apr 2024 14:27:21 +0200 Subject: [PATCH 04/13] Changed `discovery_service.id` from varchar(200) to varchar(36) to fix the "is not the same length or scale as referencing column" error. Also changed to docker imague due to a missing `sqlcmd` binary in the ARM image. Important: Make sure the varchar(36) is okay, and otherwise change referencing fields to use varchar(200) as well. --- e2e-tests/oauth-flow/rfc021/sqlserver.yml | 3 ++- storage/sql_migrations/002_discoveryservice.sql | 2 +- .../004_discoveryservice_client_registration.sql | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/e2e-tests/oauth-flow/rfc021/sqlserver.yml b/e2e-tests/oauth-flow/rfc021/sqlserver.yml index 4ee45a2a96..baa65bf2bf 100644 --- a/e2e-tests/oauth-flow/rfc021/sqlserver.yml +++ b/e2e-tests/oauth-flow/rfc021/sqlserver.yml @@ -10,7 +10,8 @@ services: environment: NUTS_STORAGE_SQL_CONNECTION: sqlserver://sa:MyStrong(!)Password@db:1433/node_b?sslmode=disable db: - image: mcr.microsoft.com/azure-sql-edge:latest + # image: mcr.microsoft.com/azure-sql-edge:latest <-- "The sqlcmd utility is not included in the ARM64 version of the SQL Edge container" - https://github.com/microsoft/mssql-docker/issues/734 + image: mcr.microsoft.com/mssql/server:2022-latest restart: always ports: - "1433:1433" diff --git a/storage/sql_migrations/002_discoveryservice.sql b/storage/sql_migrations/002_discoveryservice.sql index b4ca544e9f..c238072b09 100644 --- a/storage/sql_migrations/002_discoveryservice.sql +++ b/storage/sql_migrations/002_discoveryservice.sql @@ -3,7 +3,7 @@ create table discovery_service ( -- id is the unique identifier for the service. It comes from the service definition. - id varchar(200) not null primary key, + id varchar(36) not null primary key, -- tag is the latest tag pointing to the last presentation registered on the service. last_tag varchar(40) null, -- tag_prefix is used to prefix the tag of the presentations of the service. diff --git a/storage/sql_migrations/004_discoveryservice_client_registration.sql b/storage/sql_migrations/004_discoveryservice_client_registration.sql index 417c4a82e6..0397031555 100644 --- a/storage/sql_migrations/004_discoveryservice_client_registration.sql +++ b/storage/sql_migrations/004_discoveryservice_client_registration.sql @@ -4,7 +4,7 @@ create table discovery_presentation_refresh ( -- service_id is the ID of the Discover Service that the DID should be registered on. -- It comes from the service definition. - service_id varchar(200) not null, + service_id varchar(36) not null, -- did is the DID that should be registered on the Discovery Service. did varchar(370) not null, -- next_refresh is the timestamp (seconds since Unix epoch) when the registration on the From bcc70ef20638f1f6d332f5f982eef3e7fdd9ec12 Mon Sep 17 00:00:00 2001 From: Rein Krul Date: Wed, 1 May 2024 16:06:58 +0200 Subject: [PATCH 05/13] go mod tidy --- go.mod | 67 +++++++++++++++++++++++----------------------------------- go.sum | 15 ++++++------- 2 files changed, 34 insertions(+), 48 deletions(-) diff --git a/go.mod b/go.mod index 3b65e7b8fd..ba56a699b4 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,8 @@ require ( github.com/cbroglie/mustache v1.4.0 github.com/chromedp/chromedp v0.9.5 github.com/dlclark/regexp2 v1.11.0 + github.com/glebarez/sqlite v1.11.0 + github.com/go-redis/redismock/v9 v9.2.0 github.com/golang-jwt/jwt v3.2.2+incompatible github.com/goodsign/monday v1.0.2 github.com/google/uuid v1.6.0 @@ -30,6 +32,7 @@ require ( // check the oapi-codegen tool version in the makefile when upgrading the runtime github.com/oapi-codegen/runtime v1.1.1 github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f + github.com/pressly/goose/v3 v3.20.0 github.com/privacybydesign/irmago v0.15.2 github.com/prometheus/client_golang v1.19.0 github.com/prometheus/client_model v0.6.1 @@ -50,10 +53,14 @@ require ( google.golang.org/protobuf v1.34.0 gopkg.in/Regis24GmbH/go-phonetics.v2 v2.0.3 gopkg.in/yaml.v3 v3.0.1 + gorm.io/driver/mysql v1.5.6 + gorm.io/driver/postgres v1.5.7 + gorm.io/driver/sqlserver v1.5.2 schneider.vip/problem v1.9.1 ) require ( + filippo.io/edwards25519 v1.1.0 // indirect github.com/PaesslerAG/gval v1.2.2 // indirect github.com/alexandrevicenzi/go-sse v1.6.0 // indirect github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect @@ -78,9 +85,11 @@ require ( github.com/fatih/structs v1.1.0 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/fxamacker/cbor v1.5.1 // indirect + github.com/glebarez/go-sqlite v1.21.2 // indirect github.com/go-chi/chi/v5 v5.0.10 // indirect github.com/go-co-op/gocron v1.28.3 // indirect github.com/go-errors/errors v1.4.2 // indirect + github.com/go-jose/go-jose/v4 v4.0.1 // indirect github.com/go-redis/redis/v8 v8.11.5 // indirect github.com/go-redsync/redsync/v4 v4.13.0 // indirect github.com/go-sql-driver/mysql v1.8.1 // indirect @@ -90,6 +99,9 @@ require ( github.com/goccy/go-json v0.10.2 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect + github.com/golang-sql/sqlexp v0.1.0 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/google/flatbuffers v24.3.25+incompatible // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect @@ -100,7 +112,12 @@ require ( github.com/hashicorp/go-sockaddr v1.0.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect + github.com/jackc/pgx/v5 v5.5.5 // indirect + github.com/jackc/puddle/v2 v2.2.1 // indirect github.com/jinzhu/inflection v1.0.0 // indirect + github.com/joho/godotenv v1.5.1 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/klauspost/compress v1.17.8 // indirect github.com/labstack/gommon v0.4.2 // indirect @@ -112,7 +129,9 @@ require ( github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mfridman/interpolate v0.0.2 // indirect github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect + github.com/microsoft/go-mssqldb v1.7.0 // indirect github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect github.com/minio/highwayhash v1.0.2 // indirect github.com/minio/sha256-simd v0.1.1 // indirect @@ -127,16 +146,19 @@ require ( github.com/nats-io/jwt/v2 v2.5.5 // indirect github.com/nats-io/nkeys v0.4.7 // indirect github.com/nats-io/nuid v1.0.1 // indirect + github.com/ncruces/go-strftime v0.1.9 // indirect github.com/nightlyone/lockfile v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect github.com/privacybydesign/gabi v0.0.0-20221212095008-68a086907750 // indirect github.com/prometheus/common v0.48.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/robfig/cron/v3 v3.0.1 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/ryanuber/go-glob v1.0.0 // indirect github.com/segmentio/asm v1.2.0 // indirect + github.com/sethvargo/go-retry v0.2.4 // indirect github.com/shengdoushi/base58 v1.0.0 // indirect github.com/shopspring/decimal v1.4.0 // indirect github.com/sietseringers/go-sse v0.0.0-20200801161811-e2cf2c63ca50 // indirect @@ -152,54 +174,19 @@ require ( github.com/x-cray/logrus-prefixed-formatter v0.5.2 // indirect github.com/x448/float16 v0.8.4 // indirect github.com/yuin/gopher-lua v1.1.1 // indirect + go.opencensus.io v0.24.0 // indirect + go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.24.0 // indirect + golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.19.0 // indirect golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect gopkg.in/Regis24GmbH/go-diacritics.v2 v2.0.3 // indirect gorm.io/gorm v1.25.10 - rsc.io/qr v0.2.0 // indirect -) - -require ( - github.com/glebarez/sqlite v1.11.0 - github.com/golang-migrate/migrate/v4 v4.17.1 - github.com/pressly/goose/v3 v3.20.0 - github.com/go-redis/redismock/v9 v9.2.0 - gorm.io/driver/mysql v1.5.6 - gorm.io/driver/postgres v1.5.7 - gorm.io/driver/sqlserver v1.5.2 - modernc.org/sqlite v1.29.8 -) - -require ( - filippo.io/edwards25519 v1.1.0 // indirect - github.com/glebarez/go-sqlite v1.21.2 // indirect - github.com/go-jose/go-jose/v4 v4.0.1 // indirect - github.com/golang-sql/sqlexp v0.1.0 // indirect - github.com/google/flatbuffers v24.3.25+incompatible // indirect - github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect - github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect - github.com/jackc/pgx/v5 v5.5.5 // indirect - github.com/jackc/puddle/v2 v2.2.1 // indirect - github.com/joho/godotenv v1.5.1 // indirect - github.com/mfridman/interpolate v0.0.2 // indirect - github.com/microsoft/go-mssqldb v1.7.0 // indirect - github.com/ncruces/go-strftime v0.1.9 // indirect - github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect - github.com/sethvargo/go-retry v0.2.4 // indirect - go.uber.org/multierr v1.11.0 // indirect - golang.org/x/sync v0.7.0 // indirect - modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect modernc.org/libc v1.49.3 // indirect modernc.org/mathutil v1.6.0 // indirect modernc.org/memory v1.8.0 // indirect - modernc.org/strutil v1.2.0 // indirect - modernc.org/token v1.1.0 // indirect - github.com/microsoft/go-mssqldb v1.6.0 // indirect - golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect - golang.org/x/sync v0.7.0 // indirect - gorm.io/driver/sqlserver v1.5.2 // indirect + modernc.org/sqlite v1.29.8 // indirect + rsc.io/qr v0.2.0 // indirect ) diff --git a/go.sum b/go.sum index 6c54a4b0da..fceff53631 100644 --- a/go.sum +++ b/go.sum @@ -47,8 +47,6 @@ github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGn github.com/alicebob/miniredis/v2 v2.32.1 h1:Bz7CciDnYSaa0mX5xODh6GUITRSx+cVhjNoOR4JssBo= github.com/alicebob/miniredis/v2 v2.32.1/go.mod h1:AqkLNAfUm0K07J28hnAyyQKf/x0YkCY/g5DCtuL01Mw= github.com/alvaroloes/enumer v1.1.2/go.mod h1:FxrjvuXoDAx9isTJrv4c+T410zFi0DtXIT0m65DJ+Wo= -github.com/amacneil/dbmate/v2 v2.15.0 h1:s5NVssvrdRMUTQI8YGMsIfdmZCmCPDsdqncj3XsMfjk= -github.com/amacneil/dbmate/v2 v2.15.0/go.mod h1:bOAtNUrGzXsSn89ETWe+1LQ3VKpgCX95+iGD1MvUI7I= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= @@ -209,8 +207,6 @@ github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw= github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/golang-migrate/migrate/v4 v4.17.1 h1:4zQ6iqL6t6AiItphxJctQb3cFqWiSpMnX7wLTPnnYO4= -github.com/golang-migrate/migrate/v4 v4.17.1/go.mod h1:m8hinFyWBn0SA4QKHuKh175Pm9wjmxj3S2Mia7dbXzM= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= @@ -218,6 +214,7 @@ github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EO github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68= github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -252,6 +249,7 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -313,6 +311,7 @@ github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= @@ -420,8 +419,6 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= -github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mdp/qrterminal/v3 v3.2.0 h1:qteQMXO3oyTK4IHwj2mWsKYYRBOp1Pj2WRYFYYNTCdk= github.com/mdp/qrterminal/v3 v3.2.0/go.mod h1:XGGuua4Lefrl7TLEsSONiD+UEjQXJZ4mPzF+gWYIJkk= @@ -568,10 +565,10 @@ github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8= github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= -github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= -github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/redis/rueidis v1.0.19 h1:s65oWtotzlIFN8eMPhyYwxlwLR1lUdhza2KtWprKYSo= github.com/redis/rueidis v1.0.19/go.mod h1:8B+r5wdnjwK3lTFml5VtxjzGOQAC+5UmujoD12pDrEo= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= @@ -729,6 +726,7 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= @@ -869,6 +867,7 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= From c927ede921366ddf055e67dbf8fcf58e372a5102 Mon Sep 17 00:00:00 2001 From: Rein Krul Date: Wed, 1 May 2024 16:09:43 +0200 Subject: [PATCH 06/13] fix test compilation failure --- storage/test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/test.go b/storage/test.go index fa67f369ca..66663a881f 100644 --- a/storage/test.go +++ b/storage/test.go @@ -24,6 +24,7 @@ import ( "github.com/alicebob/miniredis/v2" "github.com/nuts-foundation/go-stoabs" "github.com/nuts-foundation/nuts-node/test/io" + stdIO "io" "testing" "github.com/nuts-foundation/go-did/did" From afd5ef1445c6ed8c9d34447abb5058e19256e486 Mon Sep 17 00:00:00 2001 From: Rein Krul Date: Wed, 1 May 2024 16:24:31 +0200 Subject: [PATCH 07/13] Fix goose logger --- storage/engine.go | 18 +++++------------- storage/test.go | 13 +++++-------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/storage/engine.go b/storage/engine.go index aa97a81ad4..e8baffa90c 100644 --- a/storage/engine.go +++ b/storage/engine.go @@ -22,7 +22,6 @@ import ( "context" "errors" "fmt" - "io" "path" "strings" "sync" @@ -65,7 +64,7 @@ type engine struct { sessionDatabase SessionDatabase sqlDB *gorm.DB config Config - sqlMigrationLogger migrationLogger + sqlMigrationLogger goose.Logger } func (e *engine) Config() interface{} { @@ -235,7 +234,8 @@ func (e *engine) initSQLDatabase() error { default: return errors.New("unsupported SQL database") } - goose.SetVerbose(true) + goose.SetVerbose(log.Logger().Level >= logrus.DebugLevel) + goose.SetLogger(e.sqlMigrationLogger) if err != nil { return err } @@ -321,21 +321,13 @@ func (p *provider) getStore(moduleName string, name string, adapter database) (s return store, err } -type migrationLogger interface { - io.Writer -} type logrusInfoLogWriter struct { } -func (m logrusInfoLogWriter) Write(p []byte) (n int, err error) { - log.Logger().Info(string(p)) - return len(p), nil -} - func (m logrusInfoLogWriter) Printf(format string, v ...interface{}) { log.Logger().Info(fmt.Sprintf(format, v...)) } -func (m logrusInfoLogWriter) Verbose() bool { - return log.Logger().Level >= logrus.DebugLevel +func (m logrusInfoLogWriter) Fatalf(format string, v ...interface{}) { + log.Logger().Errorf(format, v...) } diff --git a/storage/test.go b/storage/test.go index 66663a881f..6b6694da1e 100644 --- a/storage/test.go +++ b/storage/test.go @@ -24,7 +24,6 @@ import ( "github.com/alicebob/miniredis/v2" "github.com/nuts-foundation/go-stoabs" "github.com/nuts-foundation/nuts-node/test/io" - stdIO "io" "testing" "github.com/nuts-foundation/go-did/did" @@ -38,7 +37,7 @@ func NewTestStorageRedisEngineInDir(t testing.TB, dir string) (Engine, *miniredi result := New().(*engine) // Prevent dbmate and gorm from logging database creation and applied schema migrations. // These are logged on INFO, which is good for production but annoying in unit tests. - result.sqlMigrationLogger = stdIO.Discard + result.sqlMigrationLogger = nilGooseLogger{} result.config.SQL = SQLConfig{ConnectionString: sqliteConnectionString(dir)} redis := miniredis.RunT(t) @@ -59,7 +58,7 @@ func NewTestStorageEngineInDir(t testing.TB, dir string) Engine { result := New().(*engine) // Prevent dbmate and gorm from logging database creation and applied schema migrations. // These are logged on INFO, which is good for production but annoying in unit tests. - result.sqlMigrationLogger = nilWriter{} + result.sqlMigrationLogger = nilGooseLogger{} result.config.SQL = SQLConfig{ConnectionString: sqliteConnectionString(dir)} err := result.Configure(core.TestServerConfig(func(config *core.ServerConfig) { @@ -132,10 +131,8 @@ func AddDIDtoSQLDB(t testing.TB, db *gorm.DB, dids ...did.DID) { } } -type nilWriter struct{} +type nilGooseLogger struct{} -func (m nilWriter) Write(p []byte) (n int, err error) { return len(p), nil } +func (m nilGooseLogger) Printf(format string, v ...interface{}) {} -func (m nilWriter) Printf(format string, v ...interface{}) {} - -func (m nilWriter) Verbose() bool { return false } +func (m nilGooseLogger) Fatalf(format string, v ...interface{}) {} From 3b30fcf13cc6b23970243e2df59c39e563d3465e Mon Sep 17 00:00:00 2001 From: Rein Krul Date: Wed, 1 May 2024 16:57:28 +0200 Subject: [PATCH 08/13] Substitute TEXT types with VARCHAR(MAX) for MS SQL server --- storage/engine.go | 29 +++++++++++-------- storage/sql_migrations/001_credential.sql | 7 +++-- .../sql_migrations/002_discoveryservice.sql | 3 +- storage/sql_migrations/003_did.sql | 5 ++-- storage/sql_migrations/005_statuslist.sql | 5 ++-- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/storage/engine.go b/storage/engine.go index e8baffa90c..dd287e6469 100644 --- a/storage/engine.go +++ b/storage/engine.go @@ -22,6 +22,7 @@ import ( "context" "errors" "fmt" + "os" "path" "strings" "sync" @@ -194,6 +195,15 @@ func (e *engine) initSQLDatabase() error { return err } var dialect goose.Dialect + gormConfig := &gorm.Config{ + TranslateError: true, + Logger: gormLogrusLogger{ + underlying: log.Logger(), + slowThreshold: sqlSlowQueryThreshold, + }, + } + _ = os.Setenv("TEXT_TYPE", "TEXT") + defer os.Unsetenv("TEXT_TYPE") switch dbType { case "sqlite": // SQLite does not support SELECT FOR UPDATE and allows only 1 active write transaction at any time, @@ -205,13 +215,7 @@ func (e *engine) initSQLDatabase() error { // See https://github.com/nuts-foundation/nuts-node/pull/2589#discussion_r1399130608 db.SetMaxOpenConns(1) dialector := sqlite.Dialector{Conn: db} - e.sqlDB, err = gorm.Open(dialector, &gorm.Config{ - TranslateError: true, - Logger: gormLogrusLogger{ - underlying: log.Logger(), - slowThreshold: sqlSlowQueryThreshold, - }, - }) + e.sqlDB, err = gorm.Open(dialector, gormConfig) if err != nil { return err } @@ -219,17 +223,18 @@ func (e *engine) initSQLDatabase() error { case "mysql": e.sqlDB, _ = gorm.Open(mysql.New(mysql.Config{ Conn: db, - }), &gorm.Config{}) + }), gormConfig) dialect = goose.DialectMySQL case "postgres": e.sqlDB, _ = gorm.Open(postgres.New(postgres.Config{ Conn: db, - }), &gorm.Config{}) + }), gormConfig) dialect = goose.DialectPostgres case "sqlserver": + _ = os.Setenv("TEXT_TYPE", "VARCHAR(MAX)") e.sqlDB, _ = gorm.Open(sqlserver.New(sqlserver.Config{ Conn: db, - }), &gorm.Config{}) + }), gormConfig) dialect = goose.DialectMSSQL default: return errors.New("unsupported SQL database") @@ -239,13 +244,13 @@ func (e *engine) initSQLDatabase() error { if err != nil { return err } - provider, err := goose.NewProvider(dialect, db, sql_migrations.SQLMigrationsFS) + gooseProvider, err := goose.NewProvider(dialect, db, sql_migrations.SQLMigrationsFS) if err != nil { return err } log.Logger().Debug("Running database migrations...") - result, err := provider.Up(context.Background()) + result, err := gooseProvider.Up(context.Background()) if err != nil { for _, r := range result { log.Logger().Info(r.String()) diff --git a/storage/sql_migrations/001_credential.sql b/storage/sql_migrations/001_credential.sql index 547319a294..41530f2001 100644 --- a/storage/sql_migrations/001_credential.sql +++ b/storage/sql_migrations/001_credential.sql @@ -1,21 +1,22 @@ +-- +goose ENVSUB ON -- +goose Up create table credential ( id varchar(415) not null primary key, issuer varchar(370) not null, subject_id varchar(370) not null, - raw text not null, + raw $TEXT_TYPE not null, -- for now, credentials with at most 2 types are supported. -- The type stored in the type column will be the 'other' type, not being 'VerifiableCredential'. -- When credentials with 3 or more types appear, we could have to use a separate table for the types. - type varchar(100) + type varchar(100) ); -- credential_prop contains the credentialSubject properties of a credential. -- It is to search for credentials. create table credential_prop ( - credential_id varchar(415) not null, + credential_id varchar(415) not null, path varchar(100) not null, value varchar(500), PRIMARY KEY (credential_id, path), diff --git a/storage/sql_migrations/002_discoveryservice.sql b/storage/sql_migrations/002_discoveryservice.sql index c238072b09..5d980ea449 100644 --- a/storage/sql_migrations/002_discoveryservice.sql +++ b/storage/sql_migrations/002_discoveryservice.sql @@ -1,3 +1,4 @@ +-- +goose ENVSUB ON -- +goose Up -- discovery contains the known discovery services and the associated tags. create table discovery_service @@ -21,7 +22,7 @@ create table discovery_presentation lamport_timestamp integer null, credential_subject_id varchar(370) not null, presentation_id varchar(415) not null, - presentation_raw text not null, + presentation_raw $TEXT_TYPE not null, presentation_expiration integer not null, unique (service_id, credential_subject_id), constraint fk_discovery_presentation_service_id foreign key (service_id) references discovery_service (id) on delete cascade diff --git a/storage/sql_migrations/003_did.sql b/storage/sql_migrations/003_did.sql index c06fdaab47..8ca72b4705 100644 --- a/storage/sql_migrations/003_did.sql +++ b/storage/sql_migrations/003_did.sql @@ -1,3 +1,4 @@ +-- +goose ENVSUB ON -- +goose Up -- this table is used to store locally managed DIDs create table did @@ -16,7 +17,7 @@ create table did_verificationmethod did varchar(370) not null, -- data is a JSON object containing the verification method data, e.g. the public key. -- When producing the verificationMethod, data is used as JSON base object and the id and type are added. - data text not null, + data $TEXT_TYPE not null, primary key (id), foreign key (did) references did (did) on delete cascade ); @@ -30,7 +31,7 @@ create table did_service did varchar(370) not null, -- data is a JSON object containing the service data, e.g. the serviceEndpoint. -- When producing the service, data is used as JSON base object and the id and type are added. - data text not null, + data $TEXT_TYPE not null, primary key (id), foreign key (did) references did (did) on delete cascade ); diff --git a/storage/sql_migrations/005_statuslist.sql b/storage/sql_migrations/005_statuslist.sql index 3c54cec2b2..90fa655260 100644 --- a/storage/sql_migrations/005_statuslist.sql +++ b/storage/sql_migrations/005_statuslist.sql @@ -1,3 +1,4 @@ +-- +goose ENVSUB ON -- +goose Up -- status_list_credential: latest version of known credentials. create table status_list_credential @@ -8,13 +9,13 @@ create table status_list_credential -- StatusPurpose is the purpose listed in the StatusList2021Credential.credentialSubject status_purpose varchar(25) not null, -- expanded StatusList2021 bitstring - expanded text not null, + expanded $TEXT_TYPE not null, -- created is the seconds since Unix Epoch when this credentialRecord was generated created_at integer not null, -- expires is the seconds since Unix Epoch when the credential expires, only present if set. expires integer null, -- raw credential, either base64 (jwt) or json. - raw text not null + raw $TEXT_TYPE not null ); -- status_list: keeps track of all status list credentials issued by an issuer, and the highest status list index issued for each credential. From 7063a233bf0d0d6d5463ef01024c7f073c2f9d83 Mon Sep 17 00:00:00 2001 From: Rein Krul Date: Thu, 2 May 2024 06:51:22 +0200 Subject: [PATCH 09/13] revert column length changes --- storage/engine.go | 2 ++ storage/sql_migrations/002_discoveryservice.sql | 6 +++--- storage/sql_migrations/003_did.sql | 4 ++-- .../004_discoveryservice_client_registration.sql | 2 +- storage/sql_migrations/005_statuslist.sql | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/storage/engine.go b/storage/engine.go index dd287e6469..61f75db7d0 100644 --- a/storage/engine.go +++ b/storage/engine.go @@ -202,6 +202,8 @@ func (e *engine) initSQLDatabase() error { slowThreshold: sqlSlowQueryThreshold, }, } + // SQL migration files use env variables for substitutions. + // TEXT SQL data type is really DB-specific, so we set a default here and override it for a specific database type (MS SQL). _ = os.Setenv("TEXT_TYPE", "TEXT") defer os.Unsetenv("TEXT_TYPE") switch dbType { diff --git a/storage/sql_migrations/002_discoveryservice.sql b/storage/sql_migrations/002_discoveryservice.sql index 5d980ea449..d06b52c7f5 100644 --- a/storage/sql_migrations/002_discoveryservice.sql +++ b/storage/sql_migrations/002_discoveryservice.sql @@ -4,7 +4,7 @@ create table discovery_service ( -- id is the unique identifier for the service. It comes from the service definition. - id varchar(36) not null primary key, + id varchar(200) not null primary key, -- tag is the latest tag pointing to the last presentation registered on the service. last_tag varchar(40) null, -- tag_prefix is used to prefix the tag of the presentations of the service. @@ -16,13 +16,13 @@ create table discovery_service create table discovery_presentation ( id varchar(36) not null primary key, - service_id varchar(36) not null, + service_id varchar(200) not null, -- lamport_timestamp is the lamport clock of the presentation, converted to a tag and then returned to the client. -- It is only populated if the node is server for this service. lamport_timestamp integer null, credential_subject_id varchar(370) not null, presentation_id varchar(415) not null, - presentation_raw $TEXT_TYPE not null, + presentation_raw $TEXT_TYPE not null, presentation_expiration integer not null, unique (service_id, credential_subject_id), constraint fk_discovery_presentation_service_id foreign key (service_id) references discovery_service (id) on delete cascade diff --git a/storage/sql_migrations/003_did.sql b/storage/sql_migrations/003_did.sql index 8ca72b4705..e60f2c3b77 100644 --- a/storage/sql_migrations/003_did.sql +++ b/storage/sql_migrations/003_did.sql @@ -17,7 +17,7 @@ create table did_verificationmethod did varchar(370) not null, -- data is a JSON object containing the verification method data, e.g. the public key. -- When producing the verificationMethod, data is used as JSON base object and the id and type are added. - data $TEXT_TYPE not null, + data $TEXT_TYPE not null, primary key (id), foreign key (did) references did (did) on delete cascade ); @@ -31,7 +31,7 @@ create table did_service did varchar(370) not null, -- data is a JSON object containing the service data, e.g. the serviceEndpoint. -- When producing the service, data is used as JSON base object and the id and type are added. - data $TEXT_TYPE not null, + data $TEXT_TYPE not null, primary key (id), foreign key (did) references did (did) on delete cascade ); diff --git a/storage/sql_migrations/004_discoveryservice_client_registration.sql b/storage/sql_migrations/004_discoveryservice_client_registration.sql index 0397031555..417c4a82e6 100644 --- a/storage/sql_migrations/004_discoveryservice_client_registration.sql +++ b/storage/sql_migrations/004_discoveryservice_client_registration.sql @@ -4,7 +4,7 @@ create table discovery_presentation_refresh ( -- service_id is the ID of the Discover Service that the DID should be registered on. -- It comes from the service definition. - service_id varchar(36) not null, + service_id varchar(200) not null, -- did is the DID that should be registered on the Discovery Service. did varchar(370) not null, -- next_refresh is the timestamp (seconds since Unix epoch) when the registration on the diff --git a/storage/sql_migrations/005_statuslist.sql b/storage/sql_migrations/005_statuslist.sql index 90fa655260..938d345fb5 100644 --- a/storage/sql_migrations/005_statuslist.sql +++ b/storage/sql_migrations/005_statuslist.sql @@ -9,13 +9,13 @@ create table status_list_credential -- StatusPurpose is the purpose listed in the StatusList2021Credential.credentialSubject status_purpose varchar(25) not null, -- expanded StatusList2021 bitstring - expanded $TEXT_TYPE not null, + expanded $TEXT_TYPE not null, -- created is the seconds since Unix Epoch when this credentialRecord was generated created_at integer not null, -- expires is the seconds since Unix Epoch when the credential expires, only present if set. expires integer null, -- raw credential, either base64 (jwt) or json. - raw $TEXT_TYPE not null + raw $TEXT_TYPE not null ); -- status_list: keeps track of all status list credentials issued by an issuer, and the highest status list index issued for each credential. From 8927722b41f5ac43e289bc6cfc96ff801f5b80e2 Mon Sep 17 00:00:00 2001 From: Rein Krul Date: Thu, 2 May 2024 07:05:07 +0200 Subject: [PATCH 10/13] documentation --- docs/pages/deployment/storage.rst | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/pages/deployment/storage.rst b/docs/pages/deployment/storage.rst index 7128b26f5c..f7bf9a0114 100644 --- a/docs/pages/deployment/storage.rst +++ b/docs/pages/deployment/storage.rst @@ -23,7 +23,7 @@ SQL database By default, storage SQLite will be used in a file called ``sqlite.db`` in the configured data directory. This can be overridden by configuring a connection string in ``storage.sql.connection``. -Other supported SQL databases are Postgres and MySQL. +Other supported SQL databases are Postgres, MySQL and Microsoft SQL Server. Connection strings must be in the following format: @@ -31,13 +31,12 @@ Connection strings must be in the following format: protocol://username:password@host:port/database_name?options -See the `dbmate documentation `_ for more information. +Refer to the documentation of the driver for the database you are using for the correct connection string format: -Examples: - -- Postgres: ``postgres://user:password@localhost:5432/dbname?sslmode=disable`` -- MySql: ``mysql://user:password@localhost:3306/dbname?charset=utf8mb4&parseTime=True&loc=Local`` -- SQLite: ``sqlite:file:/some/path/sqlite.db?_journal_mode=WAL&_foreign_keys=on`` +- Postgres `github.com/jackc/pgx `_ (e.g. ``postgres://user:password@localhost:5432/dbname?sslmode=disable``) +- MySql: `github.com/go-sql-driver/mysql `_ (e.g. ``mysql://user:password@localhost:3306/dbname?charset=utf8mb4&parseTime=True&loc=Local``) +- MS SQL Server: `github.com/microsoft/go-mssqldb `_ +- SQLite (e.g. ``sqlite:file:/some/path/sqlite.db?_journal_mode=(WAL)&_foreign_keys=(1)``) Private Keys ************ From 4c30ec40da73d8ad87378099c88468993a3b723b Mon Sep 17 00:00:00 2001 From: Rein Krul Date: Thu, 2 May 2024 07:07:38 +0200 Subject: [PATCH 11/13] documentation 2 --- docs/pages/deployment/storage.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/deployment/storage.rst b/docs/pages/deployment/storage.rst index f7bf9a0114..2d6321e72a 100644 --- a/docs/pages/deployment/storage.rst +++ b/docs/pages/deployment/storage.rst @@ -36,7 +36,7 @@ Refer to the documentation of the driver for the database you are using for the - Postgres `github.com/jackc/pgx `_ (e.g. ``postgres://user:password@localhost:5432/dbname?sslmode=disable``) - MySql: `github.com/go-sql-driver/mysql `_ (e.g. ``mysql://user:password@localhost:3306/dbname?charset=utf8mb4&parseTime=True&loc=Local``) - MS SQL Server: `github.com/microsoft/go-mssqldb `_ -- SQLite (e.g. ``sqlite:file:/some/path/sqlite.db?_journal_mode=(WAL)&_foreign_keys=(1)``) +- SQLite (e.g. ``sqlite:file:/some/path/sqlite.db?_pragma=foreign_keys(1)&journal_mode(WAL)``) Private Keys ************ From 1da0c864fe4b467b1bdb43860e525f192510e832 Mon Sep 17 00:00:00 2001 From: Rein Krul Date: Thu, 2 May 2024 08:57:57 +0200 Subject: [PATCH 12/13] remove commented code --- storage/engine.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/storage/engine.go b/storage/engine.go index 61f75db7d0..f93010924a 100644 --- a/storage/engine.go +++ b/storage/engine.go @@ -268,8 +268,6 @@ func (e *engine) initSQLDatabase() error { } func sqliteConnectionString(datadir string) string { - // _pragma=foreign_keys(1)&_time_format=sqlite - // return "sqlite:file:" + path.Join(datadir, "sqlite.db?_journal_mode=WAL&_foreign_keys=on") return "sqlite:file:" + path.Join(datadir, "sqlite.db?_pragma=foreign_keys(1)&journal_mode(WAL)") } From dff818aeeda76342dd05c62e261457f96674a0ed Mon Sep 17 00:00:00 2001 From: Rein Krul Date: Thu, 2 May 2024 09:59:16 +0200 Subject: [PATCH 13/13] disable CGO --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fe208bdd54..197b947733 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ COPY go.sum . RUN go mod download && go mod verify COPY . . -RUN CGO_ENABLED=1 CGO_CFLAGS="-D_LARGEFILE64_SOURCE" GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-w -s -X 'github.com/nuts-foundation/nuts-node/core.GitCommit=${GIT_COMMIT}' -X 'github.com/nuts-foundation/nuts-node/core.GitBranch=${GIT_BRANCH}' -X 'github.com/nuts-foundation/nuts-node/core.GitVersion=${GIT_VERSION}'" -o /opt/nuts/nuts +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-w -s -X 'github.com/nuts-foundation/nuts-node/core.GitCommit=${GIT_COMMIT}' -X 'github.com/nuts-foundation/nuts-node/core.GitBranch=${GIT_BRANCH}' -X 'github.com/nuts-foundation/nuts-node/core.GitVersion=${GIT_VERSION}'" -o /opt/nuts/nuts # alpine FROM alpine:3.19.1