Skip to content

Modern Docker Management, Designed for Everyone

refactor: migrate from golang-migrate to goose for database (#2830)

Kyle Mendell3cdc8a4181ab
diff --git a/backend/go.mod b/backend/go.mod
index 3d8bf15aa..a4b9cea13 100644
--- a/backend/go.mod
+++ b/backend/go.mod
@@ -32,7 +32,6 @@ require (
github.com/goccy/go-yaml v1.19.2
github.com/gofrs/flock v0.13.0
github.com/golang-jwt/jwt/v5 v5.3.1
- github.com/golang-migrate/migrate/v4 v4.19.1
github.com/google/uuid v1.6.0
github.com/google/wire v0.7.0
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674
@@ -50,6 +49,7 @@ require (
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.1.1
github.com/orandin/slog-gorm v1.4.0
+ github.com/pressly/goose/v3 v3.27.1
github.com/robfig/cron/v3 v3.0.1
github.com/samber/slog-echo v1.23.0
github.com/shirou/gopsutil/v4 v4.26.4
@@ -129,8 +129,6 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/go-containerregistry v0.21.1 // indirect
- github.com/google/go-github/v39 v39.2.0 // indirect
- github.com/google/go-querystring v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/subcommands v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.29.0 // indirect
@@ -154,13 +152,12 @@ require (
github.com/klauspost/compress v1.18.6 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/labstack/gommon v0.5.0 // indirect
- github.com/lib/pq v1.12.3 // indirect
github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.22 // indirect
github.com/mattn/go-runewidth v0.0.23 // indirect
github.com/mattn/go-shellwords v1.0.13 // indirect
- github.com/mattn/go-sqlite3 v1.14.44 // indirect
+ github.com/mfridman/interpolate v0.0.2 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/locker v1.0.1 // indirect
@@ -185,6 +182,7 @@ require (
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.11.0 // indirect
github.com/sergi/go-diff v1.4.0 // indirect
+ github.com/sethvargo/go-retry v0.3.0 // indirect
github.com/shibumi/go-pathspec v1.3.0 // indirect
github.com/sigstore/sigstore v1.10.6 // indirect
github.com/sigstore/sigstore-go v1.1.4 // indirect
@@ -221,6 +219,7 @@ require (
go.opentelemetry.io/otel/sdk/metric v1.44.0 // indirect
go.opentelemetry.io/otel/trace v1.44.0 // indirect
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
+ go.uber.org/multierr v1.11.0 // indirect
go.yaml.in/yaml/v4 v4.0.0-rc.4 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/term v0.43.0 // indirect
diff --git a/backend/go.sum b/backend/go.sum
index 9eee8092f..f4a9e6ba4 100644
--- a/backend/go.sum
+++ b/backend/go.sum
@@ -123,8 +123,6 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/depot/depot-go v0.5.2 h1:mQHyy1tGdmMKnlmsThjAc9mU3NHGUUUyzmnkhyotV+E=
github.com/depot/depot-go v0.5.2/go.mod h1:QQtSqwRn0flx4KxrUVSJGlh0hTFeZ19MLYvOcJbxtP0=
-github.com/dhui/dktest v0.4.6 h1:+DPKyScKSEp3VLtbMDHcUq6V5Lm5zfZZVb0Sk7Ahom4=
-github.com/dhui/dktest v0.4.6/go.mod h1:JHTSYDtKkvFNFHJKqCzVzqXecyv+tKt8EzceOmQOgbU=
github.com/digitorus/pkcs7 v0.0.0-20230818184609-3a137a874352 h1:ge14PCmCvPjpMQMIAH7uKg0lrtNSOdpYsRXlwk3QbaE=
github.com/digitorus/pkcs7 v0.0.0-20230818184609-3a137a874352/go.mod h1:SKVExuS+vpu2l9IoOc0RwqE7NYnb0JlcFHFnEJkVDzc=
github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 h1:lxmTCgmHE1GUYL7P0MlNa00M67axePTq+9nBSGddR8I=
@@ -253,28 +251,16 @@ 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/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY=
github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
-github.com/golang-migrate/migrate/v4 v4.19.1 h1:OCyb44lFuQfYXYLx1SCxPZQGU7mcaZ7gH9yH4jSFbBA=
-github.com/golang-migrate/migrate/v4 v4.19.1/go.mod h1:CTcgfjxhaUtsLipnLoQRWCrjYXycRz/g5+RWDuYgPrE=
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
-github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
-github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/certificate-transparency-go v1.3.2 h1:9ahSNZF2o7SYMaKaXhAumVEzXB2QaayzII9C8rv7v+A=
github.com/google/certificate-transparency-go v1.3.2/go.mod h1:H5FpMUaGa5Ab2+KCYsxg6sELw3Flkl7pGZzWdBoYLXs=
-github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/go-containerregistry v0.21.1 h1:sOt/o9BS2b87FnR7wxXPvRKU1XVJn2QCwOS5g8zQXlc=
github.com/google/go-containerregistry v0.21.1/go.mod h1:ctO5aCaewH4AK1AumSF5DPW+0+R+d2FmylMJdp5G7p0=
-github.com/google/go-github/v39 v39.2.0 h1:rNNM311XtPOz5rDdsJXAp2o8F67X9FnROXTvto3aSnQ=
-github.com/google/go-github/v39 v39.2.0/go.mod h1:C1s8C5aCC9L+JXIYpJM5GYytdX52vC1bLvHEF1IhBrE=
-github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
-github.com/google/go-querystring v1.2.0 h1:yhqkPbu2/OH+V9BfpCVPZkNmUXhb2gBxJArfhIxNtP0=
-github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJZD5A0egEOmkqU=
github.com/google/pprof v0.0.0-20260507013755-92041b743c96 h1:YDDnaZ9afWajDboPMt9Vikqca/yWAX7KAxVzb4lJU1M=
github.com/google/pprof v0.0.0-20260507013755-92041b743c96/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
@@ -353,8 +339,6 @@ github.com/labstack/echo/v4 v4.15.2 h1:nnh2sCzGCVYnU+wCisMPiYapEg/QVo/gcI9ePKg5/
github.com/labstack/echo/v4 v4.15.2/go.mod h1:Xzp1Ns1RA2c9fY7nSgUJkpkUZGNbEIVHZbtbOMPktBI=
github.com/labstack/gommon v0.5.0 h1:6VSQ2NOzsnEJ5W6+84E0RbcaDDmgB6NIAzWCczTEe6c=
github.com/labstack/gommon v0.5.0/go.mod h1:Rzlg7HHy1maLfzBYGg9NZcVuz1sA68HHhLjhcEllYE0=
-github.com/lib/pq v1.12.3 h1:tTWxr2YLKwIvK90ZXEw8GP7UFHtcbTtty8zsI+YjrfQ=
-github.com/lib/pq v1.12.3/go.mod h1:/p+8NSbOcwzAEI7wiMXFlgydTwcgTr3OSKMsD2BitpA=
github.com/lmittmann/tint v1.1.3 h1:Hv4EaHWXQr+GTFnOU4VKf8UvAtZgn0VuKT+G0wFlO3I=
github.com/lmittmann/tint v1.1.3/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE=
github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e h1:Q6MvJtQK/iRcRtzAscm/zF23XxJlbECiGPyRicsX+Ak=
@@ -367,8 +351,8 @@ github.com/mattn/go-runewidth v0.0.23 h1:7ykA0T0jkPpzSvMS5i9uoNn2Xy3R383f9HDx3Ry
github.com/mattn/go-runewidth v0.0.23/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/mattn/go-shellwords v1.0.13 h1:DC0OMEpGjm6LfNFU4ckYcvbQKyp2vE8atyFGXNtDcf4=
github.com/mattn/go-shellwords v1.0.13/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
-github.com/mattn/go-sqlite3 v1.14.44 h1:3VSe+xafpbzsLbdr2AWlAZk9yRHiBhTBakioXaCKTF8=
-github.com/mattn/go-sqlite3 v1.14.44/go.mod h1:pjEuOr8IwzLJP2MfGeTb0A35jauH+C2kbHKBr7yXKVQ=
+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/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
github.com/moby/buildkit v0.29.0 h1:wxLEFbCOJntEDjSNNN2YWd8zxltZxT5muDQ0LzpbtpU=
@@ -416,7 +400,6 @@ github.com/nicholas-fedor/shoutrrr v0.15.1/go.mod h1:xrdV1ab2W0/xa5kM6WP9mBuqVuJ
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
github.com/oklog/ulid/v2 v2.1.1 h1:suPZ4ARWLOJLegGFiZZ1dFAkqzhMjL3J1TzI+5wHz8s=
github.com/oklog/ulid/v2 v2.1.1/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
-github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
github.com/onsi/ginkgo/v2 v2.29.0 h1:rfh+ZFjgJhYWRoIqVf3Uwx/W20yLrcrE2h2GmYVRaag=
github.com/onsi/ginkgo/v2 v2.29.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44=
github.com/onsi/gomega v1.41.0 h1:OwKp4pXNgVxf6sCplzYo794OFNuoL2q2SBMU5NSWOjA=
@@ -444,14 +427,16 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU=
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
+github.com/pressly/goose/v3 v3.27.1 h1:6uEvcprBybDmW4hcz3gYujhARhye+GoWKhEWyzD5sh4=
+github.com/pressly/goose/v3 v3.27.1/go.mod h1:maruOxsPnIG2yHHyo8UqKWXYKFcH7Q76csUV7+7KYoM=
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4=
github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw=
-github.com/prometheus/procfs v0.19.2 h1:zUMhqEW66Ex7OXIiDkll3tl9a1ZdilUOd/F6ZXw4Vws=
-github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw=
+github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc=
+github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo=
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/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
@@ -469,6 +454,8 @@ github.com/secure-systems-lab/go-securesystemslib v0.11.0 h1:iuCR9kcMFD4QurdKrGv
github.com/secure-systems-lab/go-securesystemslib v0.11.0/go.mod h1:+PMOTjUGwHj2vcZ+TFKlb1tXRbrdWE1LYDT5i9JC80Q=
github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw=
github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
+github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
+github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas=
github.com/shibumi/go-pathspec v1.3.0 h1:QUyMZhFo0Md5B8zV8x2tesohbb5kfbpTi9rBnKh5dkI=
github.com/shibumi/go-pathspec v1.3.0/go.mod h1:Xutfslp817l2I1cZvgcfeMQJG5QnU2lh5tVaaMCl3jE=
github.com/shirou/gopsutil/v4 v4.26.4 h1:B4SXVbcwTyrocPHEmWBC4uCYr4Xcu3MK1TXqbprAOWY=
@@ -593,6 +580,8 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
+go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
+go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
@@ -602,7 +591,6 @@ go.yaml.in/yaml/v4 v4.0.0-rc.4/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfP
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
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-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988=
golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc=
@@ -611,15 +599,12 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.36.0 h1:JJjpVx6myfUsUdAzZuOSTTmRE0PfZeNWzzvKrP7amb4=
golang.org/x/mod v0.36.0/go.mod h1:moc6ELqsWcOw5Ef3xVprK5ul/MvtVvkIXLziUOICjUQ=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/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-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
-golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -648,7 +633,6 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn
golang.org/x/term v0.43.0 h1:S4RLU2sB31O/NCl+zFN9Aru9A/Cq2aqKpTZJ6B+DwT4=
golang.org/x/term v0.43.0/go.mod h1:lrhlHNdQJHO+1qVYiHfFKVuVioJIheAc3fBSMFYEIsk=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
@@ -667,7 +651,6 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
-google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto/googleapis/api v0.0.0-20260511170946-3700d4141b60 h1:3WsB1FAbiRIf2tOxscWKs3pQBD9he1NsrnbhMuWfekc=
google.golang.org/genproto/googleapis/api v0.0.0-20260511170946-3700d4141b60/go.mod h1:7yoXV7RIh5gblj/xVYoogxAWvA9wUeVbpsK/M694l00=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260511170946-3700d4141b60 h1:seT2EwLWM78plQ7wcDfuWBc/4FAEAXDDiaSol4ku4qo=
diff --git a/backend/internal/database/database.go b/backend/internal/database/database.go
index 9b133f3a9..46edc59fc 100644
--- a/backend/internal/database/database.go
+++ b/backend/internal/database/database.go
@@ -2,32 +2,25 @@ package database
import (
"context"
+ "database/sql"
"errors"
"fmt"
+ "io/fs"
"log/slog"
- "math"
"net/url"
"os"
"path/filepath"
"slices"
+ "strconv"
"strings"
"time"
glsqlite "github.com/glebarez/sqlite"
- "github.com/golang-migrate/migrate/v4"
- "github.com/golang-migrate/migrate/v4/database"
- postgresMigrate "github.com/golang-migrate/migrate/v4/database/postgres"
- sqliteMigrate "github.com/golang-migrate/migrate/v4/database/sqlite3"
- "github.com/golang-migrate/migrate/v4/source"
-
- // Registers the "github" source driver for golang-migrate (remote migration sources).
- _ "github.com/golang-migrate/migrate/v4/source/github"
- "github.com/golang-migrate/migrate/v4/source/iofs"
+ goose "github.com/pressly/goose/v3"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/logger"
- "github.com/getarcaneapp/arcane/backend/internal/config"
"github.com/getarcaneapp/arcane/backend/resources"
)
@@ -37,14 +30,13 @@ type DB struct {
type MigrationOptions struct {
AllowDowngrade bool
- githubRef string
}
const (
- migrationRepositoryOwner = "getarcaneapp"
- migrationRepositoryName = "arcane"
- migrationRepositoryPath = "backend/resources/migrations"
- migrationRepositoryRefFallback = "main"
+ dbProviderSQLite = "sqlite"
+ dbProviderPostgres = "postgres"
+ gooseVersionTable = "goose_db_version"
+ legacyVersionTable = "schema_migrations"
)
var customGormLogger logger.Interface
@@ -53,24 +45,8 @@ func SetGormLogger(l logger.Interface) {
customGormLogger = l
}
-func (o MigrationOptions) githubRefInternal() string {
- return githubRefForRevisionInternal(o, config.Revision)
-}
-
-func githubRefForRevisionInternal(options MigrationOptions, revision string) string {
- if ref := strings.TrimSpace(options.githubRef); ref != "" {
- return ref
- }
-
- if ref := strings.TrimSpace(revision); ref != "" && ref != "unknown" {
- return ref
- }
-
- return migrationRepositoryRefFallback
-}
-
func Initialize(ctx context.Context, databaseURL string, options MigrationOptions) (*DB, error) {
- db, err := connectDatabase(ctx, databaseURL)
+ db, err := connectDatabaseInternal(ctx, databaseURL)
if err != nil {
return nil, fmt.Errorf("failed to connect to database: %w", err)
}
@@ -85,33 +61,17 @@ func Initialize(ctx context.Context, databaseURL string, options MigrationOption
return nil, fmt.Errorf("failed to get sql.DB: %w", err)
}
- // Determine database provider for migrations
var dbProvider string
switch {
case strings.HasPrefix(databaseURL, "file:"):
- dbProvider = "sqlite"
+ dbProvider = dbProviderSQLite
case strings.HasPrefix(databaseURL, "postgres"):
- dbProvider = "postgres"
+ dbProvider = dbProviderPostgres
default:
return nil, fmt.Errorf("unsupported database type in URL: %s", databaseURL)
}
- // Choose the correct driver for migrations
- var driver database.Driver
- switch dbProvider {
- case "sqlite":
- driver, err = sqliteMigrate.WithInstance(sqlDB, &sqliteMigrate.Config{})
- case "postgres":
- driver, err = postgresMigrate.WithInstance(sqlDB, &postgresMigrate.Config{})
- default:
- return nil, fmt.Errorf("unsupported database provider: %s", dbProvider)
- }
- if err != nil {
- return nil, fmt.Errorf("failed to create migration driver: %w", err)
- }
-
- // Run migrations
- if err := migrateDatabase(driver, dbProvider, options); err != nil {
+ if err := migrateDatabaseInternal(ctx, sqlDB, dbProvider, options); err != nil {
slog.Error("Failed to run migrations", "error", err)
return nil, fmt.Errorf("failed to run migrations: %w", err)
}
@@ -130,16 +90,16 @@ func Initialize(ctx context.Context, databaseURL string, options MigrationOption
return db, nil
}
-func connectDatabase(ctx context.Context, databaseURL string) (*DB, error) {
+func connectDatabaseInternal(ctx context.Context, databaseURL string) (*DB, error) {
var dialector gorm.Dialector
switch {
case strings.HasPrefix(databaseURL, "file:"):
- connString, err := parseSqliteConnectionString(databaseURL)
+ connString, err := parseSqliteConnectionStringInternal(databaseURL)
if err != nil {
return nil, fmt.Errorf("failed to parse SQLite connection string: %w", err)
}
- if err := ensureSQLiteDirectory(connString); err != nil {
+ if err := ensureSQLiteDirectoryInternal(connString); err != nil {
return nil, fmt.Errorf("failed to prepare SQLite directory: %w", err)
}
dialector = glsqlite.Open(connString)
@@ -181,208 +141,344 @@ func connectDatabase(ctx context.Context, databaseURL string) (*DB, error) {
return nil, err
}
-func migrateDatabase(driver database.Driver, dbProvider string, options MigrationOptions) error {
+func migrateDatabaseInternal(ctx context.Context, db *sql.DB, dbProvider string, options MigrationOptions) error {
requiredVersion, err := getHighestEmbeddedMigrationVersionInternal(dbProvider)
if err != nil {
return fmt.Errorf("failed to determine target migration version for %s: %w", dbProvider, err)
}
- return migrateDatabaseToVersionInternal(driver, dbProvider, options, requiredVersion)
+ return migrateDatabaseToVersionInternal(ctx, db, dbProvider, options, requiredVersion)
}
-func migrateDatabaseToVersionInternal(driver database.Driver, dbProvider string, options MigrationOptions, requiredVersion uint) error {
- embeddedMigrate, embeddedSource, err := newEmbeddedMigrateInstanceInternal(driver, dbProvider)
+func migrateDatabaseToVersionInternal(ctx context.Context, db *sql.DB, dbProvider string, options MigrationOptions, requiredVersion int64) error {
+ if err := adoptLegacyMigrationStateInternal(ctx, db, dbProvider, options); err != nil {
+ return err
+ }
+
+ provider, err := newGooseProviderInternal(db, dbProvider)
if err != nil {
- return fmt.Errorf("failed to create embedded migration instance: %w", err)
+ return fmt.Errorf("failed to create goose provider for %s: %w", dbProvider, err)
}
- defer closeMigrateSourceInternal(embeddedSource, "embedded migrate source")
- currentVersion, dirty, hasVersion, err := currentMigrationStateInternal(embeddedMigrate)
+ currentVersion, err := provider.GetDBVersion(ctx)
if err != nil {
- return err
+ return fmt.Errorf("failed to determine current migration version for %s: %w", dbProvider, err)
}
- logMigrationStateInternal(dbProvider, currentVersion, requiredVersion, dirty, hasVersion)
+ logMigrationStateInternal(dbProvider, currentVersion, requiredVersion)
- if hasVersion && dirty && currentVersion < requiredVersion {
+ if currentVersion > requiredVersion {
if !options.AllowDowngrade {
- return fmt.Errorf("database schema version %d is dirty (interrupted forward migration); resolve it manually or set ALLOW_DOWNGRADE=true to clear the dirty flag and re-apply the migration", currentVersion)
- }
-
- forceVersion, forceErr := safeUintToIntInternal(currentVersion)
- if forceErr != nil {
- return fmt.Errorf("failed to convert current migration version %d while clearing dirty state: %w", currentVersion, forceErr)
+ return fmt.Errorf("database schema version %d is newer than this Arcane binary supports (target %d for %s); downgrade requires ALLOW_DOWNGRADE=true and a database backup before startup", currentVersion, requiredVersion, dbProvider)
}
- if err := embeddedMigrate.Force(forceVersion); err != nil {
- return fmt.Errorf("failed to clear dirty migration state for version %d: %w", currentVersion, err)
+ missingVersions, err := missingEmbeddedDowngradeMigrationsInternal(ctx, db, dbProvider, requiredVersion)
+ if err != nil {
+ return err
}
-
- slog.Warn("Cleared dirty migration state before re-applying forward migration", "provider", dbProvider, "version", currentVersion)
- }
-
- if hasVersion && dirty && currentVersion == requiredVersion {
- if !options.AllowDowngrade {
- return fmt.Errorf("database schema version %d is dirty; resolve it manually or set ALLOW_DOWNGRADE=true to clear the dirty flag after verifying the database state", currentVersion)
+ if len(missingVersions) > 0 {
+ return fmt.Errorf("cannot downgrade database from version %d to %d for %s: embedded Goose migrations are missing for applied version(s) %v, so the rollback SQL is unavailable in this Arcane binary; ALLOW_DOWNGRADE=true is not sufficient, restore the database from a backup taken before the newer schema was applied", currentVersion, requiredVersion, dbProvider, missingVersions)
}
- forceVersion, forceErr := safeUintToIntInternal(currentVersion)
- if forceErr != nil {
- return fmt.Errorf("failed to convert current migration version %d while clearing dirty state: %w", currentVersion, forceErr)
+ if _, err := provider.DownTo(ctx, requiredVersion); err != nil {
+ return fmt.Errorf("failed to downgrade database from version %d to %d for %s using embedded Goose migrations: %w", currentVersion, requiredVersion, dbProvider, err)
}
- if err := embeddedMigrate.Force(forceVersion); err != nil {
- return fmt.Errorf("failed to clear dirty migration state for version %d: %w", currentVersion, err)
- }
+ slog.Info("Database downgrade completed successfully", "provider", dbProvider, "fromVersion", currentVersion, "toVersion", requiredVersion)
+ return nil
+ }
- slog.Warn("Cleared dirty migration state at current version because ALLOW_DOWNGRADE=true", "provider", dbProvider, "version", currentVersion)
- logUpToDateStateInternal(embeddedMigrate, dbProvider)
+ if currentVersion == requiredVersion {
+ logUpToDateStateInternal(dbProvider, currentVersion)
return nil
}
- if hasVersion && currentVersion > requiredVersion {
- if !options.AllowDowngrade {
- return fmt.Errorf("database schema version %d is newer than this Arcane binary supports (target %d for %s); downgrade requires ALLOW_DOWNGRADE=true and a database backup before startup", currentVersion, requiredVersion, dbProvider)
- }
+ if _, err := provider.UpTo(ctx, requiredVersion); err != nil {
+ return fmt.Errorf("failed to apply embedded Goose migrations for %s: %w", dbProvider, err)
+ }
- if err := migrateDatabaseFromGitHubInternal(driver, dbProvider, currentVersion, requiredVersion, options.githubRefInternal()); err != nil {
- return err
- }
+ slog.Info("Database migrations completed successfully", "provider", dbProvider, "targetVersion", requiredVersion)
+ return nil
+}
- return nil
+func newGooseProviderInternal(db *sql.DB, dbProvider string) (*goose.Provider, error) {
+ migrationsFS, err := embeddedMigrationFSInternal(dbProvider)
+ if err != nil {
+ return nil, err
}
- upErr := embeddedMigrate.Up()
- if upErr != nil && !errors.Is(upErr, migrate.ErrNoChange) {
- return fmt.Errorf("failed to apply embedded migrations for %s: %w", dbProvider, upErr)
+ dialect, err := gooseDialectInternal(dbProvider)
+ if err != nil {
+ return nil, err
}
- if errors.Is(upErr, migrate.ErrNoChange) {
- logUpToDateStateInternal(embeddedMigrate, dbProvider)
- return nil
+ return goose.NewProvider(dialect, db, migrationsFS)
+}
+
+func embeddedMigrationFSInternal(dbProvider string) (fs.FS, error) {
+ migrationsFS, err := fs.Sub(resources.FS, "migrations/"+dbProvider)
+ if err != nil {
+ return nil, fmt.Errorf("failed to load embedded migrations for %s: %w", dbProvider, err)
}
- slog.Info("Database migrations completed successfully", "provider", dbProvider, "targetVersion", requiredVersion)
- return nil
+ return migrationsFS, nil
}
-func migrateDatabaseFromGitHubInternal(driver database.Driver, dbProvider string, currentVersion, requiredVersion uint, githubRef string) error {
- slog.Warn("Database downgrade detected",
- "provider", dbProvider,
- "currentVersion", currentVersion,
- "requiredVersion", requiredVersion,
- "source", buildGitHubMigrationSourceURLInternal(dbProvider, githubRef),
- )
+func gooseDialectInternal(dbProvider string) (goose.Dialect, error) {
+ switch dbProvider {
+ case dbProviderSQLite:
+ return goose.DialectSQLite3, nil
+ case dbProviderPostgres:
+ return goose.DialectPostgres, nil
+ default:
+ return "", fmt.Errorf("unsupported database provider: %s", dbProvider)
+ }
+}
- githubSource, err := newGitHubMigrationSourceInternal(dbProvider, githubRef)
+func adoptLegacyMigrationStateInternal(ctx context.Context, db *sql.DB, dbProvider string, options MigrationOptions) error {
+ legacyState, ok, err := legacyMigrationStateInternal(ctx, db, dbProvider)
if err != nil {
- return fmt.Errorf("failed to create GitHub migration source for %s downgrade: %w; hint: ensure outbound GitHub access is available and set GITHUB_TOKEN if the GitHub API is rate-limited", dbProvider, err)
+ return err
+ }
+ if !ok {
+ return nil
}
- return migrateDatabaseFromSourceInternal(driver, dbProvider, currentVersion, requiredVersion, "github", "github migrate source", githubSource)
-}
+ if legacyState.dirty {
+ if !options.AllowDowngrade {
+ return fmt.Errorf("database schema version %d is dirty in legacy %s table; resolve it manually or set ALLOW_DOWNGRADE=true after verifying the database state", legacyState.version, legacyVersionTable)
+ }
-func migrateDatabaseFromSourceInternal(driver database.Driver, dbProvider string, currentVersion, requiredVersion uint, sourceName, sourceLabel string, sourceDriver source.Driver) error {
- if sourceDriver == nil {
- return fmt.Errorf("failed to create %s migration source for provider %s: source driver is nil", sourceName, dbProvider)
+ if err := clearLegacyMigrationDirtyInternal(ctx, db, dbProvider, legacyState.version); err != nil {
+ return err
+ }
+ slog.Warn("Cleared dirty legacy migration state because ALLOW_DOWNGRADE=true", "provider", dbProvider, "version", legacyState.version)
}
- defer closeMigrateSourceInternal(sourceDriver, sourceLabel)
- migrationInstance, err := migrate.NewWithInstance(sourceName, sourceDriver, "arcane", driver)
+ hasGooseState, err := gooseVersionTableHasAppliedMigrationsInternal(ctx, db, dbProvider)
if err != nil {
- return fmt.Errorf("failed to create %s migration instance for provider %s: %w", sourceName, dbProvider, err)
+ return err
+ }
+ if hasGooseState {
+ return nil
}
- forceVersion, err := safeUintToIntInternal(currentVersion)
+ versions, err := getEmbeddedMigrationVersionsInternal(dbProvider)
if err != nil {
- return fmt.Errorf("failed to convert current migration version %d for downgrade: %w", currentVersion, err)
+ return err
}
- if err := migrationInstance.Force(forceVersion); err != nil {
- return fmt.Errorf("failed to normalize migration state before downgrade from %d to %d for %s: %w", currentVersion, requiredVersion, dbProvider, err)
+ tx, err := db.BeginTx(ctx, nil)
+ if err != nil {
+ return fmt.Errorf("failed to start legacy migration adoption transaction for %s: %w", dbProvider, err)
}
+ defer func() {
+ _ = tx.Rollback()
+ }()
- err = migrationInstance.Migrate(requiredVersion)
- if err != nil && !errors.Is(err, migrate.ErrNoChange) {
- return fmt.Errorf("failed to downgrade database from version %d to %d for %s: %w", currentVersion, requiredVersion, dbProvider, err)
+ if err := createGooseVersionTableInternal(ctx, tx, dbProvider); err != nil {
+ return err
}
- slog.Info("Database downgrade completed successfully", "provider", dbProvider, "fromVersion", currentVersion, "toVersion", requiredVersion)
- return nil
-}
+ if err := clearGooseVersionTableInternal(ctx, tx, dbProvider); err != nil {
+ return err
+ }
-func newEmbeddedMigrationSourceInternal(dbProvider string) (source.Driver, error) {
- sourceDriver, err := iofs.New(resources.FS, "migrations/"+dbProvider)
- if err != nil {
- return nil, fmt.Errorf("failed to create embedded migration source: %w", err)
+ if err := insertGooseMigrationVersionInternal(ctx, tx, dbProvider, 0); err != nil {
+ return err
+ }
+ versionApplied := legacyState.version == 0
+ for _, version := range versions {
+ if version > legacyState.version {
+ break
+ }
+ if err := insertGooseMigrationVersionInternal(ctx, tx, dbProvider, version); err != nil {
+ return err
+ }
+ if version == legacyState.version {
+ versionApplied = true
+ }
+ }
+ if !versionApplied {
+ if err := insertGooseMigrationVersionInternal(ctx, tx, dbProvider, legacyState.version); err != nil {
+ return err
+ }
+ }
+
+ if err := tx.Commit(); err != nil {
+ return fmt.Errorf("failed to commit legacy migration adoption for %s: %w", dbProvider, err)
}
- return sourceDriver, nil
+ slog.Info("Adopted legacy migration state into Goose", "provider", dbProvider, "legacyVersion", legacyState.version)
+ return nil
}
-func newEmbeddedMigrateInstanceInternal(driver database.Driver, dbProvider string) (*migrate.Migrate, source.Driver, error) {
- sourceDriver, err := newEmbeddedMigrationSourceInternal(dbProvider)
+type legacyMigrationState struct {
+ version int64
+ dirty bool
+}
+
+func legacyMigrationStateInternal(ctx context.Context, db *sql.DB, dbProvider string) (legacyMigrationState, bool, error) {
+ exists, err := legacyVersionTableExistsInternal(ctx, db, dbProvider)
if err != nil {
- return nil, nil, err
+ return legacyMigrationState{}, false, err
+ }
+ if !exists {
+ return legacyMigrationState{}, false, nil
}
- m, err := migrate.NewWithInstance("iofs", sourceDriver, "arcane", driver)
+ var state legacyMigrationState
+ err = db.QueryRowContext(ctx, fmt.Sprintf("SELECT version, dirty FROM %s ORDER BY version DESC LIMIT 1", legacyVersionTable)).Scan(&state.version, &state.dirty)
+ if errors.Is(err, sql.ErrNoRows) {
+ return legacyMigrationState{}, false, nil
+ }
if err != nil {
- if closeErr := sourceDriver.Close(); closeErr != nil {
- slog.Warn("Failed to close embedded migration source after instance creation failure", "provider", dbProvider, "error", closeErr)
- }
- return nil, nil, fmt.Errorf("failed to create migration instance: %w", err)
+ return legacyMigrationState{}, false, fmt.Errorf("failed to read legacy migration state for %s: %w", dbProvider, err)
}
- return m, sourceDriver, nil
+ return state, true, nil
}
-func newGitHubMigrationSourceInternal(dbProvider string, githubRef string) (source.Driver, error) {
- sourceDriver, err := source.Open(buildGitHubMigrationSourceURLInternal(dbProvider, githubRef))
- if err != nil {
- return nil, fmt.Errorf("failed to create GitHub migration source for provider %s: %w", dbProvider, err)
+func legacyVersionTableExistsInternal(ctx context.Context, db *sql.DB, dbProvider string) (bool, error) {
+ switch dbProvider {
+ case dbProviderSQLite:
+ var count int
+ if err := db.QueryRowContext(ctx, `SELECT COUNT(*) FROM sqlite_master WHERE type = 'table' AND name = ?`, legacyVersionTable).Scan(&count); err != nil {
+ return false, fmt.Errorf("failed to check legacy migration table for sqlite: %w", err)
+ }
+ return count > 0, nil
+ case dbProviderPostgres:
+ var exists bool
+ if err := db.QueryRowContext(ctx, `SELECT to_regclass($1) IS NOT NULL`, legacyVersionTable).Scan(&exists); err != nil {
+ return false, fmt.Errorf("failed to check legacy migration table for postgres: %w", err)
+ }
+ return exists, nil
+ default:
+ return false, fmt.Errorf("unsupported database provider: %s", dbProvider)
}
+}
- return sourceDriver, nil
+func clearLegacyMigrationDirtyInternal(ctx context.Context, db *sql.DB, dbProvider string, version int64) error {
+ queryFormat := "UPDATE " + legacyVersionTable + " SET dirty = false WHERE version = %s"
+ query, args, err := sqlWithProviderPlaceholderInternal(dbProvider, queryFormat, version)
+ if err != nil {
+ return err
+ }
+ if _, err := db.ExecContext(ctx, query, args...); err != nil {
+ return fmt.Errorf("failed to clear legacy dirty migration state for %s version %d: %w", dbProvider, version, err)
+ }
+ return nil
}
-func buildGitHubMigrationSourceURLInternal(dbProvider, githubRef string) string {
- return fmt.Sprintf("github://%s/%s/%s/%s#%s", migrationRepositoryOwner, migrationRepositoryName, migrationRepositoryPath, dbProvider, githubRef)
+func gooseVersionTableHasAppliedMigrationsInternal(ctx context.Context, db *sql.DB, dbProvider string) (bool, error) {
+ exists, err := gooseVersionTableExistsInternal(ctx, db, dbProvider)
+ if err != nil || !exists {
+ return false, err
+ }
+
+ var version int64
+ if err := db.QueryRowContext(ctx, fmt.Sprintf("SELECT COALESCE(MAX(version_id), 0) FROM %s WHERE is_applied = %s", gooseVersionTable, appliedLiteralInternal(dbProvider))).Scan(&version); err != nil {
+ return false, fmt.Errorf("failed to read Goose migration state for %s: %w", dbProvider, err)
+ }
+ return version > 0, nil
}
-func safeUintToIntInternal(value uint) (int, error) {
- if value > uint(math.MaxInt) {
- return 0, fmt.Errorf("value %d exceeds max int", value)
+func gooseVersionTableExistsInternal(ctx context.Context, db *sql.DB, dbProvider string) (bool, error) {
+ switch dbProvider {
+ case dbProviderSQLite:
+ var count int
+ if err := db.QueryRowContext(ctx, `SELECT COUNT(*) FROM sqlite_master WHERE type = 'table' AND name = ?`, gooseVersionTable).Scan(&count); err != nil {
+ return false, fmt.Errorf("failed to check Goose version table for sqlite: %w", err)
+ }
+ return count > 0, nil
+ case dbProviderPostgres:
+ var exists bool
+ if err := db.QueryRowContext(ctx, `SELECT to_regclass($1) IS NOT NULL`, gooseVersionTable).Scan(&exists); err != nil {
+ return false, fmt.Errorf("failed to check Goose version table for postgres: %w", err)
+ }
+ return exists, nil
+ default:
+ return false, fmt.Errorf("unsupported database provider: %s", dbProvider)
}
+}
- return int(value), nil
+type sqlExecerInternal interface {
+ ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}
-func currentMigrationStateInternal(m *migrate.Migrate) (version uint, dirty bool, hasVersion bool, err error) {
- version, dirty, err = m.Version()
- if errors.Is(err, migrate.ErrNilVersion) {
- return 0, false, false, nil
+func createGooseVersionTableInternal(ctx context.Context, execer sqlExecerInternal, dbProvider string) error {
+ var query string
+ switch dbProvider {
+ case dbProviderSQLite:
+ query = fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ version_id INTEGER NOT NULL,
+ is_applied INTEGER NOT NULL,
+ tstamp TIMESTAMP DEFAULT (datetime('now'))
+)`, gooseVersionTable)
+ case dbProviderPostgres:
+ query = fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s (
+ id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
+ version_id bigint NOT NULL,
+ is_applied boolean NOT NULL,
+ tstamp timestamp NOT NULL DEFAULT now()
+)`, gooseVersionTable)
+ default:
+ return fmt.Errorf("unsupported database provider: %s", dbProvider)
}
- if err != nil {
- return 0, false, false, fmt.Errorf("failed to determine current migration version: %w", err)
+
+ if _, err := execer.ExecContext(ctx, query); err != nil {
+ return fmt.Errorf("failed to create Goose version table for %s: %w", dbProvider, err)
+ }
+ return nil
+}
+
+func clearGooseVersionTableInternal(ctx context.Context, execer sqlExecerInternal, dbProvider string) error {
+ if _, err := execer.ExecContext(ctx, "DELETE FROM "+gooseVersionTable); err != nil {
+ return fmt.Errorf("failed to clear Goose version table for %s: %w", dbProvider, err)
}
+ return nil
+}
- return version, dirty, true, nil
+func insertGooseMigrationVersionInternal(ctx context.Context, execer sqlExecerInternal, dbProvider string, version int64) error {
+ switch dbProvider {
+ case dbProviderSQLite:
+ if _, err := execer.ExecContext(ctx, fmt.Sprintf("INSERT INTO %s (version_id, is_applied) VALUES (?, ?)", gooseVersionTable), version, true); err != nil {
+ return fmt.Errorf("failed to insert Goose migration version %d for sqlite: %w", version, err)
+ }
+ case dbProviderPostgres:
+ if _, err := execer.ExecContext(ctx, fmt.Sprintf("INSERT INTO %s (version_id, is_applied) VALUES ($1, $2)", gooseVersionTable), version, true); err != nil {
+ return fmt.Errorf("failed to insert Goose migration version %d for postgres: %w", version, err)
+ }
+ default:
+ return fmt.Errorf("unsupported database provider: %s", dbProvider)
+ }
+ return nil
}
-func logUpToDateStateInternal(m *migrate.Migrate, dbProvider string) {
- version, versionDirty, versionErr := m.Version()
- switch {
- case errors.Is(versionErr, migrate.ErrNilVersion):
- slog.Info("Database schema is up to date", "provider", dbProvider, "migrationVersion", 0, "dirty", false)
- case versionErr != nil:
- slog.Info("Database schema is up to date", "provider", dbProvider)
+func sqlWithProviderPlaceholderInternal(dbProvider, queryFormat string, arg any) (string, []any, error) {
+ switch dbProvider {
+ case dbProviderSQLite:
+ return fmt.Sprintf(queryFormat, "?"), []any{arg}, nil
+ case dbProviderPostgres:
+ return fmt.Sprintf(queryFormat, "$1"), []any{arg}, nil
default:
- slog.Info("Database schema is up to date", "provider", dbProvider, "migrationVersion", version, "dirty", versionDirty)
+ return "", nil, fmt.Errorf("unsupported database provider: %s", dbProvider)
}
}
-func getHighestEmbeddedMigrationVersionInternal(dbProvider string) (uint, error) {
+func appliedLiteralInternal(dbProvider string) string {
+ if dbProvider == dbProviderPostgres {
+ return "true"
+ }
+ return "1"
+}
+
+func logUpToDateStateInternal(dbProvider string, version int64) {
+ slog.Info("Database schema is up to date", "provider", dbProvider, "migrationVersion", version)
+}
+
+func getHighestEmbeddedMigrationVersionInternal(dbProvider string) (int64, error) {
versions, err := getEmbeddedMigrationVersionsInternal(dbProvider)
if err != nil {
return 0, err
@@ -394,27 +490,31 @@ func getHighestEmbeddedMigrationVersionInternal(dbProvider string) (uint, error)
return versions[len(versions)-1], nil
}
-func getEmbeddedMigrationVersionsInternal(dbProvider string) ([]uint, error) {
+func getEmbeddedMigrationVersionsInternal(dbProvider string) ([]int64, error) {
entries, err := resources.FS.ReadDir("migrations/" + dbProvider)
if err != nil {
return nil, fmt.Errorf("failed to read embedded migrations for %s: %w", dbProvider, err)
}
- versionsMap := make(map[uint]struct{})
+ versionsMap := make(map[int64]struct{})
for _, entry := range entries {
- if entry.IsDir() {
+ if entry.IsDir() || !strings.HasSuffix(entry.Name(), ".sql") {
continue
}
- migration, parseErr := source.DefaultParse(entry.Name())
+ versionText, _, found := strings.Cut(entry.Name(), "_")
+ if !found {
+ continue
+ }
+ version, parseErr := strconv.ParseInt(versionText, 10, 64)
if parseErr != nil {
continue
}
- versionsMap[migration.Version] = struct{}{}
+ versionsMap[version] = struct{}{}
}
- versions := make([]uint, 0, len(versionsMap))
+ versions := make([]int64, 0, len(versionsMap))
for version := range versionsMap {
versions = append(versions, version)
}
@@ -423,27 +523,60 @@ func getEmbeddedMigrationVersionsInternal(dbProvider string) ([]uint, error) {
return versions, nil
}
-func logMigrationStateInternal(dbProvider string, currentVersion, requiredVersion uint, dirty, hasVersion bool) {
- if !hasVersion {
- slog.Info("Resolved database migration state", "provider", dbProvider, "currentVersion", 0, "requiredVersion", requiredVersion, "dirty", false)
- return
+// missingEmbeddedDowngradeMigrationsInternal returns the applied migration
+// versions above requiredVersion that have no matching embedded migration file.
+// Goose can only roll back migrations whose .Down SQL is embedded in this
+// binary, so any such missing version makes an embedded-only downgrade
+// impossible and signals that a restore from backup is required.
+func missingEmbeddedDowngradeMigrationsInternal(ctx context.Context, db *sql.DB, dbProvider string, requiredVersion int64) ([]int64, error) {
+ embeddedVersions, err := getEmbeddedMigrationVersionsInternal(dbProvider)
+ if err != nil {
+ return nil, err
}
- slog.Info("Resolved database migration state", "provider", dbProvider, "currentVersion", currentVersion, "requiredVersion", requiredVersion, "dirty", dirty)
-}
+ embeddedSet := make(map[int64]struct{}, len(embeddedVersions))
+ for _, version := range embeddedVersions {
+ embeddedSet[version] = struct{}{}
+ }
-func closeMigrateSourceInternal(sourceDriver source.Driver, sourceName string) {
- if sourceDriver == nil {
- return
+ queryFormat := "SELECT DISTINCT version_id FROM " + gooseVersionTable +
+ " WHERE is_applied = " + appliedLiteralInternal(dbProvider) +
+ " AND version_id > %s ORDER BY version_id"
+ query, args, err := sqlWithProviderPlaceholderInternal(dbProvider, queryFormat, requiredVersion)
+ if err != nil {
+ return nil, err
}
- sourceErr := sourceDriver.Close()
- if sourceErr != nil {
- slog.Warn("Failed to close migration source", "source", sourceName, "error", sourceErr)
+ rows, err := db.QueryContext(ctx, query, args...)
+ if err != nil {
+ return nil, fmt.Errorf("failed to read applied migration versions for %s: %w", dbProvider, err)
}
+ defer func() {
+ _ = rows.Close()
+ }()
+
+ var missing []int64
+ for rows.Next() {
+ var version int64
+ if err := rows.Scan(&version); err != nil {
+ return nil, fmt.Errorf("failed to scan applied migration version for %s: %w", dbProvider, err)
+ }
+ if _, ok := embeddedSet[version]; !ok {
+ missing = append(missing, version)
+ }
+ }
+ if err := rows.Err(); err != nil {
+ return nil, fmt.Errorf("failed to iterate applied migration versions for %s: %w", dbProvider, err)
+ }
+
+ return missing, nil
}
-func parseSqliteConnectionString(connString string) (string, error) {
+func logMigrationStateInternal(dbProvider string, currentVersion, requiredVersion int64) {
+ slog.Info("Resolved database migration state", "provider", dbProvider, "currentVersion", currentVersion, "requiredVersion", requiredVersion)
+}
+
+func parseSqliteConnectionStringInternal(connString string) (string, error) {
if !strings.HasPrefix(connString, "file:") {
connString = "file:" + connString
}
@@ -502,15 +635,19 @@ func (db *DB) FindEnvironmentIDByApiKey(ctx context.Context, apiKey string) (str
}
func (db *DB) Close() error {
- sqlDB, err := db.DB.DB()
+ sqlDB, err := db.SQLDB()
if err != nil {
return err
}
return sqlDB.Close()
}
+func (db *DB) SQLDB() (*sql.DB, error) {
+ return db.DB.DB()
+}
+
// Create parent directory for file-based SQLite if needed
-func ensureSQLiteDirectory(connString string) error {
+func ensureSQLiteDirectoryInternal(connString string) error {
if !strings.HasPrefix(connString, "file:") {
return nil
}
@@ -519,13 +656,11 @@ func ensureSQLiteDirectory(connString string) error {
return fmt.Errorf("failed to parse SQLite DSN: %w", err)
}
- // For "file:data/arcane.db?...", path is in Opaque; for "file:/abs/path.db", it's in Path
+ // For "file:data/arcane.db?...", path is in Opaque; for "file:/abs/path.db", it's in Path.
pathPart := u.Opaque
if pathPart == "" {
pathPart = u.Path
}
- // Trim leading slash to handle file:/relative.db
- pathPart = strings.TrimPrefix(pathPart, "/")
if pathPart == "" || strings.HasPrefix(pathPart, ":memory:") {
return nil
}
diff --git a/backend/internal/database/database_test.go b/backend/internal/database/database_test.go
index b72db6693..3d422607a 100644
--- a/backend/internal/database/database_test.go
+++ b/backend/internal/database/database_test.go
@@ -2,14 +2,11 @@ package database
import (
"context"
+ stdsql "database/sql"
"path/filepath"
+ "strconv"
"testing"
- glsqlite "github.com/glebarez/sqlite"
- "github.com/golang-migrate/migrate/v4/database"
- sqliteMigrate "github.com/golang-migrate/migrate/v4/database/sqlite3"
- "gorm.io/gorm"
-
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -29,122 +26,112 @@ func TestGetEmbeddedMigrationVersions_ProvidersMatch(t *testing.T) {
assert.Equal(t, sqliteVersions[len(sqliteVersions)-1], highest)
}
+func TestEnsureSQLiteDirectoryPreservesAbsoluteFilePath(t *testing.T) {
+ tempDir := t.TempDir()
+ dsn := "file:" + filepath.Join(tempDir, "nested", "arcane-test.db")
+
+ require.NoError(t, ensureSQLiteDirectoryInternal(dsn))
+ require.DirExists(t, filepath.Join(tempDir, "nested"))
+ require.NoDirExists(t, filepath.Join("var", "folders"))
+}
+
func TestMigrateDatabase_BlocksDowngradeWithoutFlag(t *testing.T) {
- dbDir := t.TempDir()
- driver := newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db")
- require.NoError(t, migrateDatabase(driver, "sqlite", MigrationOptions{}))
+ ctx := context.Background()
+ rawDB, dsn := newSQLiteSQLDBInternal(t, t.TempDir(), "arcane-test.db")
+ require.NoError(t, migrateDatabaseInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{}))
targetVersion := downgradeTargetVersionInternal(t)
- err := migrateDatabaseToVersionInternal(newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db"), "sqlite", MigrationOptions{}, targetVersion)
+ err := migrateDatabaseToVersionInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{}, targetVersion)
require.Error(t, err)
assert.ErrorContains(t, err, "ALLOW_DOWNGRADE=true")
assert.ErrorContains(t, err, "newer than this Arcane binary supports")
-}
-func TestMigrateDatabase_DowngradesWhenAllowed(t *testing.T) {
- dbDir := t.TempDir()
- driver := newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db")
- require.NoError(t, migrateDatabase(driver, "sqlite", MigrationOptions{}))
- targetVersion := downgradeTargetVersionInternal(t)
highestVersion, err := getHighestEmbeddedMigrationVersionInternal("sqlite")
require.NoError(t, err)
- sourceDriver, err := newEmbeddedMigrationSourceInternal("sqlite")
- require.NoError(t, err)
+ assert.Equal(t, highestVersion, readGooseSQLiteVersionInternal(t, dsn))
+}
- require.NoError(t, migrateDatabaseFromSourceInternal(newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db"), "sqlite", highestVersion, targetVersion, "iofs", "test embedded migrate source", sourceDriver))
+func TestMigrateDatabase_DowngradesWhenAllowed(t *testing.T) {
+ ctx := context.Background()
+ rawDB, dsn := newSQLiteSQLDBInternal(t, t.TempDir(), "arcane-test.db")
+ require.NoError(t, migrateDatabaseInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{}))
+ targetVersion := downgradeTargetVersionInternal(t)
- instance, checkSourceDriver, err := newEmbeddedMigrateInstanceInternal(newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db"), "sqlite")
- require.NoError(t, err)
- defer closeMigrateSourceInternal(checkSourceDriver, "test embedded migrate source")
- currentVersion, currentDirty, versionErr := instance.Version()
- require.NoError(t, versionErr)
- assert.Equal(t, targetVersion, currentVersion)
- assert.False(t, currentDirty)
+ require.NoError(t, migrateDatabaseToVersionInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{AllowDowngrade: true}, targetVersion))
+ assert.Equal(t, targetVersion, readGooseSQLiteVersionInternal(t, dsn))
}
-func TestMigrateDatabase_DowngradesDirtyStateWhenAllowed(t *testing.T) {
- dbDir := t.TempDir()
- driver := newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db")
- require.NoError(t, migrateDatabase(driver, "sqlite", MigrationOptions{}))
- targetVersion := downgradeTargetVersionInternal(t)
+func TestMigrateDatabase_BlocksFutureGooseVersionWithoutFlag(t *testing.T) {
+ ctx := context.Background()
+ rawDB, dsn := newSQLiteSQLDBInternal(t, t.TempDir(), "arcane-future.db")
highestVersion, err := getHighestEmbeddedMigrationVersionInternal("sqlite")
require.NoError(t, err)
- highestVersionInt, err := safeUintToIntInternal(highestVersion)
- require.NoError(t, err)
- require.NoError(t, newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db").SetVersion(highestVersionInt, true))
- sourceDriver, err := newEmbeddedMigrationSourceInternal("sqlite")
- require.NoError(t, err)
+ require.NoError(t, createGooseVersionTableInternal(ctx, rawDB, dbProviderSQLite))
+ require.NoError(t, insertGooseMigrationVersionInternal(ctx, rawDB, dbProviderSQLite, 0))
+ require.NoError(t, insertGooseMigrationVersionInternal(ctx, rawDB, dbProviderSQLite, highestVersion+1))
- require.NoError(t, migrateDatabaseFromSourceInternal(newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db"), "sqlite", highestVersion, targetVersion, "iofs", "test embedded migrate source", sourceDriver))
+ err = migrateDatabaseInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{})
+ require.Error(t, err)
+ assert.ErrorContains(t, err, "newer than this Arcane binary supports")
+ assert.Equal(t, highestVersion+1, readGooseSQLiteVersionInternal(t, dsn))
+}
- instance, checkSourceDriver, err := newEmbeddedMigrateInstanceInternal(newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db"), "sqlite")
+func TestMigrateDatabase_BlocksDowngradeWhenEmbeddedMigrationMissing(t *testing.T) {
+ ctx := context.Background()
+ rawDB, dsn := newSQLiteSQLDBInternal(t, t.TempDir(), "arcane-missing-down.db")
+ highestVersion, err := getHighestEmbeddedMigrationVersionInternal("sqlite")
require.NoError(t, err)
- defer closeMigrateSourceInternal(checkSourceDriver, "test embedded migrate source")
- currentVersion, dirty, versionErr := instance.Version()
- require.NoError(t, versionErr)
- assert.Equal(t, targetVersion, currentVersion)
- assert.False(t, dirty)
+ require.NoError(t, createGooseVersionTableInternal(ctx, rawDB, dbProviderSQLite))
+ require.NoError(t, insertGooseMigrationVersionInternal(ctx, rawDB, dbProviderSQLite, 0))
+ require.NoError(t, insertGooseMigrationVersionInternal(ctx, rawDB, dbProviderSQLite, highestVersion+1))
+
+ err = migrateDatabaseInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{AllowDowngrade: true})
+ require.Error(t, err)
+ assert.ErrorContains(t, err, "ALLOW_DOWNGRADE=true is not sufficient")
+ assert.ErrorContains(t, err, "restore the database from a backup")
+ assert.ErrorContains(t, err, strconv.FormatInt(highestVersion+1, 10))
+ assert.Equal(t, highestVersion+1, readGooseSQLiteVersionInternal(t, dsn))
}
-func TestMigrateDatabase_DirtyCurrentVersionRequiresResolution(t *testing.T) {
- dbDir := t.TempDir()
- driver := newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db")
- require.NoError(t, migrateDatabase(driver, "sqlite", MigrationOptions{}))
+func TestMigrateDatabase_BlocksDirtyLegacyCurrentVersion(t *testing.T) {
+ ctx := context.Background()
+ rawDB, dsn := newSQLiteSQLDBInternal(t, t.TempDir(), "arcane-legacy-current-dirty.db")
highestVersion, err := getHighestEmbeddedMigrationVersionInternal("sqlite")
require.NoError(t, err)
- highestVersionInt, err := safeUintToIntInternal(highestVersion)
- require.NoError(t, err)
- require.NoError(t, newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db").SetVersion(highestVersionInt, true))
+ seedLegacyMigrationStateInternal(t, dsn, highestVersion, true)
- err = migrateDatabaseToVersionInternal(newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db"), "sqlite", MigrationOptions{}, highestVersion)
+ err = migrateDatabaseInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{})
require.Error(t, err)
assert.ErrorContains(t, err, "is dirty")
assert.ErrorContains(t, err, "ALLOW_DOWNGRADE=true")
- require.NoError(t, migrateDatabaseToVersionInternal(newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db"), "sqlite", MigrationOptions{AllowDowngrade: true}, highestVersion))
-
- instance, sourceDriver, err := newEmbeddedMigrateInstanceInternal(newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db"), "sqlite")
- require.NoError(t, err)
- defer closeMigrateSourceInternal(sourceDriver, "test embedded migrate source")
- currentVersion, dirty, versionErr := instance.Version()
- require.NoError(t, versionErr)
- assert.Equal(t, highestVersion, currentVersion)
- assert.False(t, dirty)
+ require.NoError(t, migrateDatabaseInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{AllowDowngrade: true}))
+ assert.Equal(t, highestVersion, readGooseSQLiteVersionInternal(t, dsn))
+ assertLegacyMigrationDirtyInternal(t, dsn, false)
}
-func TestMigrateDatabase_DirtyOlderVersionRequiresResolution(t *testing.T) {
- dbDir := t.TempDir()
- driver := newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db")
- require.NoError(t, migrateDatabase(driver, "sqlite", MigrationOptions{}))
+func TestMigrateDatabase_BlocksDirtyLegacyOlderVersion(t *testing.T) {
+ ctx := context.Background()
+ rawDB, dsn := newSQLiteSQLDBInternal(t, t.TempDir(), "arcane-legacy-older-dirty.db")
targetVersion := downgradeTargetVersionInternal(t)
- highestVersion, err := getHighestEmbeddedMigrationVersionInternal("sqlite")
- require.NoError(t, err)
- sourceDriver, err := newEmbeddedMigrationSourceInternal("sqlite")
- require.NoError(t, err)
+ require.NoError(t, migrateDatabaseInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{}))
+ require.NoError(t, migrateDatabaseToVersionInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{AllowDowngrade: true}, targetVersion))
+ require.NoError(t, clearGooseVersionTableInternal(ctx, rawDB, dbProviderSQLite))
+ seedLegacyMigrationStateInternal(t, dsn, targetVersion, true)
- require.NoError(t, migrateDatabaseFromSourceInternal(newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db"), "sqlite", highestVersion, targetVersion, "iofs", "test embedded migrate source", sourceDriver))
-
- targetVersionInt, err := safeUintToIntInternal(targetVersion)
- require.NoError(t, err)
- require.NoError(t, newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db").SetVersion(targetVersionInt, true))
-
- err = migrateDatabaseToVersionInternal(newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db"), "sqlite", MigrationOptions{}, highestVersion)
+ err := migrateDatabaseInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{})
require.Error(t, err)
- assert.ErrorContains(t, err, "interrupted forward migration")
+ assert.ErrorContains(t, err, "is dirty")
assert.ErrorContains(t, err, "ALLOW_DOWNGRADE=true")
- require.NoError(t, migrateDatabaseToVersionInternal(newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db"), "sqlite", MigrationOptions{AllowDowngrade: true}, highestVersion))
-
- instance, sourceDriver, err := newEmbeddedMigrateInstanceInternal(newSQLiteMigrationDriverInternal(t, dbDir, "arcane-test.db"), "sqlite")
+ require.NoError(t, migrateDatabaseInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{AllowDowngrade: true}))
+ highestVersion, err := getHighestEmbeddedMigrationVersionInternal("sqlite")
require.NoError(t, err)
- defer closeMigrateSourceInternal(sourceDriver, "test embedded migrate source")
- currentVersion, dirty, versionErr := instance.Version()
- require.NoError(t, versionErr)
- assert.Equal(t, highestVersion, currentVersion)
- assert.False(t, dirty)
+ assert.Equal(t, highestVersion, readGooseSQLiteVersionInternal(t, dsn))
+ assertLegacyMigrationDirtyInternal(t, dsn, false)
}
-func downgradeTargetVersionInternal(t *testing.T) uint {
+func downgradeTargetVersionInternal(t *testing.T) int64 {
t.Helper()
allVersions, err := getEmbeddedMigrationVersionsInternal("sqlite")
@@ -154,23 +141,17 @@ func downgradeTargetVersionInternal(t *testing.T) uint {
return allVersions[len(allVersions)-2]
}
-func newSQLiteMigrationDriverInternal(t *testing.T, dirPath, fileName string) database.Driver {
+func newSQLiteSQLDBInternal(t *testing.T, dirPath, fileName string) (*stdsql.DB, string) {
t.Helper()
dsn := "file:" + filepath.Join(dirPath, fileName)
- db, err := gorm.Open(glsqlite.Open(dsn), &gorm.Config{})
- require.NoError(t, err)
-
- sqlDB, err := db.DB()
+ db, err := stdsql.Open("sqlite", dsn)
require.NoError(t, err)
t.Cleanup(func() {
- _ = sqlDB.Close()
+ require.NoError(t, db.Close())
})
- driver, err := sqliteMigrate.WithInstance(sqlDB, &sqliteMigrate.Config{})
- require.NoError(t, err)
-
- return driver
+ return db, dsn
}
func TestInitialize_AllowsMigrationOptions(t *testing.T) {
@@ -187,6 +168,100 @@ func TestInitialize_AllowsMigrationOptions(t *testing.T) {
require.NoError(t, db.Close())
}
+func TestInitialize_RecordsGooseVersionOnFreshSQLite(t *testing.T) {
+ ctx := context.Background()
+ dsn := "file:" + filepath.Join(t.TempDir(), "arcane-goose-fresh.db")
+
+ db, err := Initialize(ctx, dsn, MigrationOptions{})
+ require.NoError(t, err)
+ require.NotNil(t, db)
+ t.Cleanup(func() {
+ require.NoError(t, db.Close())
+ })
+
+ highest, err := getHighestEmbeddedMigrationVersionInternal("sqlite")
+ require.NoError(t, err)
+ assert.Equal(t, highest, readGooseSQLiteVersionInternal(t, dsn))
+}
+
+func TestInitialize_AdoptsCleanLegacyMigrationState(t *testing.T) {
+ ctx := context.Background()
+ dsn := "file:" + filepath.Join(t.TempDir(), "arcane-legacy-clean.db")
+ highest, err := getHighestEmbeddedMigrationVersionInternal("sqlite")
+ require.NoError(t, err)
+ seedLegacyMigrationStateInternal(t, dsn, highest, false)
+
+ db, err := Initialize(ctx, dsn, MigrationOptions{})
+ require.NoError(t, err)
+ require.NotNil(t, db)
+ t.Cleanup(func() {
+ require.NoError(t, db.Close())
+ })
+
+ assert.Equal(t, highest, readGooseSQLiteVersionInternal(t, dsn))
+ assertLegacyMigrationDirtyInternal(t, dsn, false)
+}
+
+func TestInitialize_RollsBackFailedLegacyMigrationAdoption(t *testing.T) {
+ ctx := context.Background()
+ rawDB, dsn := newSQLiteSQLDBInternal(t, t.TempDir(), "arcane-legacy-rollback.db")
+ highest, err := getHighestEmbeddedMigrationVersionInternal("sqlite")
+ require.NoError(t, err)
+ seedLegacyMigrationStateInternal(t, dsn, highest, false)
+
+ _, err = rawDB.Exec(`
+CREATE TABLE goose_db_version (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ version_id INTEGER NOT NULL,
+ is_applied INTEGER NOT NULL CHECK (is_applied = 0),
+ tstamp TIMESTAMP DEFAULT (datetime('now'))
+)`)
+ require.NoError(t, err)
+ _, err = rawDB.Exec(`INSERT INTO goose_db_version (version_id, is_applied) VALUES (?, ?)`, 0, 0)
+ require.NoError(t, err)
+
+ err = adoptLegacyMigrationStateInternal(ctx, rawDB, dbProviderSQLite, MigrationOptions{})
+ require.Error(t, err)
+ assert.ErrorContains(t, err, "failed to insert Goose migration version")
+
+ var rowCount int
+ err = rawDB.QueryRowContext(ctx, `SELECT COUNT(*) FROM goose_db_version WHERE version_id = 0 AND is_applied = 0`).Scan(&rowCount)
+ require.NoError(t, err)
+ assert.Equal(t, 1, rowCount)
+}
+
+func TestInitialize_BlocksDirtyLegacyMigrationState(t *testing.T) {
+ ctx := context.Background()
+ dsn := "file:" + filepath.Join(t.TempDir(), "arcane-legacy-dirty.db")
+ highest, err := getHighestEmbeddedMigrationVersionInternal("sqlite")
+ require.NoError(t, err)
+ seedLegacyMigrationStateInternal(t, dsn, highest, true)
+
+ db, err := Initialize(ctx, dsn, MigrationOptions{})
+ require.Error(t, err)
+ require.Nil(t, db)
+ assert.ErrorContains(t, err, "dirty")
+ assert.ErrorContains(t, err, "ALLOW_DOWNGRADE=true")
+}
+
+func TestInitialize_ClearsDirtyLegacyMigrationStateWhenAllowed(t *testing.T) {
+ ctx := context.Background()
+ dsn := "file:" + filepath.Join(t.TempDir(), "arcane-legacy-dirty-allowed.db")
+ highest, err := getHighestEmbeddedMigrationVersionInternal("sqlite")
+ require.NoError(t, err)
+ seedLegacyMigrationStateInternal(t, dsn, highest, true)
+
+ db, err := Initialize(ctx, dsn, MigrationOptions{AllowDowngrade: true})
+ require.NoError(t, err)
+ require.NotNil(t, db)
+ t.Cleanup(func() {
+ require.NoError(t, db.Close())
+ })
+
+ assert.Equal(t, highest, readGooseSQLiteVersionInternal(t, dsn))
+ assertLegacyMigrationDirtyInternal(t, dsn, false)
+}
+
func TestInitialize_CreatesQueryPerformanceIndexes(t *testing.T) {
ctx := context.Background()
dsn := "file:" + filepath.Join(t.TempDir(), "arcane-indexes.db")
@@ -243,12 +318,6 @@ func TestInitialize_CreatesQueryPerformanceIndexes(t *testing.T) {
}
}
-func TestMigrationOptions_GitHubRefUsesBuildRevision(t *testing.T) {
- assert.Equal(t, "abc123def456", githubRefForRevisionInternal(MigrationOptions{}, "abc123def456"))
- assert.Equal(t, "custom-ref", githubRefForRevisionInternal(MigrationOptions{githubRef: "custom-ref"}, "abc123def456"))
- assert.Equal(t, migrationRepositoryRefFallback, githubRefForRevisionInternal(MigrationOptions{}, "unknown"))
-}
-
func assertSQLiteIndexExistsInternal(t *testing.T, db *DB, indexName string) {
t.Helper()
@@ -276,3 +345,53 @@ func assertSQLiteIndexMissingInternal(t *testing.T, db *DB, indexName string) {
require.NoError(t, err)
assert.Zero(t, count, "expected index %s to be removed", indexName)
}
+
+func seedLegacyMigrationStateInternal(t *testing.T, dsn string, version int64, dirty bool) {
+ t.Helper()
+
+ rawDB, err := stdsql.Open("sqlite", dsn)
+ require.NoError(t, err)
+ t.Cleanup(func() {
+ require.NoError(t, rawDB.Close())
+ })
+
+ _, err = rawDB.Exec(`
+CREATE TABLE schema_migrations (
+ version INTEGER NOT NULL PRIMARY KEY,
+ dirty BOOLEAN NOT NULL
+)`)
+ require.NoError(t, err)
+
+ _, err = rawDB.Exec(`INSERT INTO schema_migrations (version, dirty) VALUES (?, ?)`, version, dirty)
+ require.NoError(t, err)
+}
+
+func readGooseSQLiteVersionInternal(t *testing.T, dsn string) int64 {
+ t.Helper()
+
+ rawDB, err := stdsql.Open("sqlite", dsn)
+ require.NoError(t, err)
+ defer func() {
+ require.NoError(t, rawDB.Close())
+ }()
+
+ var version int64
+ err = rawDB.QueryRow(`SELECT COALESCE(MAX(version_id), 0) FROM goose_db_version WHERE is_applied = 1`).Scan(&version)
+ require.NoError(t, err)
+ return version
+}
+
+func assertLegacyMigrationDirtyInternal(t *testing.T, dsn string, expected bool) {
+ t.Helper()
+
+ rawDB, err := stdsql.Open("sqlite", dsn)
+ require.NoError(t, err)
+ defer func() {
+ require.NoError(t, rawDB.Close())
+ }()
+
+ var dirty bool
+ err = rawDB.QueryRow(`SELECT dirty FROM schema_migrations ORDER BY version DESC LIMIT 1`).Scan(&dirty)
+ require.NoError(t, err)
+ assert.Equal(t, expected, dirty)
+}
diff --git a/backend/resources/migrations/postgres/001_initial_schema.down.sql b/backend/resources/migrations/postgres/001_initial_schema.down.sql
deleted file mode 100644
index ef08827be..000000000
--- a/backend/resources/migrations/postgres/001_initial_schema.down.sql
+++ /dev/null
@@ -1,29 +0,0 @@
--- Drop all tables in reverse order of dependencies (PostgreSQL)
-
-DROP INDEX IF EXISTS idx_auto_update_start_time;
-DROP INDEX IF EXISTS idx_auto_update_resource_id;
-DROP INDEX IF EXISTS idx_image_update_tag;
-DROP INDEX IF EXISTS idx_image_update_repository;
-DROP INDEX IF EXISTS idx_images_tag;
-DROP INDEX IF EXISTS idx_images_repo;
-DROP INDEX IF EXISTS idx_containers_stack_id;
-DROP INDEX IF EXISTS idx_user_sessions_token;
-DROP INDEX IF EXISTS idx_user_sessions_user_id;
-DROP INDEX IF EXISTS idx_settings_public;
-DROP INDEX IF EXISTS idx_settings_key;
-DROP INDEX IF EXISTS idx_events_timestamp;
-
-DROP TABLE IF EXISTS auto_update_records;
-DROP TABLE IF EXISTS container_registries;
-DROP TABLE IF EXISTS compose_templates;
-DROP TABLE IF EXISTS template_registries;
-DROP TABLE IF EXISTS image_update_table;
-DROP TABLE IF EXISTS networks_table;
-DROP TABLE IF EXISTS volumes_table;
-DROP TABLE IF EXISTS images_table;
-DROP TABLE IF EXISTS containers_table;
-DROP TABLE IF EXISTS environments;
-DROP TABLE IF EXISTS stacks_table;
-DROP TABLE IF EXISTS user_sessions_table;
-DROP TABLE IF EXISTS users_table;
-DROP TABLE IF EXISTS settings;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/001_initial_schema.up.sql b/backend/resources/migrations/postgres/001_initial_schema.sql
similarity index 85%
rename from backend/resources/migrations/postgres/001_initial_schema.up.sql
rename to backend/resources/migrations/postgres/001_initial_schema.sql
index 9275fade1..b99630aef 100644
--- a/backend/resources/migrations/postgres/001_initial_schema.up.sql
+++ b/backend/resources/migrations/postgres/001_initial_schema.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS settings (
key TEXT NOT NULL PRIMARY KEY,
value TEXT NOT NULL,
@@ -214,4 +215,35 @@ CREATE INDEX IF NOT EXISTS idx_images_tag ON images_table(tag);
CREATE INDEX IF NOT EXISTS idx_image_update_repository ON image_update_table(repository);
CREATE INDEX IF NOT EXISTS idx_image_update_tag ON image_update_table(tag);
CREATE INDEX IF NOT EXISTS idx_auto_update_resource_id ON auto_update_records(resource_id);
-CREATE INDEX IF NOT EXISTS idx_auto_update_start_time ON auto_update_records(start_time);
\ No newline at end of file
+CREATE INDEX IF NOT EXISTS idx_auto_update_start_time ON auto_update_records(start_time);
+
+-- +goose Down
+-- Drop all tables in reverse order of dependencies (PostgreSQL)
+
+DROP INDEX IF EXISTS idx_auto_update_start_time;
+DROP INDEX IF EXISTS idx_auto_update_resource_id;
+DROP INDEX IF EXISTS idx_image_update_tag;
+DROP INDEX IF EXISTS idx_image_update_repository;
+DROP INDEX IF EXISTS idx_images_tag;
+DROP INDEX IF EXISTS idx_images_repo;
+DROP INDEX IF EXISTS idx_containers_stack_id;
+DROP INDEX IF EXISTS idx_user_sessions_token;
+DROP INDEX IF EXISTS idx_user_sessions_user_id;
+DROP INDEX IF EXISTS idx_settings_public;
+DROP INDEX IF EXISTS idx_settings_key;
+DROP INDEX IF EXISTS idx_events_timestamp;
+
+DROP TABLE IF EXISTS auto_update_records;
+DROP TABLE IF EXISTS container_registries;
+DROP TABLE IF EXISTS compose_templates;
+DROP TABLE IF EXISTS template_registries;
+DROP TABLE IF EXISTS image_update_table;
+DROP TABLE IF EXISTS networks_table;
+DROP TABLE IF EXISTS volumes_table;
+DROP TABLE IF EXISTS images_table;
+DROP TABLE IF EXISTS containers_table;
+DROP TABLE IF EXISTS environments;
+DROP TABLE IF EXISTS stacks_table;
+DROP TABLE IF EXISTS user_sessions_table;
+DROP TABLE IF EXISTS users_table;
+DROP TABLE IF EXISTS settings;
diff --git a/backend/resources/migrations/postgres/002_create_events_table.down.sql b/backend/resources/migrations/postgres/002_create_events_table.down.sql
deleted file mode 100644
index d11cf905c..000000000
--- a/backend/resources/migrations/postgres/002_create_events_table.down.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-DROP INDEX IF EXISTS idx_events_timestamp;
-DROP INDEX IF EXISTS idx_events_environment_id;
-DROP INDEX IF EXISTS idx_events_user_id;
-DROP INDEX IF EXISTS idx_events_resource_id;
-DROP INDEX IF EXISTS idx_events_resource_type;
-DROP INDEX IF EXISTS idx_events_severity;
-DROP INDEX IF EXISTS idx_events_type;
-
-DROP TABLE IF EXISTS events;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/002_create_events_table.up.sql b/backend/resources/migrations/postgres/002_create_events_table.sql
similarity index 73%
rename from backend/resources/migrations/postgres/002_create_events_table.up.sql
rename to backend/resources/migrations/postgres/002_create_events_table.sql
index 79a8c5d18..d1ba5cc66 100644
--- a/backend/resources/migrations/postgres/002_create_events_table.up.sql
+++ b/backend/resources/migrations/postgres/002_create_events_table.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS events (
id TEXT PRIMARY KEY,
type TEXT NOT NULL,
@@ -23,4 +24,15 @@ CREATE INDEX IF NOT EXISTS idx_events_resource_type ON events(resource_type);
CREATE INDEX IF NOT EXISTS idx_events_resource_id ON events(resource_id);
CREATE INDEX IF NOT EXISTS idx_events_user_id ON events(user_id);
CREATE INDEX IF NOT EXISTS idx_events_environment_id ON events(environment_id);
-CREATE INDEX IF NOT EXISTS idx_events_timestamp ON events(timestamp);
\ No newline at end of file
+CREATE INDEX IF NOT EXISTS idx_events_timestamp ON events(timestamp);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_events_timestamp;
+DROP INDEX IF EXISTS idx_events_environment_id;
+DROP INDEX IF EXISTS idx_events_user_id;
+DROP INDEX IF EXISTS idx_events_resource_id;
+DROP INDEX IF EXISTS idx_events_resource_type;
+DROP INDEX IF EXISTS idx_events_severity;
+DROP INDEX IF EXISTS idx_events_type;
+
+DROP TABLE IF EXISTS events;
diff --git a/backend/resources/migrations/postgres/003_remove_events_environment_fk.down.sql b/backend/resources/migrations/postgres/003_remove_events_environment_fk.sql
similarity index 51%
rename from backend/resources/migrations/postgres/003_remove_events_environment_fk.down.sql
rename to backend/resources/migrations/postgres/003_remove_events_environment_fk.sql
index d81744e3a..d2454887b 100644
--- a/backend/resources/migrations/postgres/003_remove_events_environment_fk.down.sql
+++ b/backend/resources/migrations/postgres/003_remove_events_environment_fk.sql
@@ -1,2 +1,6 @@
+-- +goose Up
+ALTER TABLE events DROP CONSTRAINT IF EXISTS events_environment_id_fkey;
+
+-- +goose Down
ALTER TABLE events ADD CONSTRAINT events_environment_id_fkey
- FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE SET NULL;
\ No newline at end of file
+ FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE SET NULL;
diff --git a/backend/resources/migrations/postgres/003_remove_events_environment_fk.up.sql b/backend/resources/migrations/postgres/003_remove_events_environment_fk.up.sql
deleted file mode 100644
index 7764d41e8..000000000
--- a/backend/resources/migrations/postgres/003_remove_events_environment_fk.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE events DROP CONSTRAINT IF EXISTS events_environment_id_fkey;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/004_project_cache.down.sql b/backend/resources/migrations/postgres/004_project_cache.down.sql
deleted file mode 100644
index 4048f9cef..000000000
--- a/backend/resources/migrations/postgres/004_project_cache.down.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-DROP INDEX IF EXISTS idx_project_cache_auto_update;
-DROP INDEX IF EXISTS idx_project_cache_cached_at;
-DROP INDEX IF EXISTS idx_project_cache_status;
-DROP TABLE IF EXISTS project_cache;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/004_project_cache.up.sql b/backend/resources/migrations/postgres/004_project_cache.sql
similarity index 78%
rename from backend/resources/migrations/postgres/004_project_cache.up.sql
rename to backend/resources/migrations/postgres/004_project_cache.sql
index 079c29c48..2da1e42e6 100644
--- a/backend/resources/migrations/postgres/004_project_cache.up.sql
+++ b/backend/resources/migrations/postgres/004_project_cache.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS project_cache (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
stack_id VARCHAR(255) UNIQUE NOT NULL,
@@ -18,4 +19,10 @@ CREATE TABLE IF NOT EXISTS project_cache (
CREATE INDEX idx_project_cache_status ON project_cache(status);
CREATE INDEX idx_project_cache_cached_at ON project_cache(cached_at);
-CREATE INDEX idx_project_cache_auto_update ON project_cache(auto_update);
\ No newline at end of file
+CREATE INDEX idx_project_cache_auto_update ON project_cache(auto_update);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_project_cache_auto_update;
+DROP INDEX IF EXISTS idx_project_cache_cached_at;
+DROP INDEX IF EXISTS idx_project_cache_status;
+DROP TABLE IF EXISTS project_cache;
diff --git a/backend/resources/migrations/postgres/005_drop_user_sessions_table.down.sql b/backend/resources/migrations/postgres/005_drop_user_sessions_table.sql
similarity index 72%
rename from backend/resources/migrations/postgres/005_drop_user_sessions_table.down.sql
rename to backend/resources/migrations/postgres/005_drop_user_sessions_table.sql
index 20c1409f5..7967ae065 100644
--- a/backend/resources/migrations/postgres/005_drop_user_sessions_table.down.sql
+++ b/backend/resources/migrations/postgres/005_drop_user_sessions_table.sql
@@ -1,3 +1,11 @@
+-- +goose Up
+-- Drop indexes first (safe if they exist), then drop the table
+DROP INDEX IF EXISTS idx_user_sessions_token;
+DROP INDEX IF EXISTS idx_user_sessions_user_id;
+
+DROP TABLE IF EXISTS user_sessions_table;
+
+-- +goose Down
-- Recreate user_sessions_table (matches initial schema)
CREATE TABLE IF NOT EXISTS user_sessions_table (
id TEXT PRIMARY KEY,
@@ -13,4 +21,4 @@ CREATE TABLE IF NOT EXISTS user_sessions_table (
);
CREATE INDEX IF NOT EXISTS idx_user_sessions_user_id ON user_sessions_table(user_id);
-CREATE INDEX IF NOT EXISTS idx_user_sessions_token ON user_sessions_table(token);
\ No newline at end of file
+CREATE INDEX IF NOT EXISTS idx_user_sessions_token ON user_sessions_table(token);
diff --git a/backend/resources/migrations/postgres/005_drop_user_sessions_table.up.sql b/backend/resources/migrations/postgres/005_drop_user_sessions_table.up.sql
deleted file mode 100644
index 73c49bd0b..000000000
--- a/backend/resources/migrations/postgres/005_drop_user_sessions_table.up.sql
+++ /dev/null
@@ -1,5 +0,0 @@
--- Drop indexes first (safe if they exist), then drop the table
-DROP INDEX IF EXISTS idx_user_sessions_token;
-DROP INDEX IF EXISTS idx_user_sessions_user_id;
-
-DROP TABLE IF EXISTS user_sessions_table;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/006_rename_tables.down.sql b/backend/resources/migrations/postgres/006_rename_tables.down.sql
deleted file mode 100644
index 62305769c..000000000
--- a/backend/resources/migrations/postgres/006_rename_tables.down.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-ALTER TABLE IF EXISTS users RENAME TO users_table;
-ALTER TABLE IF EXISTS image_updates RENAME TO image_update_table;
-ALTER TABLE IF EXISTS images RENAME TO images_table;
-ALTER TABLE IF EXISTS containers RENAME TO containers_table;
-ALTER TABLE IF EXISTS networks RENAME TO networks_table;
-ALTER TABLE IF EXISTS volumes RENAME TO volumes_table;
-ALTER TABLE IF EXISTS stacks RENAME TO stacks_table;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/006_rename_tables.sql b/backend/resources/migrations/postgres/006_rename_tables.sql
new file mode 100644
index 000000000..d7c3a52d5
--- /dev/null
+++ b/backend/resources/migrations/postgres/006_rename_tables.sql
@@ -0,0 +1,17 @@
+-- +goose Up
+ALTER TABLE IF EXISTS users_table RENAME TO users;
+ALTER TABLE IF EXISTS image_update_table RENAME TO image_updates;
+ALTER TABLE IF EXISTS images_table RENAME TO images;
+ALTER TABLE IF EXISTS containers_table RENAME TO containers;
+ALTER TABLE IF EXISTS networks_table RENAME TO networks;
+ALTER TABLE IF EXISTS volumes_table RENAME TO volumes;
+ALTER TABLE IF EXISTS stacks_table RENAME TO stacks;
+
+-- +goose Down
+ALTER TABLE IF EXISTS users RENAME TO users_table;
+ALTER TABLE IF EXISTS image_updates RENAME TO image_update_table;
+ALTER TABLE IF EXISTS images RENAME TO images_table;
+ALTER TABLE IF EXISTS containers RENAME TO containers_table;
+ALTER TABLE IF EXISTS networks RENAME TO networks_table;
+ALTER TABLE IF EXISTS volumes RENAME TO volumes_table;
+ALTER TABLE IF EXISTS stacks RENAME TO stacks_table;
diff --git a/backend/resources/migrations/postgres/006_rename_tables.up.sql b/backend/resources/migrations/postgres/006_rename_tables.up.sql
deleted file mode 100644
index 9d10ebb7e..000000000
--- a/backend/resources/migrations/postgres/006_rename_tables.up.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-ALTER TABLE IF EXISTS users_table RENAME TO users;
-ALTER TABLE IF EXISTS image_update_table RENAME TO image_updates;
-ALTER TABLE IF EXISTS images_table RENAME TO images;
-ALTER TABLE IF EXISTS containers_table RENAME TO containers;
-ALTER TABLE IF EXISTS networks_table RENAME TO networks;
-ALTER TABLE IF EXISTS volumes_table RENAME TO volumes;
-ALTER TABLE IF EXISTS stacks_table RENAME TO stacks;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/007_add_user_oidc_tokens.down.sql b/backend/resources/migrations/postgres/007_add_user_oidc_tokens.down.sql
deleted file mode 100644
index 4f67284c0..000000000
--- a/backend/resources/migrations/postgres/007_add_user_oidc_tokens.down.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-ALTER TABLE IF EXISTS users
- DROP COLUMN IF EXISTS oidc_access_token,
- DROP COLUMN IF EXISTS oidc_refresh_token,
- DROP COLUMN IF EXISTS oidc_access_token_expires_at;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/007_add_user_oidc_tokens.sql b/backend/resources/migrations/postgres/007_add_user_oidc_tokens.sql
new file mode 100644
index 000000000..9742662cb
--- /dev/null
+++ b/backend/resources/migrations/postgres/007_add_user_oidc_tokens.sql
@@ -0,0 +1,11 @@
+-- +goose Up
+ALTER TABLE IF EXISTS users
+ ADD COLUMN IF NOT EXISTS oidc_access_token TEXT,
+ ADD COLUMN IF NOT EXISTS oidc_refresh_token TEXT,
+ ADD COLUMN IF NOT EXISTS oidc_access_token_expires_at TIMESTAMPTZ;
+
+-- +goose Down
+ALTER TABLE IF EXISTS users
+ DROP COLUMN IF EXISTS oidc_access_token,
+ DROP COLUMN IF EXISTS oidc_refresh_token,
+ DROP COLUMN IF EXISTS oidc_access_token_expires_at;
diff --git a/backend/resources/migrations/postgres/007_add_user_oidc_tokens.up.sql b/backend/resources/migrations/postgres/007_add_user_oidc_tokens.up.sql
deleted file mode 100644
index 85948648a..000000000
--- a/backend/resources/migrations/postgres/007_add_user_oidc_tokens.up.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-ALTER TABLE IF EXISTS users
- ADD COLUMN IF NOT EXISTS oidc_access_token TEXT,
- ADD COLUMN IF NOT EXISTS oidc_refresh_token TEXT,
- ADD COLUMN IF NOT EXISTS oidc_access_token_expires_at TIMESTAMPTZ;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/008_clean_compose_templates.down.sql b/backend/resources/migrations/postgres/008_clean_compose_templates.down.sql
deleted file mode 100644
index 60d6d4938..000000000
--- a/backend/resources/migrations/postgres/008_clean_compose_templates.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-ALTER TABLE compose_templates
- ADD COLUMN IF NOT EXISTS meta_updated_at TEXT;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/008_clean_compose_templates.sql b/backend/resources/migrations/postgres/008_clean_compose_templates.sql
new file mode 100644
index 000000000..31ce9ad4e
--- /dev/null
+++ b/backend/resources/migrations/postgres/008_clean_compose_templates.sql
@@ -0,0 +1,7 @@
+-- +goose Up
+ALTER TABLE compose_templates
+ DROP COLUMN IF EXISTS meta_updated_at;
+
+-- +goose Down
+ALTER TABLE compose_templates
+ ADD COLUMN IF NOT EXISTS meta_updated_at TEXT;
diff --git a/backend/resources/migrations/postgres/008_clean_compose_templates.up.sql b/backend/resources/migrations/postgres/008_clean_compose_templates.up.sql
deleted file mode 100644
index 2cc3a80df..000000000
--- a/backend/resources/migrations/postgres/008_clean_compose_templates.up.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-ALTER TABLE compose_templates
- DROP COLUMN IF EXISTS meta_updated_at;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/009_add_image_update_auth_fields.down.sql b/backend/resources/migrations/postgres/009_add_image_update_auth_fields.down.sql
deleted file mode 100644
index d1049989b..000000000
--- a/backend/resources/migrations/postgres/009_add_image_update_auth_fields.down.sql
+++ /dev/null
@@ -1,5 +0,0 @@
-ALTER TABLE IF EXISTS image_updates
- DROP COLUMN IF EXISTS used_credential,
- DROP COLUMN IF EXISTS auth_registry,
- DROP COLUMN IF EXISTS auth_username,
- DROP COLUMN IF EXISTS auth_method;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/009_add_image_update_auth_fields.up.sql b/backend/resources/migrations/postgres/009_add_image_update_auth_fields.sql
similarity index 51%
rename from backend/resources/migrations/postgres/009_add_image_update_auth_fields.up.sql
rename to backend/resources/migrations/postgres/009_add_image_update_auth_fields.sql
index 28312d70a..7d7a7a60e 100644
--- a/backend/resources/migrations/postgres/009_add_image_update_auth_fields.up.sql
+++ b/backend/resources/migrations/postgres/009_add_image_update_auth_fields.sql
@@ -1,5 +1,13 @@
+-- +goose Up
ALTER TABLE IF EXISTS image_updates
ADD COLUMN IF NOT EXISTS auth_method TEXT,
ADD COLUMN IF NOT EXISTS auth_username TEXT,
ADD COLUMN IF NOT EXISTS auth_registry TEXT,
- ADD COLUMN IF NOT EXISTS used_credential BOOLEAN DEFAULT FALSE;
\ No newline at end of file
+ ADD COLUMN IF NOT EXISTS used_credential BOOLEAN DEFAULT FALSE;
+
+-- +goose Down
+ALTER TABLE IF EXISTS image_updates
+ DROP COLUMN IF EXISTS used_credential,
+ DROP COLUMN IF EXISTS auth_registry,
+ DROP COLUMN IF EXISTS auth_username,
+ DROP COLUMN IF EXISTS auth_method;
diff --git a/backend/resources/migrations/postgres/010_rework_environments.down.sql b/backend/resources/migrations/postgres/010_rework_environments.down.sql
deleted file mode 100644
index 477a73c51..000000000
--- a/backend/resources/migrations/postgres/010_rework_environments.down.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-ALTER TABLE environments DROP COLUMN IF EXISTS access_token;
-ALTER TABLE environments ADD COLUMN IF NOT EXISTS hostname TEXT NOT NULL DEFAULT '';
-ALTER TABLE environments ADD COLUMN IF NOT EXISTS description TEXT;
-DROP INDEX IF EXISTS idx_environments_api_url;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/010_rework_environments.sql b/backend/resources/migrations/postgres/010_rework_environments.sql
new file mode 100644
index 000000000..d26292515
--- /dev/null
+++ b/backend/resources/migrations/postgres/010_rework_environments.sql
@@ -0,0 +1,11 @@
+-- +goose Up
+ALTER TABLE environments DROP COLUMN IF EXISTS hostname;
+ALTER TABLE environments DROP COLUMN IF EXISTS description;
+ALTER TABLE environments ADD COLUMN IF NOT EXISTS access_token TEXT;
+CREATE INDEX IF NOT EXISTS idx_environments_api_url ON environments (api_url);
+
+-- +goose Down
+ALTER TABLE environments DROP COLUMN IF EXISTS access_token;
+ALTER TABLE environments ADD COLUMN IF NOT EXISTS hostname TEXT NOT NULL DEFAULT '';
+ALTER TABLE environments ADD COLUMN IF NOT EXISTS description TEXT;
+DROP INDEX IF EXISTS idx_environments_api_url;
diff --git a/backend/resources/migrations/postgres/010_rework_environments.up.sql b/backend/resources/migrations/postgres/010_rework_environments.up.sql
deleted file mode 100644
index 74785014c..000000000
--- a/backend/resources/migrations/postgres/010_rework_environments.up.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-ALTER TABLE environments DROP COLUMN IF EXISTS hostname;
-ALTER TABLE environments DROP COLUMN IF EXISTS description;
-ALTER TABLE environments ADD COLUMN IF NOT EXISTS access_token TEXT;
-CREATE INDEX IF NOT EXISTS idx_environments_api_url ON environments (api_url);
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/011_add_environment_name.down.sql b/backend/resources/migrations/postgres/011_add_environment_name.down.sql
deleted file mode 100644
index f544be331..000000000
--- a/backend/resources/migrations/postgres/011_add_environment_name.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-ALTER TABLE environments DROP COLUMN IF EXISTS name;
-DROP INDEX IF EXISTS idx_environments_name;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/011_add_environment_name.sql b/backend/resources/migrations/postgres/011_add_environment_name.sql
new file mode 100644
index 000000000..42850e6d0
--- /dev/null
+++ b/backend/resources/migrations/postgres/011_add_environment_name.sql
@@ -0,0 +1,7 @@
+-- +goose Up
+ALTER TABLE environments ADD COLUMN IF NOT EXISTS name TEXT;
+CREATE INDEX IF NOT EXISTS idx_environments_name ON environments (name);
+
+-- +goose Down
+ALTER TABLE environments DROP COLUMN IF EXISTS name;
+DROP INDEX IF EXISTS idx_environments_name;
diff --git a/backend/resources/migrations/postgres/011_add_environment_name.up.sql b/backend/resources/migrations/postgres/011_add_environment_name.up.sql
deleted file mode 100644
index f9adbff9c..000000000
--- a/backend/resources/migrations/postgres/011_add_environment_name.up.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-ALTER TABLE environments ADD COLUMN IF NOT EXISTS name TEXT;
-CREATE INDEX IF NOT EXISTS idx_environments_name ON environments (name);
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/012_add_user_locale.down.sql b/backend/resources/migrations/postgres/012_add_user_locale.down.sql
deleted file mode 100644
index af8112074..000000000
--- a/backend/resources/migrations/postgres/012_add_user_locale.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE users DROP COLUMN IF EXISTS locale;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/012_add_user_locale.sql b/backend/resources/migrations/postgres/012_add_user_locale.sql
new file mode 100644
index 000000000..bff7b88a9
--- /dev/null
+++ b/backend/resources/migrations/postgres/012_add_user_locale.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+ALTER TABLE users ADD COLUMN IF NOT EXISTS locale TEXT;
+
+-- +goose Down
+ALTER TABLE users DROP COLUMN IF EXISTS locale;
diff --git a/backend/resources/migrations/postgres/012_add_user_locale.up.sql b/backend/resources/migrations/postgres/012_add_user_locale.up.sql
deleted file mode 100644
index 72a293360..000000000
--- a/backend/resources/migrations/postgres/012_add_user_locale.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE users ADD COLUMN IF NOT EXISTS locale TEXT;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/013_stacks_to_projects.down.sql b/backend/resources/migrations/postgres/013_stacks_to_projects.sql
similarity index 78%
rename from backend/resources/migrations/postgres/013_stacks_to_projects.down.sql
rename to backend/resources/migrations/postgres/013_stacks_to_projects.sql
index abfaf9d62..9dc20b7ec 100644
--- a/backend/resources/migrations/postgres/013_stacks_to_projects.down.sql
+++ b/backend/resources/migrations/postgres/013_stacks_to_projects.sql
@@ -1,4 +1,11 @@
-BEGIN;
+-- +goose Up
+-- Rename stacks -> projects
+ALTER TABLE IF EXISTS stacks RENAME TO projects;
+
+-- Remove legacy cache table
+DROP TABLE IF EXISTS project_cache;
+
+-- +goose Down
-- Recreate legacy cache table
CREATE TABLE IF NOT EXISTS project_cache (
id TEXT PRIMARY KEY,
@@ -19,4 +26,3 @@ CREATE UNIQUE INDEX IF NOT EXISTS idx_project_cache_stack_id ON project_cache(st
-- Rename projects -> stacks
ALTER TABLE IF EXISTS projects RENAME TO stacks;
-COMMIT;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/013_stacks_to_projects.up.sql b/backend/resources/migrations/postgres/013_stacks_to_projects.up.sql
deleted file mode 100644
index 34060d252..000000000
--- a/backend/resources/migrations/postgres/013_stacks_to_projects.up.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-BEGIN;
--- Rename stacks -> projects
-ALTER TABLE IF EXISTS stacks RENAME TO projects;
-
--- Remove legacy cache table
-DROP TABLE IF EXISTS project_cache;
-COMMIT;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/014_containers_project_fk.down.sql b/backend/resources/migrations/postgres/014_containers_project_fk.down.sql
deleted file mode 100644
index 49ef7b90e..000000000
--- a/backend/resources/migrations/postgres/014_containers_project_fk.down.sql
+++ /dev/null
@@ -1,19 +0,0 @@
-BEGIN;
--- Drop new FK
-ALTER TABLE containers
- DROP CONSTRAINT IF EXISTS containers_project_id_fkey;
-
--- Rename column back
-ALTER TABLE containers
- RENAME COLUMN IF EXISTS project_id TO stack_id;
-
--- Optionally restore FK to stacks if it exists
-DO $$
-BEGIN
- IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name='stacks' AND table_schema = current_schema()) THEN
- ALTER TABLE containers
- ADD CONSTRAINT containers_stack_id_fkey
- FOREIGN KEY (stack_id) REFERENCES stacks(id) ON DELETE SET NULL;
- END IF;
-END$$;
-COMMIT;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/014_containers_project_fk.up.sql b/backend/resources/migrations/postgres/014_containers_project_fk.sql
similarity index 54%
rename from backend/resources/migrations/postgres/014_containers_project_fk.up.sql
rename to backend/resources/migrations/postgres/014_containers_project_fk.sql
index 2ee52a6da..aefd8a917 100644
--- a/backend/resources/migrations/postgres/014_containers_project_fk.up.sql
+++ b/backend/resources/migrations/postgres/014_containers_project_fk.sql
@@ -1,4 +1,5 @@
-BEGIN;
+-- +goose Up
+-- +goose StatementBegin
DO $$
DECLARE cname text;
BEGIN
@@ -11,6 +12,7 @@ BEGIN
EXECUTE format('ALTER TABLE containers DROP CONSTRAINT %I', cname);
END IF;
END$$;
+-- +goose StatementEnd
ALTER TABLE containers
RENAME COLUMN stack_id TO project_id;
@@ -19,4 +21,24 @@ ALTER TABLE containers
ALTER TABLE containers
ADD CONSTRAINT containers_project_id_fkey
FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE SET NULL;
-COMMIT;
\ No newline at end of file
+
+-- +goose Down
+-- Drop new FK
+ALTER TABLE containers
+ DROP CONSTRAINT IF EXISTS containers_project_id_fkey;
+
+-- Rename column back
+ALTER TABLE containers
+ RENAME COLUMN IF EXISTS project_id TO stack_id;
+
+-- Optionally restore FK to stacks if it exists
+-- +goose StatementBegin
+DO $$
+BEGIN
+ IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name='stacks' AND table_schema = current_schema()) THEN
+ ALTER TABLE containers
+ ADD CONSTRAINT containers_stack_id_fkey
+ FOREIGN KEY (stack_id) REFERENCES stacks(id) ON DELETE SET NULL;
+ END IF;
+END$$;
+-- +goose StatementEnd
diff --git a/backend/resources/migrations/postgres/015_rename_stacks_directory_setting.down.sql b/backend/resources/migrations/postgres/015_rename_stacks_directory_setting.down.sql
deleted file mode 100644
index 898d78867..000000000
--- a/backend/resources/migrations/postgres/015_rename_stacks_directory_setting.down.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-BEGIN;
-INSERT INTO settings (key, value)
-SELECT 'stacksDirectory', value
-FROM settings
-WHERE key = 'projectsDirectory'
-ON CONFLICT (key) DO NOTHING;
-
-DELETE FROM settings WHERE key = 'projectsDirectory';
-COMMIT;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/015_rename_stacks_directory_setting.sql b/backend/resources/migrations/postgres/015_rename_stacks_directory_setting.sql
new file mode 100644
index 000000000..2c4f9684a
--- /dev/null
+++ b/backend/resources/migrations/postgres/015_rename_stacks_directory_setting.sql
@@ -0,0 +1,17 @@
+-- +goose Up
+INSERT INTO settings (key, value)
+SELECT 'projectsDirectory', value
+FROM settings
+WHERE key = 'stacksDirectory'
+ON CONFLICT (key) DO NOTHING;
+
+DELETE FROM settings WHERE key = 'stacksDirectory';
+
+-- +goose Down
+INSERT INTO settings (key, value)
+SELECT 'stacksDirectory', value
+FROM settings
+WHERE key = 'projectsDirectory'
+ON CONFLICT (key) DO NOTHING;
+
+DELETE FROM settings WHERE key = 'projectsDirectory';
diff --git a/backend/resources/migrations/postgres/015_rename_stacks_directory_setting.up.sql b/backend/resources/migrations/postgres/015_rename_stacks_directory_setting.up.sql
deleted file mode 100644
index f5a53f9a6..000000000
--- a/backend/resources/migrations/postgres/015_rename_stacks_directory_setting.up.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-BEGIN;
-INSERT INTO settings (key, value)
-SELECT 'projectsDirectory', value
-FROM settings
-WHERE key = 'stacksDirectory'
-ON CONFLICT (key) DO NOTHING;
-
-DELETE FROM settings WHERE key = 'stacksDirectory';
-COMMIT;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/016_drop_image_table.down.sql b/backend/resources/migrations/postgres/016_drop_image_table.sql
similarity index 85%
rename from backend/resources/migrations/postgres/016_drop_image_table.down.sql
rename to backend/resources/migrations/postgres/016_drop_image_table.sql
index c14836e20..2e4d3bea2 100644
--- a/backend/resources/migrations/postgres/016_drop_image_table.down.sql
+++ b/backend/resources/migrations/postgres/016_drop_image_table.sql
@@ -1,3 +1,7 @@
+-- +goose Up
+DROP TABLE IF EXISTS images_table;
+
+-- +goose Down
CREATE TABLE IF NOT EXISTS images_table (
id TEXT PRIMARY KEY,
repo_tags TEXT,
@@ -11,4 +15,4 @@ CREATE TABLE IF NOT EXISTS images_table (
in_use BOOLEAN NOT NULL DEFAULT false,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP
-);
\ No newline at end of file
+);
diff --git a/backend/resources/migrations/postgres/016_drop_image_table.up.sql b/backend/resources/migrations/postgres/016_drop_image_table.up.sql
deleted file mode 100644
index 39d4074ea..000000000
--- a/backend/resources/migrations/postgres/016_drop_image_table.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP TABLE IF EXISTS images_table;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/017_drop_unused_docker_tables.down.sql b/backend/resources/migrations/postgres/017_drop_unused_docker_tables.sql
similarity index 89%
rename from backend/resources/migrations/postgres/017_drop_unused_docker_tables.down.sql
rename to backend/resources/migrations/postgres/017_drop_unused_docker_tables.sql
index fcff228fa..f0981d926 100644
--- a/backend/resources/migrations/postgres/017_drop_unused_docker_tables.down.sql
+++ b/backend/resources/migrations/postgres/017_drop_unused_docker_tables.sql
@@ -1,3 +1,9 @@
+-- +goose Up
+DROP TABLE IF EXISTS containers CASCADE;
+DROP TABLE IF EXISTS volumes CASCADE;
+DROP TABLE IF EXISTS networks CASCADE;
+
+-- +goose Down
-- Recreate containers table (for rollback only)
CREATE TABLE IF NOT EXISTS containers (
id TEXT PRIMARY KEY,
diff --git a/backend/resources/migrations/postgres/017_drop_unused_docker_tables.up.sql b/backend/resources/migrations/postgres/017_drop_unused_docker_tables.up.sql
deleted file mode 100644
index 8e004a835..000000000
--- a/backend/resources/migrations/postgres/017_drop_unused_docker_tables.up.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-DROP TABLE IF EXISTS containers CASCADE;
-DROP TABLE IF EXISTS volumes CASCADE;
-DROP TABLE IF EXISTS networks CASCADE;
diff --git a/backend/resources/migrations/postgres/018_add_project_status_reason.down.sql b/backend/resources/migrations/postgres/018_add_project_status_reason.down.sql
deleted file mode 100644
index 8b190d0e0..000000000
--- a/backend/resources/migrations/postgres/018_add_project_status_reason.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE projects DROP COLUMN status_reason;
diff --git a/backend/resources/migrations/postgres/018_add_project_status_reason.sql b/backend/resources/migrations/postgres/018_add_project_status_reason.sql
new file mode 100644
index 000000000..f6a7b9547
--- /dev/null
+++ b/backend/resources/migrations/postgres/018_add_project_status_reason.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+ALTER TABLE projects ADD COLUMN status_reason TEXT;
+
+-- +goose Down
+ALTER TABLE projects DROP COLUMN status_reason;
diff --git a/backend/resources/migrations/postgres/018_add_project_status_reason.up.sql b/backend/resources/migrations/postgres/018_add_project_status_reason.up.sql
deleted file mode 100644
index 87131d0d9..000000000
--- a/backend/resources/migrations/postgres/018_add_project_status_reason.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE projects ADD COLUMN status_reason TEXT;
diff --git a/backend/resources/migrations/postgres/019_add_user_requires_password_change.down.sql b/backend/resources/migrations/postgres/019_add_user_requires_password_change.down.sql
deleted file mode 100644
index 19b394f77..000000000
--- a/backend/resources/migrations/postgres/019_add_user_requires_password_change.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE users DROP COLUMN IF EXISTS requires_password_change;
diff --git a/backend/resources/migrations/postgres/019_add_user_requires_password_change.up.sql b/backend/resources/migrations/postgres/019_add_user_requires_password_change.sql
similarity index 51%
rename from backend/resources/migrations/postgres/019_add_user_requires_password_change.up.sql
rename to backend/resources/migrations/postgres/019_add_user_requires_password_change.sql
index dc2b8efe3..df9362a96 100644
--- a/backend/resources/migrations/postgres/019_add_user_requires_password_change.up.sql
+++ b/backend/resources/migrations/postgres/019_add_user_requires_password_change.sql
@@ -1 +1,5 @@
+-- +goose Up
ALTER TABLE users ADD COLUMN IF NOT EXISTS requires_password_change BOOLEAN NOT NULL DEFAULT FALSE;
+
+-- +goose Down
+ALTER TABLE users DROP COLUMN IF EXISTS requires_password_change;
diff --git a/backend/resources/migrations/postgres/020_remove_mobile_navigation_scroll_to_hide_setting.down.sql b/backend/resources/migrations/postgres/020_remove_mobile_navigation_scroll_to_hide_setting.down.sql
deleted file mode 100644
index 5ac9b7c71..000000000
--- a/backend/resources/migrations/postgres/020_remove_mobile_navigation_scroll_to_hide_setting.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-INSERT INTO settings (key, value) VALUES ('mobileNavigationScrollToHide', 'true');
-
diff --git a/backend/resources/migrations/postgres/020_remove_mobile_navigation_scroll_to_hide_setting.sql b/backend/resources/migrations/postgres/020_remove_mobile_navigation_scroll_to_hide_setting.sql
new file mode 100644
index 000000000..13bb22f60
--- /dev/null
+++ b/backend/resources/migrations/postgres/020_remove_mobile_navigation_scroll_to_hide_setting.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+DELETE FROM settings WHERE key = 'mobileNavigationScrollToHide';
+
+-- +goose Down
+INSERT INTO settings (key, value) VALUES ('mobileNavigationScrollToHide', 'true');
diff --git a/backend/resources/migrations/postgres/020_remove_mobile_navigation_scroll_to_hide_setting.up.sql b/backend/resources/migrations/postgres/020_remove_mobile_navigation_scroll_to_hide_setting.up.sql
deleted file mode 100644
index 3f490bb39..000000000
--- a/backend/resources/migrations/postgres/020_remove_mobile_navigation_scroll_to_hide_setting.up.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-DELETE FROM settings WHERE key = 'mobileNavigationScrollToHide';
-
diff --git a/backend/resources/migrations/postgres/021_add_notifications.down.sql b/backend/resources/migrations/postgres/021_add_notifications.down.sql
deleted file mode 100644
index 8733d0b5b..000000000
--- a/backend/resources/migrations/postgres/021_add_notifications.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-DROP TABLE IF EXISTS notification_logs;
-DROP TABLE IF EXISTS notification_settings;
diff --git a/backend/resources/migrations/postgres/021_add_notifications.up.sql b/backend/resources/migrations/postgres/021_add_notifications.sql
similarity index 88%
rename from backend/resources/migrations/postgres/021_add_notifications.up.sql
rename to backend/resources/migrations/postgres/021_add_notifications.sql
index 1cc02664e..eb73e7acc 100644
--- a/backend/resources/migrations/postgres/021_add_notifications.up.sql
+++ b/backend/resources/migrations/postgres/021_add_notifications.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS notification_settings (
id SERIAL PRIMARY KEY,
provider VARCHAR(50) NOT NULL,
@@ -23,3 +24,7 @@ CREATE TABLE IF NOT EXISTS notification_logs (
CREATE INDEX idx_notification_logs_provider ON notification_logs(provider);
CREATE INDEX idx_notification_logs_sent_at ON notification_logs(sent_at);
+
+-- +goose Down
+DROP TABLE IF EXISTS notification_logs;
+DROP TABLE IF EXISTS notification_settings;
diff --git a/backend/resources/migrations/postgres/022_unique_oidc_subject_index.down.sql b/backend/resources/migrations/postgres/022_unique_oidc_subject_index.down.sql
deleted file mode 100644
index ae265e30a..000000000
--- a/backend/resources/migrations/postgres/022_unique_oidc_subject_index.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP INDEX IF EXISTS idx_users_oidc_subject_id_unique;
\ No newline at end of file
diff --git a/backend/resources/migrations/postgres/022_unique_oidc_subject_index.up.sql b/backend/resources/migrations/postgres/022_unique_oidc_subject_index.sql
similarity index 58%
rename from backend/resources/migrations/postgres/022_unique_oidc_subject_index.up.sql
rename to backend/resources/migrations/postgres/022_unique_oidc_subject_index.sql
index d8c941f38..cf4dbe1be 100644
--- a/backend/resources/migrations/postgres/022_unique_oidc_subject_index.up.sql
+++ b/backend/resources/migrations/postgres/022_unique_oidc_subject_index.sql
@@ -1,4 +1,8 @@
+-- +goose Up
-- Ensure OIDC subject is unique across users while allowing NULL values
CREATE UNIQUE INDEX IF NOT EXISTS idx_users_oidc_subject_id_unique
ON users (oidc_subject_id)
-WHERE oidc_subject_id IS NOT NULL;
\ No newline at end of file
+WHERE oidc_subject_id IS NOT NULL;
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_users_oidc_subject_id_unique;
diff --git a/backend/resources/migrations/postgres/023_add_apprise_settings.down.sql b/backend/resources/migrations/postgres/023_add_apprise_settings.down.sql
deleted file mode 100644
index 954f2e5d2..000000000
--- a/backend/resources/migrations/postgres/023_add_apprise_settings.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP TABLE IF EXISTS apprise_settings;
diff --git a/backend/resources/migrations/postgres/023_add_apprise_settings.up.sql b/backend/resources/migrations/postgres/023_add_apprise_settings.sql
similarity index 83%
rename from backend/resources/migrations/postgres/023_add_apprise_settings.up.sql
rename to backend/resources/migrations/postgres/023_add_apprise_settings.sql
index 2d32481de..8bd47b4ee 100644
--- a/backend/resources/migrations/postgres/023_add_apprise_settings.up.sql
+++ b/backend/resources/migrations/postgres/023_add_apprise_settings.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS apprise_settings (
id SERIAL PRIMARY KEY,
api_url VARCHAR(512) NOT NULL,
@@ -7,3 +8,6 @@ CREATE TABLE IF NOT EXISTS apprise_settings (
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
+
+-- +goose Down
+DROP TABLE IF EXISTS apprise_settings;
diff --git a/backend/resources/migrations/postgres/024_add_api_keys.down.sql b/backend/resources/migrations/postgres/024_add_api_keys.down.sql
deleted file mode 100644
index 42af8e148..000000000
--- a/backend/resources/migrations/postgres/024_add_api_keys.down.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-DROP INDEX IF EXISTS idx_api_keys_key_prefix;
-DROP INDEX IF EXISTS idx_api_keys_key_hash;
-DROP INDEX IF EXISTS idx_api_keys_user_id;
-DROP TABLE IF EXISTS api_keys;
diff --git a/backend/resources/migrations/postgres/024_add_api_keys.up.sql b/backend/resources/migrations/postgres/024_add_api_keys.sql
similarity index 76%
rename from backend/resources/migrations/postgres/024_add_api_keys.up.sql
rename to backend/resources/migrations/postgres/024_add_api_keys.sql
index fcbc143ec..134868352 100644
--- a/backend/resources/migrations/postgres/024_add_api_keys.up.sql
+++ b/backend/resources/migrations/postgres/024_add_api_keys.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS api_keys (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
@@ -15,3 +16,9 @@ CREATE TABLE IF NOT EXISTS api_keys (
CREATE INDEX IF NOT EXISTS idx_api_keys_user_id ON api_keys(user_id);
CREATE INDEX IF NOT EXISTS idx_api_keys_key_hash ON api_keys(key_hash);
CREATE INDEX IF NOT EXISTS idx_api_keys_key_prefix ON api_keys(key_prefix);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_api_keys_key_prefix;
+DROP INDEX IF EXISTS idx_api_keys_key_hash;
+DROP INDEX IF EXISTS idx_api_keys_user_id;
+DROP TABLE IF EXISTS api_keys;
diff --git a/backend/resources/migrations/postgres/025_add_environment_api_key_pairing.down.sql b/backend/resources/migrations/postgres/025_add_environment_api_key_pairing.down.sql
deleted file mode 100644
index d81f3a533..000000000
--- a/backend/resources/migrations/postgres/025_add_environment_api_key_pairing.down.sql
+++ /dev/null
@@ -1,5 +0,0 @@
--- Remove environment_id column from api_keys table
-ALTER TABLE api_keys DROP COLUMN environment_id;
-
--- Remove api_key_id column from environments table
-ALTER TABLE environments DROP COLUMN api_key_id;
diff --git a/backend/resources/migrations/postgres/025_add_environment_api_key_pairing.up.sql b/backend/resources/migrations/postgres/025_add_environment_api_key_pairing.sql
similarity index 60%
rename from backend/resources/migrations/postgres/025_add_environment_api_key_pairing.up.sql
rename to backend/resources/migrations/postgres/025_add_environment_api_key_pairing.sql
index f81fe771c..f77f826ff 100644
--- a/backend/resources/migrations/postgres/025_add_environment_api_key_pairing.up.sql
+++ b/backend/resources/migrations/postgres/025_add_environment_api_key_pairing.sql
@@ -1,5 +1,13 @@
+-- +goose Up
-- Add api_key_id column to environments table for API key-based pairing
ALTER TABLE environments ADD COLUMN api_key_id TEXT REFERENCES api_keys(id) ON DELETE SET NULL;
-- Add environment_id column to api_keys table to link API keys to environments
ALTER TABLE api_keys ADD COLUMN environment_id TEXT REFERENCES environments(id) ON DELETE CASCADE;
+
+-- +goose Down
+-- Remove environment_id column from api_keys table
+ALTER TABLE api_keys DROP COLUMN environment_id;
+
+-- Remove api_key_id column from environments table
+ALTER TABLE environments DROP COLUMN api_key_id;
diff --git a/backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.down.sql b/backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.down.sql
deleted file mode 100644
index 42144d243..000000000
--- a/backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.down.sql
+++ /dev/null
@@ -1,4 +0,0 @@
--- Remove notification_sent column
--- PostgreSQL automatically preserves existing indexes on other columns
-ALTER TABLE IF EXISTS image_updates
- DROP COLUMN notification_sent;
diff --git a/backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.up.sql b/backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.sql
similarity index 52%
rename from backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.up.sql
rename to backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.sql
index 8bde48fae..ffae0d04c 100644
--- a/backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.up.sql
+++ b/backend/resources/migrations/postgres/026_add_notification_sent_to_image_updates.sql
@@ -1,4 +1,11 @@
+-- +goose Up
-- Add notification_sent column to track if updates have been sent
-- Existing indexes on repository and tag are preserved automatically
ALTER TABLE IF EXISTS image_updates
ADD COLUMN notification_sent BOOLEAN DEFAULT false;
+
+-- +goose Down
+-- Remove notification_sent column
+-- PostgreSQL automatically preserves existing indexes on other columns
+ALTER TABLE IF EXISTS image_updates
+ DROP COLUMN notification_sent;
diff --git a/backend/resources/migrations/postgres/027_add_missing_indexes.down.sql b/backend/resources/migrations/postgres/027_add_missing_indexes.down.sql
deleted file mode 100644
index 40bd1dcbf..000000000
--- a/backend/resources/migrations/postgres/027_add_missing_indexes.down.sql
+++ /dev/null
@@ -1,15 +0,0 @@
-DROP INDEX IF EXISTS idx_environments_enabled;
-DROP INDEX IF EXISTS idx_environments_status;
-DROP INDEX IF EXISTS idx_environments_last_seen;
-DROP INDEX IF EXISTS idx_container_registries_enabled;
-DROP INDEX IF EXISTS idx_projects_status;
-DROP INDEX IF EXISTS idx_projects_name;
-DROP INDEX IF EXISTS idx_users_username;
-DROP INDEX IF EXISTS idx_users_email;
-DROP INDEX IF EXISTS idx_users_oidc_subject_id;
-DROP INDEX IF EXISTS idx_image_updates_has_update;
-DROP INDEX IF EXISTS idx_image_updates_has_update_notification;
-DROP INDEX IF EXISTS idx_image_updates_check_time;
-DROP INDEX IF EXISTS idx_image_updates_notification_sent;
-DROP INDEX IF EXISTS idx_notification_settings_enabled;
-DROP INDEX IF EXISTS idx_apprise_settings_enabled;
diff --git a/backend/resources/migrations/postgres/027_add_missing_indexes.up.sql b/backend/resources/migrations/postgres/027_add_missing_indexes.sql
similarity index 62%
rename from backend/resources/migrations/postgres/027_add_missing_indexes.up.sql
rename to backend/resources/migrations/postgres/027_add_missing_indexes.sql
index 6ccc193f0..98e01f831 100644
--- a/backend/resources/migrations/postgres/027_add_missing_indexes.up.sql
+++ b/backend/resources/migrations/postgres/027_add_missing_indexes.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE INDEX IF NOT EXISTS idx_environments_enabled ON environments (enabled);
CREATE INDEX IF NOT EXISTS idx_environments_status ON environments (status);
CREATE INDEX IF NOT EXISTS idx_environments_last_seen ON environments (last_seen);
@@ -13,3 +14,20 @@ CREATE INDEX IF NOT EXISTS idx_image_updates_check_time ON image_updates (check_
CREATE INDEX IF NOT EXISTS idx_image_updates_notification_sent ON image_updates (notification_sent);
CREATE INDEX IF NOT EXISTS idx_notification_settings_enabled ON notification_settings (enabled);
CREATE INDEX IF NOT EXISTS idx_apprise_settings_enabled ON apprise_settings (enabled);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_environments_enabled;
+DROP INDEX IF EXISTS idx_environments_status;
+DROP INDEX IF EXISTS idx_environments_last_seen;
+DROP INDEX IF EXISTS idx_container_registries_enabled;
+DROP INDEX IF EXISTS idx_projects_status;
+DROP INDEX IF EXISTS idx_projects_name;
+DROP INDEX IF EXISTS idx_users_username;
+DROP INDEX IF EXISTS idx_users_email;
+DROP INDEX IF EXISTS idx_users_oidc_subject_id;
+DROP INDEX IF EXISTS idx_image_updates_has_update;
+DROP INDEX IF EXISTS idx_image_updates_has_update_notification;
+DROP INDEX IF EXISTS idx_image_updates_check_time;
+DROP INDEX IF EXISTS idx_image_updates_notification_sent;
+DROP INDEX IF EXISTS idx_notification_settings_enabled;
+DROP INDEX IF EXISTS idx_apprise_settings_enabled;
diff --git a/backend/resources/migrations/postgres/028_add_gitops.down.sql b/backend/resources/migrations/postgres/028_add_gitops.down.sql
deleted file mode 100644
index e8f576dfd..000000000
--- a/backend/resources/migrations/postgres/028_add_gitops.down.sql
+++ /dev/null
@@ -1,5 +0,0 @@
--- Remove gitops_managed_by column from projects table
-ALTER TABLE projects DROP COLUMN IF EXISTS gitops_managed_by;
-
-DROP TABLE IF EXISTS gitops_syncs;
-DROP TABLE IF EXISTS git_repositories;
diff --git a/backend/resources/migrations/postgres/028_add_gitops.up.sql b/backend/resources/migrations/postgres/028_add_gitops.sql
similarity index 90%
rename from backend/resources/migrations/postgres/028_add_gitops.up.sql
rename to backend/resources/migrations/postgres/028_add_gitops.sql
index d318417f0..d03ce448b 100644
--- a/backend/resources/migrations/postgres/028_add_gitops.up.sql
+++ b/backend/resources/migrations/postgres/028_add_gitops.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS git_repositories (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
@@ -48,3 +49,10 @@ CREATE INDEX IF NOT EXISTS idx_gitops_syncs_last_sync_commit ON gitops_syncs(las
-- Add gitops_managed_by column to projects table
ALTER TABLE projects ADD COLUMN IF NOT EXISTS gitops_managed_by TEXT;
CREATE INDEX IF NOT EXISTS idx_projects_gitops_managed_by ON projects(gitops_managed_by);
+
+-- +goose Down
+-- Remove gitops_managed_by column from projects table
+ALTER TABLE projects DROP COLUMN IF EXISTS gitops_managed_by;
+
+DROP TABLE IF EXISTS gitops_syncs;
+DROP TABLE IF EXISTS git_repositories;
diff --git a/backend/resources/migrations/postgres/029_add_ssh_host_key_verification.down.sql b/backend/resources/migrations/postgres/029_add_ssh_host_key_verification.down.sql
deleted file mode 100644
index f476480b3..000000000
--- a/backend/resources/migrations/postgres/029_add_ssh_host_key_verification.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE git_repositories DROP COLUMN IF EXISTS ssh_host_key_verification;
diff --git a/backend/resources/migrations/postgres/029_add_ssh_host_key_verification.up.sql b/backend/resources/migrations/postgres/029_add_ssh_host_key_verification.sql
similarity index 73%
rename from backend/resources/migrations/postgres/029_add_ssh_host_key_verification.up.sql
rename to backend/resources/migrations/postgres/029_add_ssh_host_key_verification.sql
index 23c4c7178..98037b08f 100644
--- a/backend/resources/migrations/postgres/029_add_ssh_host_key_verification.up.sql
+++ b/backend/resources/migrations/postgres/029_add_ssh_host_key_verification.sql
@@ -1,3 +1,7 @@
+-- +goose Up
-- Add ssh_host_key_verification column to git_repositories table
-- Values: 'strict' (use known_hosts), 'accept_new' (default - auto-add unknown hosts), 'skip' (disable verification)
ALTER TABLE git_repositories ADD COLUMN IF NOT EXISTS ssh_host_key_verification TEXT NOT NULL DEFAULT 'accept_new';
+
+-- +goose Down
+ALTER TABLE git_repositories DROP COLUMN IF EXISTS ssh_host_key_verification;
diff --git a/backend/resources/migrations/postgres/030_remove_gitops_sync_enabled.down.sql b/backend/resources/migrations/postgres/030_remove_gitops_sync_enabled.sql
similarity index 52%
rename from backend/resources/migrations/postgres/030_remove_gitops_sync_enabled.down.sql
rename to backend/resources/migrations/postgres/030_remove_gitops_sync_enabled.sql
index 121f905b0..f473be6f2 100644
--- a/backend/resources/migrations/postgres/030_remove_gitops_sync_enabled.down.sql
+++ b/backend/resources/migrations/postgres/030_remove_gitops_sync_enabled.sql
@@ -1,3 +1,9 @@
+-- +goose Up
+-- Remove the enabled column from gitops_syncs table
+-- Only autoSync field will control automatic syncing behavior
+ALTER TABLE gitops_syncs DROP COLUMN IF EXISTS enabled;
+
+-- +goose Down
-- Re-add the enabled column to gitops_syncs table
ALTER TABLE gitops_syncs ADD COLUMN IF NOT EXISTS enabled BOOLEAN NOT NULL DEFAULT true;
CREATE INDEX IF NOT EXISTS idx_gitops_syncs_enabled ON gitops_syncs(enabled);
diff --git a/backend/resources/migrations/postgres/030_remove_gitops_sync_enabled.up.sql b/backend/resources/migrations/postgres/030_remove_gitops_sync_enabled.up.sql
deleted file mode 100644
index 149e2d0ec..000000000
--- a/backend/resources/migrations/postgres/030_remove_gitops_sync_enabled.up.sql
+++ /dev/null
@@ -1,3 +0,0 @@
--- Remove the enabled column from gitops_syncs table
--- Only autoSync field will control automatic syncing behavior
-ALTER TABLE gitops_syncs DROP COLUMN IF EXISTS enabled;
diff --git a/backend/resources/migrations/postgres/031_add_environment_is_edge.down.sql b/backend/resources/migrations/postgres/031_add_environment_is_edge.down.sql
deleted file mode 100644
index 87ac3a0c7..000000000
--- a/backend/resources/migrations/postgres/031_add_environment_is_edge.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- remove is_edge column from environments table
-ALTER TABLE environments DROP COLUMN is_edge;
diff --git a/backend/resources/migrations/postgres/031_add_environment_is_edge.up.sql b/backend/resources/migrations/postgres/031_add_environment_is_edge.sql
similarity index 53%
rename from backend/resources/migrations/postgres/031_add_environment_is_edge.up.sql
rename to backend/resources/migrations/postgres/031_add_environment_is_edge.sql
index 4e4f6d1c8..75dea001c 100644
--- a/backend/resources/migrations/postgres/031_add_environment_is_edge.up.sql
+++ b/backend/resources/migrations/postgres/031_add_environment_is_edge.sql
@@ -1,2 +1,7 @@
+-- +goose Up
-- add is_edge column to environments table for edge agent mode
ALTER TABLE environments ADD COLUMN is_edge BOOLEAN NOT NULL DEFAULT false;
+
+-- +goose Down
+-- remove is_edge column from environments table
+ALTER TABLE environments DROP COLUMN is_edge;
diff --git a/backend/resources/migrations/postgres/032_add_volume_backups.down.sql b/backend/resources/migrations/postgres/032_add_volume_backups.down.sql
deleted file mode 100644
index dc16e31ec..000000000
--- a/backend/resources/migrations/postgres/032_add_volume_backups.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP TABLE volume_backups;
diff --git a/backend/resources/migrations/postgres/032_add_volume_backups.up.sql b/backend/resources/migrations/postgres/032_add_volume_backups.sql
similarity index 83%
rename from backend/resources/migrations/postgres/032_add_volume_backups.up.sql
rename to backend/resources/migrations/postgres/032_add_volume_backups.sql
index b9c095beb..459d0069e 100644
--- a/backend/resources/migrations/postgres/032_add_volume_backups.up.sql
+++ b/backend/resources/migrations/postgres/032_add_volume_backups.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE volume_backups (
id TEXT PRIMARY KEY,
volume_name TEXT NOT NULL,
@@ -6,3 +7,6 @@ CREATE TABLE volume_backups (
updated_at TIMESTAMP WITH TIME ZONE
);
CREATE INDEX idx_volume_backups_volume_name ON volume_backups(volume_name);
+
+-- +goose Down
+DROP TABLE volume_backups;
diff --git a/backend/resources/migrations/postgres/033_add_vulnerability_scans.down.sql b/backend/resources/migrations/postgres/033_add_vulnerability_scans.down.sql
deleted file mode 100644
index a943e6999..000000000
--- a/backend/resources/migrations/postgres/033_add_vulnerability_scans.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- Remove vulnerability_scans table
-DROP TABLE IF EXISTS vulnerability_scans;
diff --git a/backend/resources/migrations/postgres/033_add_vulnerability_scans.up.sql b/backend/resources/migrations/postgres/033_add_vulnerability_scans.sql
similarity index 89%
rename from backend/resources/migrations/postgres/033_add_vulnerability_scans.up.sql
rename to backend/resources/migrations/postgres/033_add_vulnerability_scans.sql
index 54bdb5ead..29a2b9e70 100644
--- a/backend/resources/migrations/postgres/033_add_vulnerability_scans.up.sql
+++ b/backend/resources/migrations/postgres/033_add_vulnerability_scans.sql
@@ -1,3 +1,4 @@
+-- +goose Up
-- Add vulnerability_scans table for storing vulnerability scan results
CREATE TABLE IF NOT EXISTS vulnerability_scans (
id TEXT PRIMARY KEY,
@@ -21,3 +22,7 @@ CREATE TABLE IF NOT EXISTS vulnerability_scans (
-- Create indexes for efficient querying
CREATE INDEX IF NOT EXISTS idx_vulnerability_scans_status ON vulnerability_scans(status);
CREATE INDEX IF NOT EXISTS idx_vulnerability_scans_scan_time ON vulnerability_scans(scan_time);
+
+-- +goose Down
+-- Remove vulnerability_scans table
+DROP TABLE IF EXISTS vulnerability_scans;
diff --git a/backend/resources/migrations/postgres/034_add_vulnerability_ignores.down.sql b/backend/resources/migrations/postgres/034_add_vulnerability_ignores.down.sql
deleted file mode 100644
index bf0cb0176..000000000
--- a/backend/resources/migrations/postgres/034_add_vulnerability_ignores.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- Drop vulnerability_ignores table
-DROP TABLE IF EXISTS vulnerability_ignores;
diff --git a/backend/resources/migrations/postgres/034_add_vulnerability_ignores.up.sql b/backend/resources/migrations/postgres/034_add_vulnerability_ignores.sql
similarity index 89%
rename from backend/resources/migrations/postgres/034_add_vulnerability_ignores.up.sql
rename to backend/resources/migrations/postgres/034_add_vulnerability_ignores.sql
index 6ea2eeaec..96c00aa50 100644
--- a/backend/resources/migrations/postgres/034_add_vulnerability_ignores.up.sql
+++ b/backend/resources/migrations/postgres/034_add_vulnerability_ignores.sql
@@ -1,3 +1,4 @@
+-- +goose Up
-- Add vulnerability_ignores table for storing ignored vulnerability records
CREATE TABLE IF NOT EXISTS vulnerability_ignores (
id TEXT PRIMARY KEY,
@@ -16,3 +17,7 @@ CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_env ON vulnerability_ignore
CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_image ON vulnerability_ignores(image_id);
CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_vuln ON vulnerability_ignores(vulnerability_id);
CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_composite ON vulnerability_ignores(environment_id, image_id, vulnerability_id, pkg_name, installed_version);
+
+-- +goose Down
+-- Drop vulnerability_ignores table
+DROP TABLE IF EXISTS vulnerability_ignores;
diff --git a/backend/resources/migrations/postgres/035_backfill_missing_settings.down.sql b/backend/resources/migrations/postgres/035_backfill_missing_settings.down.sql
deleted file mode 100644
index be3dedff2..000000000
--- a/backend/resources/migrations/postgres/035_backfill_missing_settings.down.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-BEGIN;
--- No-op: data backfill migration cannot be safely reversed.
-COMMIT;
diff --git a/backend/resources/migrations/postgres/035_backfill_missing_settings.up.sql b/backend/resources/migrations/postgres/035_backfill_missing_settings.sql
similarity index 89%
rename from backend/resources/migrations/postgres/035_backfill_missing_settings.up.sql
rename to backend/resources/migrations/postgres/035_backfill_missing_settings.sql
index 51a40e005..6fdf3c217 100644
--- a/backend/resources/migrations/postgres/035_backfill_missing_settings.up.sql
+++ b/backend/resources/migrations/postgres/035_backfill_missing_settings.sql
@@ -1,5 +1,4 @@
-BEGIN;
-
+-- +goose Up
-- Backfill missing vulnerability scan settings defaults
INSERT INTO settings (key, value)
VALUES ('vulnerabilityScanEnabled', 'false')
@@ -29,4 +28,5 @@ SET value = ''
WHERE key = 'autoUpdateExcludedContainers'
AND value IS NULL;
-COMMIT;
+-- +goose Down
+-- No-op: data backfill migration cannot be safely reversed.
diff --git a/backend/resources/migrations/postgres/036_notification_log_image_ref_text.down.sql b/backend/resources/migrations/postgres/036_notification_log_image_ref_text.down.sql
deleted file mode 100644
index edf194a2b..000000000
--- a/backend/resources/migrations/postgres/036_notification_log_image_ref_text.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- Revert image_ref back to VARCHAR(255)
-ALTER TABLE notification_logs ALTER COLUMN image_ref TYPE VARCHAR(255);
diff --git a/backend/resources/migrations/postgres/036_notification_log_image_ref_text.up.sql b/backend/resources/migrations/postgres/036_notification_log_image_ref_text.sql
similarity index 53%
rename from backend/resources/migrations/postgres/036_notification_log_image_ref_text.up.sql
rename to backend/resources/migrations/postgres/036_notification_log_image_ref_text.sql
index c9dbc1135..f7da01362 100644
--- a/backend/resources/migrations/postgres/036_notification_log_image_ref_text.up.sql
+++ b/backend/resources/migrations/postgres/036_notification_log_image_ref_text.sql
@@ -1,2 +1,7 @@
+-- +goose Up
-- Change image_ref from VARCHAR(255) to TEXT to support batch notifications with multiple image refs
ALTER TABLE notification_logs ALTER COLUMN image_ref TYPE TEXT;
+
+-- +goose Down
+-- Revert image_ref back to VARCHAR(255)
+ALTER TABLE notification_logs ALTER COLUMN image_ref TYPE VARCHAR(255);
diff --git a/backend/resources/migrations/postgres/037_add_image_builds.down.sql b/backend/resources/migrations/postgres/037_add_image_builds.down.sql
deleted file mode 100644
index 3327a4894..000000000
--- a/backend/resources/migrations/postgres/037_add_image_builds.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- Drop image_builds table
-DROP TABLE IF EXISTS image_builds;
diff --git a/backend/resources/migrations/postgres/037_add_image_builds.up.sql b/backend/resources/migrations/postgres/037_add_image_builds.sql
similarity index 93%
rename from backend/resources/migrations/postgres/037_add_image_builds.up.sql
rename to backend/resources/migrations/postgres/037_add_image_builds.sql
index 531f780bd..7ff8bd404 100644
--- a/backend/resources/migrations/postgres/037_add_image_builds.up.sql
+++ b/backend/resources/migrations/postgres/037_add_image_builds.sql
@@ -1,3 +1,4 @@
+-- +goose Up
-- Add image_builds table for storing build history
CREATE TABLE IF NOT EXISTS image_builds (
id TEXT PRIMARY KEY,
@@ -40,3 +41,7 @@ CREATE TABLE IF NOT EXISTS image_builds (
CREATE INDEX IF NOT EXISTS idx_image_builds_env ON image_builds(environment_id);
CREATE INDEX IF NOT EXISTS idx_image_builds_status ON image_builds(status);
CREATE INDEX IF NOT EXISTS idx_image_builds_created_at ON image_builds(created_at);
+
+-- +goose Down
+-- Drop image_builds table
+DROP TABLE IF EXISTS image_builds;
diff --git a/backend/resources/migrations/postgres/038_create_kv_table.down.sql b/backend/resources/migrations/postgres/038_create_kv_table.down.sql
deleted file mode 100644
index d4b20a7bd..000000000
--- a/backend/resources/migrations/postgres/038_create_kv_table.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP TABLE IF EXISTS kv;
diff --git a/backend/resources/migrations/postgres/038_create_kv_table.up.sql b/backend/resources/migrations/postgres/038_create_kv_table.sql
similarity index 77%
rename from backend/resources/migrations/postgres/038_create_kv_table.up.sql
rename to backend/resources/migrations/postgres/038_create_kv_table.sql
index 6e4e24eba..3fb2a0cc3 100644
--- a/backend/resources/migrations/postgres/038_create_kv_table.up.sql
+++ b/backend/resources/migrations/postgres/038_create_kv_table.sql
@@ -1,6 +1,10 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS kv (
key TEXT NOT NULL PRIMARY KEY,
value TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMPTZ
);
+
+-- +goose Down
+DROP TABLE IF EXISTS kv;
diff --git a/backend/resources/migrations/postgres/039_add_ecr_registry_support.down.sql b/backend/resources/migrations/postgres/039_add_ecr_registry_support.down.sql
deleted file mode 100644
index bba8d4964..000000000
--- a/backend/resources/migrations/postgres/039_add_ecr_registry_support.down.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-ALTER TABLE container_registries DROP COLUMN IF EXISTS registry_type;
-ALTER TABLE container_registries DROP COLUMN IF EXISTS aws_access_key_id;
-ALTER TABLE container_registries DROP COLUMN IF EXISTS aws_secret_access_key;
-ALTER TABLE container_registries DROP COLUMN IF EXISTS aws_region;
-ALTER TABLE container_registries DROP COLUMN IF EXISTS ecr_token;
-ALTER TABLE container_registries DROP COLUMN IF EXISTS ecr_token_generated_at;
diff --git a/backend/resources/migrations/postgres/039_add_ecr_registry_support.up.sql b/backend/resources/migrations/postgres/039_add_ecr_registry_support.sql
similarity index 52%
rename from backend/resources/migrations/postgres/039_add_ecr_registry_support.up.sql
rename to backend/resources/migrations/postgres/039_add_ecr_registry_support.sql
index ba3f1f191..bbea60796 100644
--- a/backend/resources/migrations/postgres/039_add_ecr_registry_support.up.sql
+++ b/backend/resources/migrations/postgres/039_add_ecr_registry_support.sql
@@ -1,6 +1,15 @@
+-- +goose Up
ALTER TABLE container_registries ADD COLUMN IF NOT EXISTS registry_type TEXT NOT NULL DEFAULT 'generic';
ALTER TABLE container_registries ADD COLUMN IF NOT EXISTS aws_access_key_id TEXT;
ALTER TABLE container_registries ADD COLUMN IF NOT EXISTS aws_secret_access_key TEXT;
ALTER TABLE container_registries ADD COLUMN IF NOT EXISTS aws_region TEXT;
ALTER TABLE container_registries ADD COLUMN IF NOT EXISTS ecr_token TEXT;
ALTER TABLE container_registries ADD COLUMN IF NOT EXISTS ecr_token_generated_at TIMESTAMPTZ;
+
+-- +goose Down
+ALTER TABLE container_registries DROP COLUMN IF EXISTS registry_type;
+ALTER TABLE container_registries DROP COLUMN IF EXISTS aws_access_key_id;
+ALTER TABLE container_registries DROP COLUMN IF EXISTS aws_secret_access_key;
+ALTER TABLE container_registries DROP COLUMN IF EXISTS aws_region;
+ALTER TABLE container_registries DROP COLUMN IF EXISTS ecr_token;
+ALTER TABLE container_registries DROP COLUMN IF EXISTS ecr_token_generated_at;
diff --git a/backend/resources/migrations/postgres/040_add_api_key_managed_by.down.sql b/backend/resources/migrations/postgres/040_add_api_key_managed_by.down.sql
deleted file mode 100644
index 7d044ed5c..000000000
--- a/backend/resources/migrations/postgres/040_add_api_key_managed_by.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE api_keys DROP COLUMN IF EXISTS managed_by;
diff --git a/backend/resources/migrations/postgres/040_add_api_key_managed_by.sql b/backend/resources/migrations/postgres/040_add_api_key_managed_by.sql
new file mode 100644
index 000000000..b1d5cb49d
--- /dev/null
+++ b/backend/resources/migrations/postgres/040_add_api_key_managed_by.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+ALTER TABLE api_keys ADD COLUMN IF NOT EXISTS managed_by TEXT;
+
+-- +goose Down
+ALTER TABLE api_keys DROP COLUMN IF EXISTS managed_by;
diff --git a/backend/resources/migrations/postgres/040_add_api_key_managed_by.up.sql b/backend/resources/migrations/postgres/040_add_api_key_managed_by.up.sql
deleted file mode 100644
index e777834e1..000000000
--- a/backend/resources/migrations/postgres/040_add_api_key_managed_by.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE api_keys ADD COLUMN IF NOT EXISTS managed_by TEXT;
diff --git a/backend/resources/migrations/postgres/041_add_query_performance_indexes.down.sql b/backend/resources/migrations/postgres/041_add_query_performance_indexes.down.sql
deleted file mode 100644
index 6573189cc..000000000
--- a/backend/resources/migrations/postgres/041_add_query_performance_indexes.down.sql
+++ /dev/null
@@ -1,32 +0,0 @@
-CREATE INDEX IF NOT EXISTS idx_api_keys_user_id ON api_keys(user_id);
-CREATE INDEX IF NOT EXISTS idx_events_environment_id ON events(environment_id);
-CREATE INDEX IF NOT EXISTS idx_image_update_repository ON image_updates(repository);
-CREATE INDEX IF NOT EXISTS idx_image_update_tag ON image_updates(tag);
-CREATE INDEX IF NOT EXISTS idx_volume_backups_volume_name ON volume_backups(volume_name);
-CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_env ON vulnerability_ignores(environment_id);
-CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_vuln ON vulnerability_ignores(vulnerability_id);
-CREATE INDEX IF NOT EXISTS idx_vulnerability_scans_status ON vulnerability_scans(status);
-
-DROP INDEX IF EXISTS idx_vulnerability_ignores_env_vulnerability_id;
-DROP INDEX IF EXISTS idx_events_environment_timestamp;
-DROP INDEX IF EXISTS idx_image_updates_repository_tag;
-DROP INDEX IF EXISTS idx_image_builds_environment_status;
-DROP INDEX IF EXISTS idx_image_builds_environment_created_at;
-DROP INDEX IF EXISTS idx_volume_backups_volume_name_created_at;
-DROP INDEX IF EXISTS idx_compose_templates_lookup_description;
-DROP INDEX IF EXISTS idx_compose_templates_lookup_name;
-DROP INDEX IF EXISTS idx_projects_dir_name_not_null;
-DROP INDEX IF EXISTS idx_projects_path;
-DROP INDEX IF EXISTS idx_gitops_syncs_environment_project_id;
-DROP INDEX IF EXISTS idx_gitops_syncs_environment_repository_id;
-DROP INDEX IF EXISTS idx_gitops_syncs_environment_last_sync_status;
-DROP INDEX IF EXISTS idx_gitops_syncs_auto_sync_true;
-DROP INDEX IF EXISTS idx_gitops_syncs_environment_auto_sync;
-DROP INDEX IF EXISTS idx_git_repositories_auth_type;
-DROP INDEX IF EXISTS idx_git_repositories_enabled_url;
-DROP INDEX IF EXISTS idx_vulnerability_ignores_env_created_at;
-DROP INDEX IF EXISTS idx_vulnerability_scans_status_total_count;
-DROP INDEX IF EXISTS idx_api_keys_user_managed_by_created_at;
-DROP INDEX IF EXISTS idx_api_keys_expires_at_not_null;
-DROP INDEX IF EXISTS idx_environments_enabled_true;
-DROP INDEX IF EXISTS idx_environments_access_token_not_null;
diff --git a/backend/resources/migrations/postgres/041_add_query_performance_indexes.up.sql b/backend/resources/migrations/postgres/041_add_query_performance_indexes.sql
similarity index 59%
rename from backend/resources/migrations/postgres/041_add_query_performance_indexes.up.sql
rename to backend/resources/migrations/postgres/041_add_query_performance_indexes.sql
index 639cdb800..9685551b6 100644
--- a/backend/resources/migrations/postgres/041_add_query_performance_indexes.up.sql
+++ b/backend/resources/migrations/postgres/041_add_query_performance_indexes.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE INDEX IF NOT EXISTS idx_environments_access_token_not_null
ON environments (access_token)
WHERE access_token IS NOT NULL;
@@ -80,3 +81,37 @@ DROP INDEX IF EXISTS idx_volume_backups_volume_name;
DROP INDEX IF EXISTS idx_vulnerability_ignores_env;
DROP INDEX IF EXISTS idx_vulnerability_ignores_vuln;
DROP INDEX IF EXISTS idx_vulnerability_scans_status;
+
+-- +goose Down
+CREATE INDEX IF NOT EXISTS idx_api_keys_user_id ON api_keys(user_id);
+CREATE INDEX IF NOT EXISTS idx_events_environment_id ON events(environment_id);
+CREATE INDEX IF NOT EXISTS idx_image_update_repository ON image_updates(repository);
+CREATE INDEX IF NOT EXISTS idx_image_update_tag ON image_updates(tag);
+CREATE INDEX IF NOT EXISTS idx_volume_backups_volume_name ON volume_backups(volume_name);
+CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_env ON vulnerability_ignores(environment_id);
+CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_vuln ON vulnerability_ignores(vulnerability_id);
+CREATE INDEX IF NOT EXISTS idx_vulnerability_scans_status ON vulnerability_scans(status);
+
+DROP INDEX IF EXISTS idx_vulnerability_ignores_env_vulnerability_id;
+DROP INDEX IF EXISTS idx_events_environment_timestamp;
+DROP INDEX IF EXISTS idx_image_updates_repository_tag;
+DROP INDEX IF EXISTS idx_image_builds_environment_status;
+DROP INDEX IF EXISTS idx_image_builds_environment_created_at;
+DROP INDEX IF EXISTS idx_volume_backups_volume_name_created_at;
+DROP INDEX IF EXISTS idx_compose_templates_lookup_description;
+DROP INDEX IF EXISTS idx_compose_templates_lookup_name;
+DROP INDEX IF EXISTS idx_projects_dir_name_not_null;
+DROP INDEX IF EXISTS idx_projects_path;
+DROP INDEX IF EXISTS idx_gitops_syncs_environment_project_id;
+DROP INDEX IF EXISTS idx_gitops_syncs_environment_repository_id;
+DROP INDEX IF EXISTS idx_gitops_syncs_environment_last_sync_status;
+DROP INDEX IF EXISTS idx_gitops_syncs_auto_sync_true;
+DROP INDEX IF EXISTS idx_gitops_syncs_environment_auto_sync;
+DROP INDEX IF EXISTS idx_git_repositories_auth_type;
+DROP INDEX IF EXISTS idx_git_repositories_enabled_url;
+DROP INDEX IF EXISTS idx_vulnerability_ignores_env_created_at;
+DROP INDEX IF EXISTS idx_vulnerability_scans_status_total_count;
+DROP INDEX IF EXISTS idx_api_keys_user_managed_by_created_at;
+DROP INDEX IF EXISTS idx_api_keys_expires_at_not_null;
+DROP INDEX IF EXISTS idx_environments_enabled_true;
+DROP INDEX IF EXISTS idx_environments_access_token_not_null;
diff --git a/backend/resources/migrations/postgres/042_add_directory_sync.down.sql b/backend/resources/migrations/postgres/042_add_directory_sync.down.sql
deleted file mode 100644
index 7e1558e96..000000000
--- a/backend/resources/migrations/postgres/042_add_directory_sync.down.sql
+++ /dev/null
@@ -1,9 +0,0 @@
--- Remove directory sync columns from gitops_syncs table
-
-DROP INDEX IF EXISTS idx_gitops_syncs_sync_directory;
-
-ALTER TABLE gitops_syncs DROP COLUMN IF EXISTS max_sync_binary_size;
-ALTER TABLE gitops_syncs DROP COLUMN IF EXISTS max_sync_total_size;
-ALTER TABLE gitops_syncs DROP COLUMN IF EXISTS max_sync_files;
-ALTER TABLE gitops_syncs DROP COLUMN IF EXISTS synced_files;
-ALTER TABLE gitops_syncs DROP COLUMN IF EXISTS sync_directory;
diff --git a/backend/resources/migrations/postgres/042_add_directory_sync.up.sql b/backend/resources/migrations/postgres/042_add_directory_sync.sql
similarity index 66%
rename from backend/resources/migrations/postgres/042_add_directory_sync.up.sql
rename to backend/resources/migrations/postgres/042_add_directory_sync.sql
index 5a52d5212..8240d4aa4 100644
--- a/backend/resources/migrations/postgres/042_add_directory_sync.up.sql
+++ b/backend/resources/migrations/postgres/042_add_directory_sync.sql
@@ -1,3 +1,4 @@
+-- +goose Up
-- Add directory sync support to gitops_syncs table
-- sync_directory: when true, syncs entire directory containing compose file (default: true)
-- synced_files: JSON array of file paths that were synced (for cleanup on updates)
@@ -12,3 +13,14 @@ ALTER TABLE gitops_syncs ADD COLUMN max_sync_total_size BIGINT NOT NULL DEFAULT
ALTER TABLE gitops_syncs ADD COLUMN max_sync_binary_size BIGINT NOT NULL DEFAULT 10485760;
CREATE INDEX IF NOT EXISTS idx_gitops_syncs_sync_directory ON gitops_syncs(sync_directory);
+
+-- +goose Down
+-- Remove directory sync columns from gitops_syncs table
+
+DROP INDEX IF EXISTS idx_gitops_syncs_sync_directory;
+
+ALTER TABLE gitops_syncs DROP COLUMN IF EXISTS max_sync_binary_size;
+ALTER TABLE gitops_syncs DROP COLUMN IF EXISTS max_sync_total_size;
+ALTER TABLE gitops_syncs DROP COLUMN IF EXISTS max_sync_files;
+ALTER TABLE gitops_syncs DROP COLUMN IF EXISTS synced_files;
+ALTER TABLE gitops_syncs DROP COLUMN IF EXISTS sync_directory;
diff --git a/backend/resources/migrations/postgres/043_add_hidden_swarm_node_agents.down.sql b/backend/resources/migrations/postgres/043_add_hidden_swarm_node_agents.down.sql
deleted file mode 100644
index 2c64f302b..000000000
--- a/backend/resources/migrations/postgres/043_add_hidden_swarm_node_agents.down.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-DROP INDEX IF EXISTS idx_environments_parent_swarm_node;
-DROP INDEX IF EXISTS idx_environments_swarm_node_id;
-DROP INDEX IF EXISTS idx_environments_parent_environment_id;
-DROP INDEX IF EXISTS idx_environments_hidden;
-
-ALTER TABLE environments DROP COLUMN swarm_node_id;
-ALTER TABLE environments DROP COLUMN parent_environment_id;
-ALTER TABLE environments DROP COLUMN hidden;
diff --git a/backend/resources/migrations/postgres/043_add_hidden_swarm_node_agents.up.sql b/backend/resources/migrations/postgres/043_add_hidden_swarm_node_agents.sql
similarity index 59%
rename from backend/resources/migrations/postgres/043_add_hidden_swarm_node_agents.up.sql
rename to backend/resources/migrations/postgres/043_add_hidden_swarm_node_agents.sql
index 05162ea43..da2c22604 100644
--- a/backend/resources/migrations/postgres/043_add_hidden_swarm_node_agents.up.sql
+++ b/backend/resources/migrations/postgres/043_add_hidden_swarm_node_agents.sql
@@ -1,3 +1,4 @@
+-- +goose Up
ALTER TABLE environments ADD COLUMN hidden BOOLEAN NOT NULL DEFAULT false;
ALTER TABLE environments ADD COLUMN parent_environment_id TEXT;
ALTER TABLE environments ADD COLUMN swarm_node_id TEXT;
@@ -6,3 +7,13 @@ CREATE INDEX IF NOT EXISTS idx_environments_hidden ON environments(hidden);
CREATE INDEX IF NOT EXISTS idx_environments_parent_environment_id ON environments(parent_environment_id);
CREATE INDEX IF NOT EXISTS idx_environments_swarm_node_id ON environments(swarm_node_id);
CREATE INDEX IF NOT EXISTS idx_environments_parent_swarm_node ON environments(parent_environment_id, swarm_node_id);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_environments_parent_swarm_node;
+DROP INDEX IF EXISTS idx_environments_swarm_node_id;
+DROP INDEX IF EXISTS idx_environments_parent_environment_id;
+DROP INDEX IF EXISTS idx_environments_hidden;
+
+ALTER TABLE environments DROP COLUMN swarm_node_id;
+ALTER TABLE environments DROP COLUMN parent_environment_id;
+ALTER TABLE environments DROP COLUMN hidden;
diff --git a/backend/resources/migrations/postgres/044_allow_nested_project_paths.down.sql b/backend/resources/migrations/postgres/044_allow_nested_project_paths.sql
similarity index 68%
rename from backend/resources/migrations/postgres/044_allow_nested_project_paths.down.sql
rename to backend/resources/migrations/postgres/044_allow_nested_project_paths.sql
index 40c9ab00e..cfa35f043 100644
--- a/backend/resources/migrations/postgres/044_allow_nested_project_paths.down.sql
+++ b/backend/resources/migrations/postgres/044_allow_nested_project_paths.sql
@@ -1,7 +1,15 @@
+-- +goose Up
+ALTER TABLE projects DROP CONSTRAINT IF EXISTS projects_dir_name_key;
+
+DROP INDEX IF EXISTS idx_projects_path;
+CREATE UNIQUE INDEX IF NOT EXISTS idx_projects_path_unique ON projects(path);
+
+-- +goose Down
DROP INDEX IF EXISTS idx_projects_path_unique;
CREATE INDEX IF NOT EXISTS idx_projects_path ON projects(path);
-- Rollback is only safe when dir_name values remain unique.
+-- +goose StatementBegin
DO $$
BEGIN
IF EXISTS (
@@ -14,6 +22,7 @@ BEGIN
RAISE EXCEPTION 'Cannot rollback migration 044: duplicate projects.dir_name values exist. Remove duplicates before running the down migration.';
END IF;
END $$;
+-- +goose StatementEnd
ALTER TABLE projects
ADD CONSTRAINT projects_dir_name_key UNIQUE (dir_name);
diff --git a/backend/resources/migrations/postgres/044_allow_nested_project_paths.up.sql b/backend/resources/migrations/postgres/044_allow_nested_project_paths.up.sql
deleted file mode 100644
index 41fbe618b..000000000
--- a/backend/resources/migrations/postgres/044_allow_nested_project_paths.up.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-ALTER TABLE projects DROP CONSTRAINT IF EXISTS projects_dir_name_key;
-
-DROP INDEX IF EXISTS idx_projects_path;
-CREATE UNIQUE INDEX IF NOT EXISTS idx_projects_path_unique ON projects(path);
diff --git a/backend/resources/migrations/postgres/045_add_webhooks.down.sql b/backend/resources/migrations/postgres/045_add_webhooks.down.sql
deleted file mode 100644
index 0457cf1c1..000000000
--- a/backend/resources/migrations/postgres/045_add_webhooks.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP TABLE IF EXISTS webhooks;
diff --git a/backend/resources/migrations/postgres/045_add_webhooks.up.sql b/backend/resources/migrations/postgres/045_add_webhooks.sql
similarity index 92%
rename from backend/resources/migrations/postgres/045_add_webhooks.up.sql
rename to backend/resources/migrations/postgres/045_add_webhooks.sql
index 0f70c3734..1f4d38676 100644
--- a/backend/resources/migrations/postgres/045_add_webhooks.up.sql
+++ b/backend/resources/migrations/postgres/045_add_webhooks.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS webhooks (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
@@ -16,3 +17,6 @@ CREATE TABLE IF NOT EXISTS webhooks (
CREATE INDEX IF NOT EXISTS idx_webhooks_token_prefix ON webhooks (token_prefix);
CREATE INDEX IF NOT EXISTS idx_webhooks_environment_id ON webhooks (environment_id);
+
+-- +goose Down
+DROP TABLE IF EXISTS webhooks;
diff --git a/backend/resources/migrations/postgres/046_nullable_api_key_user_id.down.sql b/backend/resources/migrations/postgres/046_nullable_api_key_user_id.down.sql
deleted file mode 100644
index 1df2cf8fd..000000000
--- a/backend/resources/migrations/postgres/046_nullable_api_key_user_id.down.sql
+++ /dev/null
@@ -1,3 +0,0 @@
--- Remove environment bootstrap keys (user_id IS NULL) before restoring the NOT NULL constraint.
-DELETE FROM api_keys WHERE user_id IS NULL;
-ALTER TABLE api_keys ALTER COLUMN user_id SET NOT NULL;
diff --git a/backend/resources/migrations/postgres/046_nullable_api_key_user_id.sql b/backend/resources/migrations/postgres/046_nullable_api_key_user_id.sql
new file mode 100644
index 000000000..fa6cd20c5
--- /dev/null
+++ b/backend/resources/migrations/postgres/046_nullable_api_key_user_id.sql
@@ -0,0 +1,9 @@
+-- +goose Up
+-- Environment bootstrap keys are owned by the system, not a user.
+-- Allow user_id to be NULL so agent-side key creation doesn't violate the FK constraint.
+ALTER TABLE api_keys ALTER COLUMN user_id DROP NOT NULL;
+
+-- +goose Down
+-- Remove environment bootstrap keys (user_id IS NULL) before restoring the NOT NULL constraint.
+DELETE FROM api_keys WHERE user_id IS NULL;
+ALTER TABLE api_keys ALTER COLUMN user_id SET NOT NULL;
diff --git a/backend/resources/migrations/postgres/046_nullable_api_key_user_id.up.sql b/backend/resources/migrations/postgres/046_nullable_api_key_user_id.up.sql
deleted file mode 100644
index 98452119a..000000000
--- a/backend/resources/migrations/postgres/046_nullable_api_key_user_id.up.sql
+++ /dev/null
@@ -1,3 +0,0 @@
--- Environment bootstrap keys are owned by the system, not a user.
--- Allow user_id to be NULL so agent-side key creation doesn't violate the FK constraint.
-ALTER TABLE api_keys ALTER COLUMN user_id DROP NOT NULL;
diff --git a/backend/resources/migrations/postgres/047_add_gitops_sync_target_type.down.sql b/backend/resources/migrations/postgres/047_add_gitops_sync_target_type.down.sql
deleted file mode 100644
index da10a53e4..000000000
--- a/backend/resources/migrations/postgres/047_add_gitops_sync_target_type.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE gitops_syncs DROP COLUMN IF EXISTS target_type;
diff --git a/backend/resources/migrations/postgres/047_add_gitops_sync_target_type.up.sql b/backend/resources/migrations/postgres/047_add_gitops_sync_target_type.sql
similarity index 50%
rename from backend/resources/migrations/postgres/047_add_gitops_sync_target_type.up.sql
rename to backend/resources/migrations/postgres/047_add_gitops_sync_target_type.sql
index 467404929..7c4345c70 100644
--- a/backend/resources/migrations/postgres/047_add_gitops_sync_target_type.up.sql
+++ b/backend/resources/migrations/postgres/047_add_gitops_sync_target_type.sql
@@ -1 +1,5 @@
+-- +goose Up
ALTER TABLE gitops_syncs ADD COLUMN target_type VARCHAR(255) NOT NULL DEFAULT 'project';
+
+-- +goose Down
+ALTER TABLE gitops_syncs DROP COLUMN IF EXISTS target_type;
diff --git a/backend/resources/migrations/postgres/048_add_compose_project_name.down.sql b/backend/resources/migrations/postgres/048_add_compose_project_name.down.sql
deleted file mode 100644
index 03e0bf5c4..000000000
--- a/backend/resources/migrations/postgres/048_add_compose_project_name.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE projects DROP COLUMN compose_project_name;
diff --git a/backend/resources/migrations/postgres/048_add_compose_project_name.sql b/backend/resources/migrations/postgres/048_add_compose_project_name.sql
new file mode 100644
index 000000000..a052ead2c
--- /dev/null
+++ b/backend/resources/migrations/postgres/048_add_compose_project_name.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+ALTER TABLE projects ADD COLUMN compose_project_name TEXT;
+
+-- +goose Down
+ALTER TABLE projects DROP COLUMN compose_project_name;
diff --git a/backend/resources/migrations/postgres/048_add_compose_project_name.up.sql b/backend/resources/migrations/postgres/048_add_compose_project_name.up.sql
deleted file mode 100644
index 9155e4826..000000000
--- a/backend/resources/migrations/postgres/048_add_compose_project_name.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE projects ADD COLUMN compose_project_name TEXT;
diff --git a/backend/resources/migrations/postgres/049_add_projects_name_index.down.sql b/backend/resources/migrations/postgres/049_add_projects_name_index.down.sql
deleted file mode 100644
index 2177cfdbb..000000000
--- a/backend/resources/migrations/postgres/049_add_projects_name_index.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP INDEX IF EXISTS idx_projects_name;
diff --git a/backend/resources/migrations/postgres/049_add_projects_name_index.sql b/backend/resources/migrations/postgres/049_add_projects_name_index.sql
new file mode 100644
index 000000000..3f38b2ab0
--- /dev/null
+++ b/backend/resources/migrations/postgres/049_add_projects_name_index.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+CREATE INDEX IF NOT EXISTS idx_projects_name ON projects (name);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_projects_name;
diff --git a/backend/resources/migrations/postgres/049_add_projects_name_index.up.sql b/backend/resources/migrations/postgres/049_add_projects_name_index.up.sql
deleted file mode 100644
index 2deb77b44..000000000
--- a/backend/resources/migrations/postgres/049_add_projects_name_index.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-CREATE INDEX IF NOT EXISTS idx_projects_name ON projects (name);
diff --git a/backend/resources/migrations/postgres/050_add_project_archived.down.sql b/backend/resources/migrations/postgres/050_add_project_archived.down.sql
deleted file mode 100644
index bd71b4c9a..000000000
--- a/backend/resources/migrations/postgres/050_add_project_archived.down.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-DROP INDEX IF EXISTS idx_projects_is_archived;
-ALTER TABLE projects DROP COLUMN archived_at;
-ALTER TABLE projects DROP COLUMN is_archived;
diff --git a/backend/resources/migrations/postgres/050_add_project_archived.up.sql b/backend/resources/migrations/postgres/050_add_project_archived.sql
similarity index 53%
rename from backend/resources/migrations/postgres/050_add_project_archived.up.sql
rename to backend/resources/migrations/postgres/050_add_project_archived.sql
index db3715479..a6d1909bb 100644
--- a/backend/resources/migrations/postgres/050_add_project_archived.up.sql
+++ b/backend/resources/migrations/postgres/050_add_project_archived.sql
@@ -1,3 +1,9 @@
+-- +goose Up
ALTER TABLE projects ADD COLUMN is_archived BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE projects ADD COLUMN archived_at TIMESTAMP;
CREATE INDEX idx_projects_is_archived ON projects(is_archived);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_projects_is_archived;
+ALTER TABLE projects DROP COLUMN archived_at;
+ALTER TABLE projects DROP COLUMN is_archived;
diff --git a/backend/resources/migrations/postgres/051_add_user_sessions.down.sql b/backend/resources/migrations/postgres/051_add_user_sessions.down.sql
deleted file mode 100644
index 58349aa4c..000000000
--- a/backend/resources/migrations/postgres/051_add_user_sessions.down.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-DROP INDEX IF EXISTS idx_user_sessions_expires_at;
-DROP INDEX IF EXISTS idx_user_sessions_user_id;
-DROP TABLE IF EXISTS user_sessions;
diff --git a/backend/resources/migrations/postgres/051_add_user_sessions.up.sql b/backend/resources/migrations/postgres/051_add_user_sessions.sql
similarity index 76%
rename from backend/resources/migrations/postgres/051_add_user_sessions.up.sql
rename to backend/resources/migrations/postgres/051_add_user_sessions.sql
index c384d5b7f..1739b4ba6 100644
--- a/backend/resources/migrations/postgres/051_add_user_sessions.up.sql
+++ b/backend/resources/migrations/postgres/051_add_user_sessions.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS user_sessions (
id TEXT PRIMARY KEY,
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
@@ -13,3 +14,8 @@ CREATE TABLE IF NOT EXISTS user_sessions (
CREATE INDEX IF NOT EXISTS idx_user_sessions_user_id ON user_sessions(user_id);
CREATE INDEX IF NOT EXISTS idx_user_sessions_expires_at ON user_sessions(expires_at);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_user_sessions_expires_at;
+DROP INDEX IF EXISTS idx_user_sessions_user_id;
+DROP TABLE IF EXISTS user_sessions;
diff --git a/backend/resources/migrations/postgres/052_add_project_image_refs.down.sql b/backend/resources/migrations/postgres/052_add_project_image_refs.down.sql
deleted file mode 100644
index e2a56cc0c..000000000
--- a/backend/resources/migrations/postgres/052_add_project_image_refs.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE projects DROP COLUMN image_refs_json;
diff --git a/backend/resources/migrations/postgres/052_add_project_image_refs.sql b/backend/resources/migrations/postgres/052_add_project_image_refs.sql
new file mode 100644
index 000000000..c5e4639c2
--- /dev/null
+++ b/backend/resources/migrations/postgres/052_add_project_image_refs.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+ALTER TABLE projects ADD COLUMN image_refs_json TEXT NOT NULL DEFAULT '';
+
+-- +goose Down
+ALTER TABLE projects DROP COLUMN image_refs_json;
diff --git a/backend/resources/migrations/postgres/052_add_project_image_refs.up.sql b/backend/resources/migrations/postgres/052_add_project_image_refs.up.sql
deleted file mode 100644
index 5758bb697..000000000
--- a/backend/resources/migrations/postgres/052_add_project_image_refs.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE projects ADD COLUMN image_refs_json TEXT NOT NULL DEFAULT '';
diff --git a/backend/resources/migrations/postgres/053_drop_deprecated_v2.down.sql b/backend/resources/migrations/postgres/053_drop_deprecated_v2.down.sql
deleted file mode 100644
index 786df4a83..000000000
--- a/backend/resources/migrations/postgres/053_drop_deprecated_v2.down.sql
+++ /dev/null
@@ -1,10 +0,0 @@
--- v2.0.0 rollback: recreate the apprise_settings table shape (data is not restored).
-CREATE TABLE IF NOT EXISTS apprise_settings (
- id SERIAL PRIMARY KEY,
- api_url TEXT NOT NULL,
- enabled BOOLEAN NOT NULL DEFAULT FALSE,
- image_update_tag VARCHAR(255),
- container_update_tag VARCHAR(255),
- created_at TIMESTAMP,
- updated_at TIMESTAMP
-);
diff --git a/backend/resources/migrations/postgres/053_drop_deprecated_v2.sql b/backend/resources/migrations/postgres/053_drop_deprecated_v2.sql
new file mode 100644
index 000000000..e04f3070a
--- /dev/null
+++ b/backend/resources/migrations/postgres/053_drop_deprecated_v2.sql
@@ -0,0 +1,25 @@
+-- +goose Up
+-- v2.0.0: drop the Apprise notification service table and deprecated settings rows.
+DROP TABLE IF EXISTS apprise_settings;
+
+DELETE FROM settings WHERE key IN (
+ 'dockerPruneMode',
+ 'scheduledPruneContainers',
+ 'scheduledPruneImages',
+ 'scheduledPruneVolumes',
+ 'scheduledPruneNetworks',
+ 'scheduledPruneBuildCache',
+ 'authOidcConfig'
+);
+
+-- +goose Down
+-- v2.0.0 rollback: recreate the apprise_settings table shape (data is not restored).
+CREATE TABLE IF NOT EXISTS apprise_settings (
+ id SERIAL PRIMARY KEY,
+ api_url TEXT NOT NULL,
+ enabled BOOLEAN NOT NULL DEFAULT FALSE,
+ image_update_tag VARCHAR(255),
+ container_update_tag VARCHAR(255),
+ created_at TIMESTAMP,
+ updated_at TIMESTAMP
+);
diff --git a/backend/resources/migrations/postgres/053_drop_deprecated_v2.up.sql b/backend/resources/migrations/postgres/053_drop_deprecated_v2.up.sql
deleted file mode 100644
index c3bbe402d..000000000
--- a/backend/resources/migrations/postgres/053_drop_deprecated_v2.up.sql
+++ /dev/null
@@ -1,12 +0,0 @@
--- v2.0.0: drop the Apprise notification service table and deprecated settings rows.
-DROP TABLE IF EXISTS apprise_settings;
-
-DELETE FROM settings WHERE key IN (
- 'dockerPruneMode',
- 'scheduledPruneContainers',
- 'scheduledPruneImages',
- 'scheduledPruneVolumes',
- 'scheduledPruneNetworks',
- 'scheduledPruneBuildCache',
- 'authOidcConfig'
-);
diff --git a/backend/resources/migrations/postgres/054_add_rbac.down.sql b/backend/resources/migrations/postgres/054_add_rbac.down.sql
deleted file mode 100644
index 0bc7893ed..000000000
--- a/backend/resources/migrations/postgres/054_add_rbac.down.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-
-DELETE FROM settings WHERE key = 'oidcGroupsClaim';
-
-DROP INDEX IF EXISTS idx_orm_claim;
-DROP TABLE IF EXISTS oidc_role_mappings;
-
-DROP INDEX IF EXISTS idx_akp_uniq;
-DROP INDEX IF EXISTS idx_akp_key;
-DROP TABLE IF EXISTS api_key_permissions;
-
-DROP INDEX IF EXISTS idx_ura_uniq;
-DROP INDEX IF EXISTS idx_ura_env;
-DROP INDEX IF EXISTS idx_ura_role;
-DROP INDEX IF EXISTS idx_ura_user;
-DROP TABLE IF EXISTS user_role_assignments;
-
-DROP TABLE IF EXISTS roles;
diff --git a/backend/resources/migrations/postgres/054_add_rbac.up.sql b/backend/resources/migrations/postgres/054_add_rbac.sql
similarity index 83%
rename from backend/resources/migrations/postgres/054_add_rbac.up.sql
rename to backend/resources/migrations/postgres/054_add_rbac.sql
index 811d56bfb..842db8ccb 100644
--- a/backend/resources/migrations/postgres/054_add_rbac.up.sql
+++ b/backend/resources/migrations/postgres/054_add_rbac.sql
@@ -1,4 +1,4 @@
-
+-- +goose Up
CREATE TABLE IF NOT EXISTS roles (
id TEXT PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
@@ -51,3 +51,21 @@ CREATE TABLE IF NOT EXISTS oidc_role_mappings (
);
CREATE INDEX IF NOT EXISTS idx_orm_claim ON oidc_role_mappings(claim_value);
+
+-- +goose Down
+DELETE FROM settings WHERE key = 'oidcGroupsClaim';
+
+DROP INDEX IF EXISTS idx_orm_claim;
+DROP TABLE IF EXISTS oidc_role_mappings;
+
+DROP INDEX IF EXISTS idx_akp_uniq;
+DROP INDEX IF EXISTS idx_akp_key;
+DROP TABLE IF EXISTS api_key_permissions;
+
+DROP INDEX IF EXISTS idx_ura_uniq;
+DROP INDEX IF EXISTS idx_ura_env;
+DROP INDEX IF EXISTS idx_ura_role;
+DROP INDEX IF EXISTS idx_ura_user;
+DROP TABLE IF EXISTS user_role_assignments;
+
+DROP TABLE IF EXISTS roles;
diff --git a/backend/resources/migrations/postgres/055_add_activities.down.sql b/backend/resources/migrations/postgres/055_add_activities.down.sql
deleted file mode 100644
index 58d060bf5..000000000
--- a/backend/resources/migrations/postgres/055_add_activities.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-DROP TABLE IF EXISTS activity_messages;
-DROP TABLE IF EXISTS activities;
diff --git a/backend/resources/migrations/postgres/055_add_activities.up.sql b/backend/resources/migrations/postgres/055_add_activities.sql
similarity index 92%
rename from backend/resources/migrations/postgres/055_add_activities.up.sql
rename to backend/resources/migrations/postgres/055_add_activities.sql
index 728f41a72..d6bdb80d9 100644
--- a/backend/resources/migrations/postgres/055_add_activities.up.sql
+++ b/backend/resources/migrations/postgres/055_add_activities.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE activities (
id TEXT PRIMARY KEY,
created_at TIMESTAMPTZ NOT NULL,
@@ -38,3 +39,7 @@ CREATE TABLE activity_messages (
);
CREATE INDEX idx_activity_messages_activity_created ON activity_messages(activity_id, created_at);
+
+-- +goose Down
+DROP TABLE IF EXISTS activity_messages;
+DROP TABLE IF EXISTS activities;
diff --git a/backend/resources/migrations/postgres/056_add_federated_credentials.down.sql b/backend/resources/migrations/postgres/056_add_federated_credentials.down.sql
deleted file mode 100644
index b52076a30..000000000
--- a/backend/resources/migrations/postgres/056_add_federated_credentials.down.sql
+++ /dev/null
@@ -1,13 +0,0 @@
-DROP INDEX IF EXISTS idx_user_sessions_federated_credential_id;
-ALTER TABLE user_sessions DROP COLUMN IF EXISTS federated_credential_id;
-ALTER TABLE user_sessions DROP COLUMN IF EXISTS source;
-ALTER TABLE users DROP COLUMN IF EXISTS is_service_account;
-
-DROP INDEX IF EXISTS idx_federated_credentials_role_id;
-DROP INDEX IF EXISTS idx_federated_credentials_identity_user_id;
-DROP INDEX IF EXISTS idx_federated_credentials_enabled;
-DROP INDEX IF EXISTS idx_federated_credentials_issuer_url;
-DROP INDEX IF EXISTS idx_federated_token_replays_expires_at;
-DROP INDEX IF EXISTS idx_federated_token_replays_issuer_url;
-DROP TABLE IF EXISTS federated_token_replays;
-DROP TABLE IF EXISTS federated_credentials;
diff --git a/backend/resources/migrations/postgres/056_add_federated_credentials.up.sql b/backend/resources/migrations/postgres/056_add_federated_credentials.sql
similarity index 73%
rename from backend/resources/migrations/postgres/056_add_federated_credentials.up.sql
rename to backend/resources/migrations/postgres/056_add_federated_credentials.sql
index 23b7e3318..dccca12dc 100644
--- a/backend/resources/migrations/postgres/056_add_federated_credentials.up.sql
+++ b/backend/resources/migrations/postgres/056_add_federated_credentials.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS federated_credentials (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
@@ -40,3 +41,18 @@ ALTER TABLE user_sessions ADD COLUMN IF NOT EXISTS source TEXT;
ALTER TABLE user_sessions ADD COLUMN IF NOT EXISTS federated_credential_id TEXT REFERENCES federated_credentials(id) ON DELETE SET NULL;
CREATE INDEX IF NOT EXISTS idx_user_sessions_federated_credential_id ON user_sessions(federated_credential_id);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_user_sessions_federated_credential_id;
+ALTER TABLE user_sessions DROP COLUMN IF EXISTS federated_credential_id;
+ALTER TABLE user_sessions DROP COLUMN IF EXISTS source;
+ALTER TABLE users DROP COLUMN IF EXISTS is_service_account;
+
+DROP INDEX IF EXISTS idx_federated_credentials_role_id;
+DROP INDEX IF EXISTS idx_federated_credentials_identity_user_id;
+DROP INDEX IF EXISTS idx_federated_credentials_enabled;
+DROP INDEX IF EXISTS idx_federated_credentials_issuer_url;
+DROP INDEX IF EXISTS idx_federated_token_replays_expires_at;
+DROP INDEX IF EXISTS idx_federated_token_replays_issuer_url;
+DROP TABLE IF EXISTS federated_token_replays;
+DROP TABLE IF EXISTS federated_credentials;
diff --git a/backend/resources/migrations/sqlite/001_initial_schema.down.sql b/backend/resources/migrations/sqlite/001_initial_schema.down.sql
deleted file mode 100644
index 4702af74c..000000000
--- a/backend/resources/migrations/sqlite/001_initial_schema.down.sql
+++ /dev/null
@@ -1,28 +0,0 @@
--- Drop all tables in reverse order of dependencies
-
-DROP INDEX IF EXISTS idx_auto_update_start_time;
-DROP INDEX IF EXISTS idx_auto_update_resource_id;
-DROP INDEX IF EXISTS idx_image_update_tag;
-DROP INDEX IF EXISTS idx_image_update_repository;
-DROP INDEX IF EXISTS idx_images_tag;
-DROP INDEX IF EXISTS idx_images_repo;
-DROP INDEX IF EXISTS idx_containers_stack_id;
-DROP INDEX IF EXISTS idx_user_sessions_token;
-DROP INDEX IF EXISTS idx_user_sessions_user_id;
-DROP INDEX IF EXISTS idx_settings_public;
-DROP INDEX IF EXISTS idx_settings_key;
-
-DROP TABLE IF EXISTS auto_update_records;
-DROP TABLE IF EXISTS container_registries;
-DROP TABLE IF EXISTS compose_templates;
-DROP TABLE IF EXISTS template_registries;
-DROP TABLE IF EXISTS image_update_table;
-DROP TABLE IF EXISTS networks_table;
-DROP TABLE IF EXISTS volumes_table;
-DROP TABLE IF EXISTS images_table;
-DROP TABLE IF EXISTS containers_table;
-DROP TABLE IF EXISTS environments;
-DROP TABLE IF EXISTS stacks_table;
-DROP TABLE IF EXISTS user_sessions_table;
-DROP TABLE IF EXISTS users_table;
-DROP TABLE IF EXISTS settings;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/001_initial_schema.up.sql b/backend/resources/migrations/sqlite/001_initial_schema.sql
similarity index 85%
rename from backend/resources/migrations/sqlite/001_initial_schema.up.sql
rename to backend/resources/migrations/sqlite/001_initial_schema.sql
index 5faf8c59f..f781237c0 100644
--- a/backend/resources/migrations/sqlite/001_initial_schema.up.sql
+++ b/backend/resources/migrations/sqlite/001_initial_schema.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS settings (
key TEXT NOT NULL PRIMARY KEY,
value TEXT NOT NULL,
@@ -213,4 +214,34 @@ CREATE INDEX IF NOT EXISTS idx_images_tag ON images_table(tag);
CREATE INDEX IF NOT EXISTS idx_image_update_repository ON image_update_table(repository);
CREATE INDEX IF NOT EXISTS idx_image_update_tag ON image_update_table(tag);
CREATE INDEX IF NOT EXISTS idx_auto_update_resource_id ON auto_update_records(resource_id);
-CREATE INDEX IF NOT EXISTS idx_auto_update_start_time ON auto_update_records(start_time);
\ No newline at end of file
+CREATE INDEX IF NOT EXISTS idx_auto_update_start_time ON auto_update_records(start_time);
+
+-- +goose Down
+-- Drop all tables in reverse order of dependencies
+
+DROP INDEX IF EXISTS idx_auto_update_start_time;
+DROP INDEX IF EXISTS idx_auto_update_resource_id;
+DROP INDEX IF EXISTS idx_image_update_tag;
+DROP INDEX IF EXISTS idx_image_update_repository;
+DROP INDEX IF EXISTS idx_images_tag;
+DROP INDEX IF EXISTS idx_images_repo;
+DROP INDEX IF EXISTS idx_containers_stack_id;
+DROP INDEX IF EXISTS idx_user_sessions_token;
+DROP INDEX IF EXISTS idx_user_sessions_user_id;
+DROP INDEX IF EXISTS idx_settings_public;
+DROP INDEX IF EXISTS idx_settings_key;
+
+DROP TABLE IF EXISTS auto_update_records;
+DROP TABLE IF EXISTS container_registries;
+DROP TABLE IF EXISTS compose_templates;
+DROP TABLE IF EXISTS template_registries;
+DROP TABLE IF EXISTS image_update_table;
+DROP TABLE IF EXISTS networks_table;
+DROP TABLE IF EXISTS volumes_table;
+DROP TABLE IF EXISTS images_table;
+DROP TABLE IF EXISTS containers_table;
+DROP TABLE IF EXISTS environments;
+DROP TABLE IF EXISTS stacks_table;
+DROP TABLE IF EXISTS user_sessions_table;
+DROP TABLE IF EXISTS users_table;
+DROP TABLE IF EXISTS settings;
diff --git a/backend/resources/migrations/sqlite/002_create_events_table.down.sql b/backend/resources/migrations/sqlite/002_create_events_table.down.sql
deleted file mode 100644
index d11cf905c..000000000
--- a/backend/resources/migrations/sqlite/002_create_events_table.down.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-DROP INDEX IF EXISTS idx_events_timestamp;
-DROP INDEX IF EXISTS idx_events_environment_id;
-DROP INDEX IF EXISTS idx_events_user_id;
-DROP INDEX IF EXISTS idx_events_resource_id;
-DROP INDEX IF EXISTS idx_events_resource_type;
-DROP INDEX IF EXISTS idx_events_severity;
-DROP INDEX IF EXISTS idx_events_type;
-
-DROP TABLE IF EXISTS events;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/002_create_events_table.up.sql b/backend/resources/migrations/sqlite/002_create_events_table.sql
similarity index 73%
rename from backend/resources/migrations/sqlite/002_create_events_table.up.sql
rename to backend/resources/migrations/sqlite/002_create_events_table.sql
index a81f30d6a..75ee6d13a 100644
--- a/backend/resources/migrations/sqlite/002_create_events_table.up.sql
+++ b/backend/resources/migrations/sqlite/002_create_events_table.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS events (
id TEXT PRIMARY KEY,
type TEXT NOT NULL,
@@ -23,4 +24,15 @@ CREATE INDEX IF NOT EXISTS idx_events_resource_type ON events(resource_type);
CREATE INDEX IF NOT EXISTS idx_events_resource_id ON events(resource_id);
CREATE INDEX IF NOT EXISTS idx_events_user_id ON events(user_id);
CREATE INDEX IF NOT EXISTS idx_events_environment_id ON events(environment_id);
-CREATE INDEX IF NOT EXISTS idx_events_timestamp ON events(timestamp);
\ No newline at end of file
+CREATE INDEX IF NOT EXISTS idx_events_timestamp ON events(timestamp);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_events_timestamp;
+DROP INDEX IF EXISTS idx_events_environment_id;
+DROP INDEX IF EXISTS idx_events_user_id;
+DROP INDEX IF EXISTS idx_events_resource_id;
+DROP INDEX IF EXISTS idx_events_resource_type;
+DROP INDEX IF EXISTS idx_events_severity;
+DROP INDEX IF EXISTS idx_events_type;
+
+DROP TABLE IF EXISTS events;
diff --git a/backend/resources/migrations/sqlite/003_remove_events_environment_fk.down.sql b/backend/resources/migrations/sqlite/003_remove_events_environment_fk.down.sql
deleted file mode 100644
index fd30aec16..000000000
--- a/backend/resources/migrations/sqlite/003_remove_events_environment_fk.down.sql
+++ /dev/null
@@ -1,4 +0,0 @@
--- Create migration file: backend/resources/migrations/sqlite/003_remove_events_environment_fk.down.sql
--- This would require recreating the table with the foreign key constraint
--- For simplicity, we'll leave this empty since rolling back would be complex in SQLite
-DROP TABLE IF EXISTS events;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/003_remove_events_environment_fk.up.sql b/backend/resources/migrations/sqlite/003_remove_events_environment_fk.sql
similarity index 81%
rename from backend/resources/migrations/sqlite/003_remove_events_environment_fk.up.sql
rename to backend/resources/migrations/sqlite/003_remove_events_environment_fk.sql
index 209cfacf1..38d7e9305 100644
--- a/backend/resources/migrations/sqlite/003_remove_events_environment_fk.up.sql
+++ b/backend/resources/migrations/sqlite/003_remove_events_environment_fk.sql
@@ -1,3 +1,5 @@
+-- +goose NO TRANSACTION
+-- +goose Up
-- SQLite doesn't support dropping foreign key constraints directly
-- We need to recreate the table without the constraint
@@ -34,4 +36,9 @@ CREATE INDEX IF NOT EXISTS idx_events_user_id ON events(user_id);
CREATE INDEX IF NOT EXISTS idx_events_environment_id ON events(environment_id);
CREATE INDEX IF NOT EXISTS idx_events_timestamp ON events(timestamp);
-PRAGMA foreign_keys=on;
\ No newline at end of file
+PRAGMA foreign_keys=on;
+
+-- +goose Down
+-- This would require recreating the table with the foreign key constraint
+-- For simplicity, we'll leave this empty since rolling back would be complex in SQLite
+DROP TABLE IF EXISTS events;
diff --git a/backend/resources/migrations/sqlite/004_project_cache.down.sql b/backend/resources/migrations/sqlite/004_project_cache.down.sql
deleted file mode 100644
index 4048f9cef..000000000
--- a/backend/resources/migrations/sqlite/004_project_cache.down.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-DROP INDEX IF EXISTS idx_project_cache_auto_update;
-DROP INDEX IF EXISTS idx_project_cache_cached_at;
-DROP INDEX IF EXISTS idx_project_cache_status;
-DROP TABLE IF EXISTS project_cache;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/004_project_cache.up.sql b/backend/resources/migrations/sqlite/004_project_cache.sql
similarity index 77%
rename from backend/resources/migrations/sqlite/004_project_cache.up.sql
rename to backend/resources/migrations/sqlite/004_project_cache.sql
index 9977c303e..bebd4dc1a 100644
--- a/backend/resources/migrations/sqlite/004_project_cache.up.sql
+++ b/backend/resources/migrations/sqlite/004_project_cache.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS project_cache (
id TEXT PRIMARY KEY,
stack_id TEXT UNIQUE NOT NULL,
@@ -18,4 +19,10 @@ CREATE TABLE IF NOT EXISTS project_cache (
CREATE INDEX idx_project_cache_status ON project_cache(status);
CREATE INDEX idx_project_cache_cached_at ON project_cache(cached_at);
-CREATE INDEX idx_project_cache_auto_update ON project_cache(auto_update);
\ No newline at end of file
+CREATE INDEX idx_project_cache_auto_update ON project_cache(auto_update);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_project_cache_auto_update;
+DROP INDEX IF EXISTS idx_project_cache_cached_at;
+DROP INDEX IF EXISTS idx_project_cache_status;
+DROP TABLE IF EXISTS project_cache;
diff --git a/backend/resources/migrations/sqlite/005_drop_user_sessions_table.down.sql b/backend/resources/migrations/sqlite/005_drop_user_sessions_table.sql
similarity index 72%
rename from backend/resources/migrations/sqlite/005_drop_user_sessions_table.down.sql
rename to backend/resources/migrations/sqlite/005_drop_user_sessions_table.sql
index 20c1409f5..7967ae065 100644
--- a/backend/resources/migrations/sqlite/005_drop_user_sessions_table.down.sql
+++ b/backend/resources/migrations/sqlite/005_drop_user_sessions_table.sql
@@ -1,3 +1,11 @@
+-- +goose Up
+-- Drop indexes first (safe if they exist), then drop the table
+DROP INDEX IF EXISTS idx_user_sessions_token;
+DROP INDEX IF EXISTS idx_user_sessions_user_id;
+
+DROP TABLE IF EXISTS user_sessions_table;
+
+-- +goose Down
-- Recreate user_sessions_table (matches initial schema)
CREATE TABLE IF NOT EXISTS user_sessions_table (
id TEXT PRIMARY KEY,
@@ -13,4 +21,4 @@ CREATE TABLE IF NOT EXISTS user_sessions_table (
);
CREATE INDEX IF NOT EXISTS idx_user_sessions_user_id ON user_sessions_table(user_id);
-CREATE INDEX IF NOT EXISTS idx_user_sessions_token ON user_sessions_table(token);
\ No newline at end of file
+CREATE INDEX IF NOT EXISTS idx_user_sessions_token ON user_sessions_table(token);
diff --git a/backend/resources/migrations/sqlite/005_drop_user_sessions_table.up.sql b/backend/resources/migrations/sqlite/005_drop_user_sessions_table.up.sql
deleted file mode 100644
index 73c49bd0b..000000000
--- a/backend/resources/migrations/sqlite/005_drop_user_sessions_table.up.sql
+++ /dev/null
@@ -1,5 +0,0 @@
--- Drop indexes first (safe if they exist), then drop the table
-DROP INDEX IF EXISTS idx_user_sessions_token;
-DROP INDEX IF EXISTS idx_user_sessions_user_id;
-
-DROP TABLE IF EXISTS user_sessions_table;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/006_rename_tables.down.sql b/backend/resources/migrations/sqlite/006_rename_tables.down.sql
deleted file mode 100644
index 9797bb4be..000000000
--- a/backend/resources/migrations/sqlite/006_rename_tables.down.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-PRAGMA foreign_keys=ON;
-PRAGMA legacy_alter_table=ON;
-
-ALTER TABLE users RENAME TO users_table;
-ALTER TABLE image_updates RENAME TO image_update_table;
-ALTER TABLE images RENAME TO images_table;
-ALTER TABLE containers RENAME TO containers_table;
-ALTER TABLE networks RENAME TO networks_table;
-ALTER TABLE volumes RENAME TO volumes_table;
-ALTER TABLE stacks RENAME TO stacks_table;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/006_rename_tables.sql b/backend/resources/migrations/sqlite/006_rename_tables.sql
new file mode 100644
index 000000000..16553297e
--- /dev/null
+++ b/backend/resources/migrations/sqlite/006_rename_tables.sql
@@ -0,0 +1,24 @@
+-- +goose NO TRANSACTION
+-- +goose Up
+PRAGMA foreign_keys=ON;
+PRAGMA legacy_alter_table=ON;
+
+ALTER TABLE users_table RENAME TO users;
+ALTER TABLE image_update_table RENAME TO image_updates;
+ALTER TABLE images_table RENAME TO images;
+ALTER TABLE containers_table RENAME TO containers;
+ALTER TABLE networks_table RENAME TO networks;
+ALTER TABLE volumes_table RENAME TO volumes;
+ALTER TABLE stacks_table RENAME TO stacks;
+
+-- +goose Down
+PRAGMA foreign_keys=ON;
+PRAGMA legacy_alter_table=ON;
+
+ALTER TABLE users RENAME TO users_table;
+ALTER TABLE image_updates RENAME TO image_update_table;
+ALTER TABLE images RENAME TO images_table;
+ALTER TABLE containers RENAME TO containers_table;
+ALTER TABLE networks RENAME TO networks_table;
+ALTER TABLE volumes RENAME TO volumes_table;
+ALTER TABLE stacks RENAME TO stacks_table;
diff --git a/backend/resources/migrations/sqlite/006_rename_tables.up.sql b/backend/resources/migrations/sqlite/006_rename_tables.up.sql
deleted file mode 100644
index a43165999..000000000
--- a/backend/resources/migrations/sqlite/006_rename_tables.up.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-PRAGMA foreign_keys=ON;
-PRAGMA legacy_alter_table=ON;
-
-ALTER TABLE users_table RENAME TO users;
-ALTER TABLE image_update_table RENAME TO image_updates;
-ALTER TABLE images_table RENAME TO images;
-ALTER TABLE containers_table RENAME TO containers;
-ALTER TABLE networks_table RENAME TO networks;
-ALTER TABLE volumes_table RENAME TO volumes;
-ALTER TABLE stacks_table RENAME TO stacks;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/007_add_user_oidc_tokens.down.sql b/backend/resources/migrations/sqlite/007_add_user_oidc_tokens.down.sql
deleted file mode 100644
index cd2fc759a..000000000
--- a/backend/resources/migrations/sqlite/007_add_user_oidc_tokens.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- SQLite cannot DROP COLUMN directly. No-op down migration.
--- To rollback manually, recreate the users table without these columns and copy data back.
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/007_add_user_oidc_tokens.sql b/backend/resources/migrations/sqlite/007_add_user_oidc_tokens.sql
new file mode 100644
index 000000000..389ba2d23
--- /dev/null
+++ b/backend/resources/migrations/sqlite/007_add_user_oidc_tokens.sql
@@ -0,0 +1,8 @@
+-- +goose Up
+ALTER TABLE users ADD COLUMN oidc_access_token TEXT;
+ALTER TABLE users ADD COLUMN oidc_refresh_token TEXT;
+ALTER TABLE users ADD COLUMN oidc_access_token_expires_at DATETIME;
+
+-- +goose Down
+-- SQLite cannot DROP COLUMN directly. No-op down migration.
+-- To rollback manually, recreate the users table without these columns and copy data back.
diff --git a/backend/resources/migrations/sqlite/007_add_user_oidc_tokens.up.sql b/backend/resources/migrations/sqlite/007_add_user_oidc_tokens.up.sql
deleted file mode 100644
index 7312312f9..000000000
--- a/backend/resources/migrations/sqlite/007_add_user_oidc_tokens.up.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-ALTER TABLE users ADD COLUMN oidc_access_token TEXT;
-ALTER TABLE users ADD COLUMN oidc_refresh_token TEXT;
-ALTER TABLE users ADD COLUMN oidc_access_token_expires_at DATETIME;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/008_clean_compose_templates.down.sql b/backend/resources/migrations/sqlite/008_clean_compose_templates.down.sql
deleted file mode 100644
index 6e8ecf220..000000000
--- a/backend/resources/migrations/sqlite/008_clean_compose_templates.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE compose_templates ADD COLUMN meta_updated_at TEXT;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/008_clean_compose_templates.sql b/backend/resources/migrations/sqlite/008_clean_compose_templates.sql
new file mode 100644
index 000000000..68956454a
--- /dev/null
+++ b/backend/resources/migrations/sqlite/008_clean_compose_templates.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+ALTER TABLE compose_templates DROP COLUMN meta_updated_at;
+
+-- +goose Down
+ALTER TABLE compose_templates ADD COLUMN meta_updated_at TEXT;
diff --git a/backend/resources/migrations/sqlite/008_clean_compose_templates.up.sql b/backend/resources/migrations/sqlite/008_clean_compose_templates.up.sql
deleted file mode 100644
index f7590971d..000000000
--- a/backend/resources/migrations/sqlite/008_clean_compose_templates.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE compose_templates DROP COLUMN meta_updated_at;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/009_add_image_update_auth_fields.down.sql b/backend/resources/migrations/sqlite/009_add_image_update_auth_fields.down.sql
deleted file mode 100644
index 562d4f0e1..000000000
--- a/backend/resources/migrations/sqlite/009_add_image_update_auth_fields.down.sql
+++ /dev/null
@@ -1 +0,0 @@
--- no-op: dropping columns in SQLite requires table rebuild; intentionally left empty
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/009_add_image_update_auth_fields.up.sql b/backend/resources/migrations/sqlite/009_add_image_update_auth_fields.sql
similarity index 65%
rename from backend/resources/migrations/sqlite/009_add_image_update_auth_fields.up.sql
rename to backend/resources/migrations/sqlite/009_add_image_update_auth_fields.sql
index 8d7f71804..277dddb2f 100644
--- a/backend/resources/migrations/sqlite/009_add_image_update_auth_fields.up.sql
+++ b/backend/resources/migrations/sqlite/009_add_image_update_auth_fields.sql
@@ -1,4 +1,8 @@
+-- +goose Up
ALTER TABLE image_updates ADD COLUMN auth_method TEXT;
ALTER TABLE image_updates ADD COLUMN auth_username TEXT;
ALTER TABLE image_updates ADD COLUMN auth_registry TEXT;
-ALTER TABLE image_updates ADD COLUMN used_credential INTEGER DEFAULT 0;
\ No newline at end of file
+ALTER TABLE image_updates ADD COLUMN used_credential INTEGER DEFAULT 0;
+
+-- +goose Down
+-- no-op: dropping columns in SQLite requires table rebuild; intentionally left empty
diff --git a/backend/resources/migrations/sqlite/010_rework_environments.down.sql b/backend/resources/migrations/sqlite/010_rework_environments.down.sql
deleted file mode 100644
index 68df67aca..000000000
--- a/backend/resources/migrations/sqlite/010_rework_environments.down.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-ALTER TABLE environments DROP COLUMN access_token;
-ALTER TABLE environments ADD COLUMN hostname TEXT NOT NULL DEFAULT '';
-ALTER TABLE environments ADD COLUMN description TEXT;
-DROP INDEX IF EXISTS idx_environments_api_url;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/010_rework_environments.sql b/backend/resources/migrations/sqlite/010_rework_environments.sql
new file mode 100644
index 000000000..fc43665af
--- /dev/null
+++ b/backend/resources/migrations/sqlite/010_rework_environments.sql
@@ -0,0 +1,11 @@
+-- +goose Up
+ALTER TABLE environments DROP COLUMN hostname;
+ALTER TABLE environments DROP COLUMN description;
+ALTER TABLE environments ADD COLUMN access_token TEXT;
+CREATE INDEX IF NOT EXISTS idx_environments_api_url ON environments(api_url);
+
+-- +goose Down
+ALTER TABLE environments DROP COLUMN access_token;
+ALTER TABLE environments ADD COLUMN hostname TEXT NOT NULL DEFAULT '';
+ALTER TABLE environments ADD COLUMN description TEXT;
+DROP INDEX IF EXISTS idx_environments_api_url;
diff --git a/backend/resources/migrations/sqlite/010_rework_environments.up.sql b/backend/resources/migrations/sqlite/010_rework_environments.up.sql
deleted file mode 100644
index 6b7c2de60..000000000
--- a/backend/resources/migrations/sqlite/010_rework_environments.up.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-ALTER TABLE environments DROP COLUMN hostname;
-ALTER TABLE environments DROP COLUMN description;
-ALTER TABLE environments ADD COLUMN access_token TEXT;
-CREATE INDEX IF NOT EXISTS idx_environments_api_url ON environments(api_url);
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/011_add_environment_name.down.sql b/backend/resources/migrations/sqlite/011_add_environment_name.down.sql
deleted file mode 100644
index 7bdbdc63b..000000000
--- a/backend/resources/migrations/sqlite/011_add_environment_name.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-ALTER TABLE environments DROP COLUMN name;
-DROP INDEX IF EXISTS idx_environments_name;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/011_add_environment_name.sql b/backend/resources/migrations/sqlite/011_add_environment_name.sql
new file mode 100644
index 000000000..e719b6895
--- /dev/null
+++ b/backend/resources/migrations/sqlite/011_add_environment_name.sql
@@ -0,0 +1,7 @@
+-- +goose Up
+ALTER TABLE environments ADD COLUMN name TEXT DEFAULT '';
+CREATE INDEX IF NOT EXISTS idx_environments_name ON environments(name);
+
+-- +goose Down
+ALTER TABLE environments DROP COLUMN name;
+DROP INDEX IF EXISTS idx_environments_name;
diff --git a/backend/resources/migrations/sqlite/011_add_environment_name.up.sql b/backend/resources/migrations/sqlite/011_add_environment_name.up.sql
deleted file mode 100644
index 05c0970a5..000000000
--- a/backend/resources/migrations/sqlite/011_add_environment_name.up.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-ALTER TABLE environments ADD COLUMN name TEXT DEFAULT '';
-CREATE INDEX IF NOT EXISTS idx_environments_name ON environments(name);
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/012_add_user_locale.down.sql b/backend/resources/migrations/sqlite/012_add_user_locale.down.sql
deleted file mode 100644
index 5e16673d8..000000000
--- a/backend/resources/migrations/sqlite/012_add_user_locale.down.sql
+++ /dev/null
@@ -1 +0,0 @@
--- SQLite down migration: to rollback, recreate the users table without the 'locale' column and copy data back.
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/012_add_user_locale.sql b/backend/resources/migrations/sqlite/012_add_user_locale.sql
new file mode 100644
index 000000000..17e9da3fa
--- /dev/null
+++ b/backend/resources/migrations/sqlite/012_add_user_locale.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+ALTER TABLE users ADD COLUMN locale TEXT;
+
+-- +goose Down
+-- SQLite down migration: to rollback, recreate the users table without the 'locale' column and copy data back.
diff --git a/backend/resources/migrations/sqlite/012_add_user_locale.up.sql b/backend/resources/migrations/sqlite/012_add_user_locale.up.sql
deleted file mode 100644
index 99644e0c9..000000000
--- a/backend/resources/migrations/sqlite/012_add_user_locale.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE users ADD COLUMN locale TEXT;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/013_stacks_to_projects.down.sql b/backend/resources/migrations/sqlite/013_stacks_to_projects.sql
similarity index 74%
rename from backend/resources/migrations/sqlite/013_stacks_to_projects.down.sql
rename to backend/resources/migrations/sqlite/013_stacks_to_projects.sql
index 0a9d877f2..0d4fb39b4 100644
--- a/backend/resources/migrations/sqlite/013_stacks_to_projects.down.sql
+++ b/backend/resources/migrations/sqlite/013_stacks_to_projects.sql
@@ -1,3 +1,11 @@
+-- +goose Up
+-- Rename stacks -> projects
+ALTER TABLE stacks RENAME TO projects;
+
+-- Remove legacy cache table
+DROP TABLE IF EXISTS project_cache;
+
+-- +goose Down
-- Recreate legacy cache table
CREATE TABLE IF NOT EXISTS project_cache (
id TEXT PRIMARY KEY,
@@ -17,4 +25,4 @@ CREATE TABLE IF NOT EXISTS project_cache (
CREATE UNIQUE INDEX IF NOT EXISTS idx_project_cache_stack_id ON project_cache(stack_id);
-- Rename projects -> stacks
-ALTER TABLE projects RENAME TO stacks;
\ No newline at end of file
+ALTER TABLE projects RENAME TO stacks;
diff --git a/backend/resources/migrations/sqlite/013_stacks_to_projects.up.sql b/backend/resources/migrations/sqlite/013_stacks_to_projects.up.sql
deleted file mode 100644
index 6af4c2d00..000000000
--- a/backend/resources/migrations/sqlite/013_stacks_to_projects.up.sql
+++ /dev/null
@@ -1,5 +0,0 @@
--- Rename stacks -> projects
-ALTER TABLE stacks RENAME TO projects;
-
--- Remove legacy cache table
-DROP TABLE IF EXISTS project_cache;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/014_containers_project_fk.down.sql b/backend/resources/migrations/sqlite/014_containers_project_fk.down.sql
deleted file mode 100644
index 2f8ccb84c..000000000
--- a/backend/resources/migrations/sqlite/014_containers_project_fk.down.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-PRAGMA foreign_keys=off;
-ALTER TABLE containers RENAME COLUMN project_id TO stack_id;
-PRAGMA foreign_keys=on;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/014_containers_project_fk.sql b/backend/resources/migrations/sqlite/014_containers_project_fk.sql
new file mode 100644
index 000000000..a2c5477d8
--- /dev/null
+++ b/backend/resources/migrations/sqlite/014_containers_project_fk.sql
@@ -0,0 +1,10 @@
+-- +goose NO TRANSACTION
+-- +goose Up
+PRAGMA foreign_keys=off;
+ALTER TABLE containers RENAME COLUMN stack_id TO project_id;
+PRAGMA foreign_keys=on;
+
+-- +goose Down
+PRAGMA foreign_keys=off;
+ALTER TABLE containers RENAME COLUMN project_id TO stack_id;
+PRAGMA foreign_keys=on;
diff --git a/backend/resources/migrations/sqlite/014_containers_project_fk.up.sql b/backend/resources/migrations/sqlite/014_containers_project_fk.up.sql
deleted file mode 100644
index 03c966e6b..000000000
--- a/backend/resources/migrations/sqlite/014_containers_project_fk.up.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-PRAGMA foreign_keys=off;
-ALTER TABLE containers RENAME COLUMN stack_id TO project_id;
-PRAGMA foreign_keys=on;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/015_rename_stacks_directory_setting.down.sql b/backend/resources/migrations/sqlite/015_rename_stacks_directory_setting.down.sql
deleted file mode 100644
index 69a8f21ee..000000000
--- a/backend/resources/migrations/sqlite/015_rename_stacks_directory_setting.down.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-INSERT OR IGNORE INTO settings (key, value)
-SELECT 'stacksDirectory', value
-FROM settings
-WHERE key = 'projectsDirectory';
-
-DELETE FROM settings WHERE key = 'projectsDirectory';
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/015_rename_stacks_directory_setting.sql b/backend/resources/migrations/sqlite/015_rename_stacks_directory_setting.sql
new file mode 100644
index 000000000..22e0870e3
--- /dev/null
+++ b/backend/resources/migrations/sqlite/015_rename_stacks_directory_setting.sql
@@ -0,0 +1,15 @@
+-- +goose Up
+INSERT OR IGNORE INTO settings (key, value)
+SELECT 'projectsDirectory', value
+FROM settings
+WHERE key = 'stacksDirectory';
+
+DELETE FROM settings WHERE key = 'stacksDirectory';
+
+-- +goose Down
+INSERT OR IGNORE INTO settings (key, value)
+SELECT 'stacksDirectory', value
+FROM settings
+WHERE key = 'projectsDirectory';
+
+DELETE FROM settings WHERE key = 'projectsDirectory';
diff --git a/backend/resources/migrations/sqlite/015_rename_stacks_directory_setting.up.sql b/backend/resources/migrations/sqlite/015_rename_stacks_directory_setting.up.sql
deleted file mode 100644
index 060032e9f..000000000
--- a/backend/resources/migrations/sqlite/015_rename_stacks_directory_setting.up.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-INSERT OR IGNORE INTO settings (key, value)
-SELECT 'projectsDirectory', value
-FROM settings
-WHERE key = 'stacksDirectory';
-
-DELETE FROM settings WHERE key = 'stacksDirectory';
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/016_drop_image_table.down.sql b/backend/resources/migrations/sqlite/016_drop_image_table.sql
similarity index 85%
rename from backend/resources/migrations/sqlite/016_drop_image_table.down.sql
rename to backend/resources/migrations/sqlite/016_drop_image_table.sql
index 4b92fe99e..ee4747d1e 100644
--- a/backend/resources/migrations/sqlite/016_drop_image_table.down.sql
+++ b/backend/resources/migrations/sqlite/016_drop_image_table.sql
@@ -1,3 +1,7 @@
+-- +goose Up
+DROP TABLE IF EXISTS images_table;
+
+-- +goose Down
CREATE TABLE IF NOT EXISTS images_table (
id TEXT PRIMARY KEY,
repo_tags TEXT,
@@ -11,4 +15,4 @@ CREATE TABLE IF NOT EXISTS images_table (
in_use BOOLEAN NOT NULL DEFAULT false,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME
-);
\ No newline at end of file
+);
diff --git a/backend/resources/migrations/sqlite/016_drop_image_table.up.sql b/backend/resources/migrations/sqlite/016_drop_image_table.up.sql
deleted file mode 100644
index 39d4074ea..000000000
--- a/backend/resources/migrations/sqlite/016_drop_image_table.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP TABLE IF EXISTS images_table;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/017_drop_unused_docker_tables.down.sql b/backend/resources/migrations/sqlite/017_drop_unused_docker_tables.sql
similarity index 91%
rename from backend/resources/migrations/sqlite/017_drop_unused_docker_tables.down.sql
rename to backend/resources/migrations/sqlite/017_drop_unused_docker_tables.sql
index 6383baa64..8c33c6760 100644
--- a/backend/resources/migrations/sqlite/017_drop_unused_docker_tables.down.sql
+++ b/backend/resources/migrations/sqlite/017_drop_unused_docker_tables.sql
@@ -1,3 +1,9 @@
+-- +goose Up
+DROP TABLE IF EXISTS containers;
+DROP TABLE IF EXISTS volumes;
+DROP TABLE IF EXISTS networks;
+
+-- +goose Down
-- Recreate containers table (for rollback only)
CREATE TABLE IF NOT EXISTS containers (
id TEXT PRIMARY KEY,
diff --git a/backend/resources/migrations/sqlite/017_drop_unused_docker_tables.up.sql b/backend/resources/migrations/sqlite/017_drop_unused_docker_tables.up.sql
deleted file mode 100644
index 830b9c22c..000000000
--- a/backend/resources/migrations/sqlite/017_drop_unused_docker_tables.up.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-DROP TABLE IF EXISTS containers;
-DROP TABLE IF EXISTS volumes;
-DROP TABLE IF EXISTS networks;
diff --git a/backend/resources/migrations/sqlite/018_add_project_status_reason.down.sql b/backend/resources/migrations/sqlite/018_add_project_status_reason.down.sql
deleted file mode 100644
index 8b190d0e0..000000000
--- a/backend/resources/migrations/sqlite/018_add_project_status_reason.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE projects DROP COLUMN status_reason;
diff --git a/backend/resources/migrations/sqlite/018_add_project_status_reason.sql b/backend/resources/migrations/sqlite/018_add_project_status_reason.sql
new file mode 100644
index 000000000..f6a7b9547
--- /dev/null
+++ b/backend/resources/migrations/sqlite/018_add_project_status_reason.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+ALTER TABLE projects ADD COLUMN status_reason TEXT;
+
+-- +goose Down
+ALTER TABLE projects DROP COLUMN status_reason;
diff --git a/backend/resources/migrations/sqlite/018_add_project_status_reason.up.sql b/backend/resources/migrations/sqlite/018_add_project_status_reason.up.sql
deleted file mode 100644
index 87131d0d9..000000000
--- a/backend/resources/migrations/sqlite/018_add_project_status_reason.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE projects ADD COLUMN status_reason TEXT;
diff --git a/backend/resources/migrations/sqlite/019_add_user_requires_password_change.down.sql b/backend/resources/migrations/sqlite/019_add_user_requires_password_change.down.sql
deleted file mode 100644
index da4627ead..000000000
--- a/backend/resources/migrations/sqlite/019_add_user_requires_password_change.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE users DROP COLUMN requires_password_change;
diff --git a/backend/resources/migrations/sqlite/019_add_user_requires_password_change.sql b/backend/resources/migrations/sqlite/019_add_user_requires_password_change.sql
new file mode 100644
index 000000000..a8ea579bd
--- /dev/null
+++ b/backend/resources/migrations/sqlite/019_add_user_requires_password_change.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+ALTER TABLE users ADD COLUMN requires_password_change BOOLEAN NOT NULL DEFAULT 0;
+
+-- +goose Down
+ALTER TABLE users DROP COLUMN requires_password_change;
diff --git a/backend/resources/migrations/sqlite/019_add_user_requires_password_change.up.sql b/backend/resources/migrations/sqlite/019_add_user_requires_password_change.up.sql
deleted file mode 100644
index b3e49b650..000000000
--- a/backend/resources/migrations/sqlite/019_add_user_requires_password_change.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE users ADD COLUMN requires_password_change BOOLEAN NOT NULL DEFAULT 0;
diff --git a/backend/resources/migrations/sqlite/020_remove_mobile_navigation_scroll_to_hide_setting.down.sql b/backend/resources/migrations/sqlite/020_remove_mobile_navigation_scroll_to_hide_setting.down.sql
deleted file mode 100644
index 5ac9b7c71..000000000
--- a/backend/resources/migrations/sqlite/020_remove_mobile_navigation_scroll_to_hide_setting.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-INSERT INTO settings (key, value) VALUES ('mobileNavigationScrollToHide', 'true');
-
diff --git a/backend/resources/migrations/sqlite/020_remove_mobile_navigation_scroll_to_hide_setting.sql b/backend/resources/migrations/sqlite/020_remove_mobile_navigation_scroll_to_hide_setting.sql
new file mode 100644
index 000000000..13bb22f60
--- /dev/null
+++ b/backend/resources/migrations/sqlite/020_remove_mobile_navigation_scroll_to_hide_setting.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+DELETE FROM settings WHERE key = 'mobileNavigationScrollToHide';
+
+-- +goose Down
+INSERT INTO settings (key, value) VALUES ('mobileNavigationScrollToHide', 'true');
diff --git a/backend/resources/migrations/sqlite/020_remove_mobile_navigation_scroll_to_hide_setting.up.sql b/backend/resources/migrations/sqlite/020_remove_mobile_navigation_scroll_to_hide_setting.up.sql
deleted file mode 100644
index 3f490bb39..000000000
--- a/backend/resources/migrations/sqlite/020_remove_mobile_navigation_scroll_to_hide_setting.up.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-DELETE FROM settings WHERE key = 'mobileNavigationScrollToHide';
-
diff --git a/backend/resources/migrations/sqlite/021_add_notifications.down.sql b/backend/resources/migrations/sqlite/021_add_notifications.down.sql
deleted file mode 100644
index 8733d0b5b..000000000
--- a/backend/resources/migrations/sqlite/021_add_notifications.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-DROP TABLE IF EXISTS notification_logs;
-DROP TABLE IF EXISTS notification_settings;
diff --git a/backend/resources/migrations/sqlite/021_add_notifications.up.sql b/backend/resources/migrations/sqlite/021_add_notifications.sql
similarity index 88%
rename from backend/resources/migrations/sqlite/021_add_notifications.up.sql
rename to backend/resources/migrations/sqlite/021_add_notifications.sql
index 019e7093b..d06282f94 100644
--- a/backend/resources/migrations/sqlite/021_add_notifications.up.sql
+++ b/backend/resources/migrations/sqlite/021_add_notifications.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS notification_settings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
provider VARCHAR(50) NOT NULL,
@@ -23,3 +24,7 @@ CREATE TABLE IF NOT EXISTS notification_logs (
CREATE INDEX idx_notification_logs_provider ON notification_logs(provider);
CREATE INDEX idx_notification_logs_sent_at ON notification_logs(sent_at);
+
+-- +goose Down
+DROP TABLE IF EXISTS notification_logs;
+DROP TABLE IF EXISTS notification_settings;
diff --git a/backend/resources/migrations/sqlite/022_unique_oidc_subject_index.down.sql b/backend/resources/migrations/sqlite/022_unique_oidc_subject_index.down.sql
deleted file mode 100644
index ae265e30a..000000000
--- a/backend/resources/migrations/sqlite/022_unique_oidc_subject_index.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP INDEX IF EXISTS idx_users_oidc_subject_id_unique;
\ No newline at end of file
diff --git a/backend/resources/migrations/sqlite/022_unique_oidc_subject_index.up.sql b/backend/resources/migrations/sqlite/022_unique_oidc_subject_index.sql
similarity index 63%
rename from backend/resources/migrations/sqlite/022_unique_oidc_subject_index.up.sql
rename to backend/resources/migrations/sqlite/022_unique_oidc_subject_index.sql
index cbac702d8..955d91c2d 100644
--- a/backend/resources/migrations/sqlite/022_unique_oidc_subject_index.up.sql
+++ b/backend/resources/migrations/sqlite/022_unique_oidc_subject_index.sql
@@ -1,4 +1,8 @@
+-- +goose Up
-- Ensure OIDC subject is unique across users while allowing NULL values (SQLite >= 3.8 supports partial indexes)
CREATE UNIQUE INDEX IF NOT EXISTS idx_users_oidc_subject_id_unique
ON users(oidc_subject_id)
-WHERE oidc_subject_id IS NOT NULL;
\ No newline at end of file
+WHERE oidc_subject_id IS NOT NULL;
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_users_oidc_subject_id_unique;
diff --git a/backend/resources/migrations/sqlite/023_add_apprise_settings.down.sql b/backend/resources/migrations/sqlite/023_add_apprise_settings.down.sql
deleted file mode 100644
index 954f2e5d2..000000000
--- a/backend/resources/migrations/sqlite/023_add_apprise_settings.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP TABLE IF EXISTS apprise_settings;
diff --git a/backend/resources/migrations/sqlite/023_add_apprise_settings.up.sql b/backend/resources/migrations/sqlite/023_add_apprise_settings.sql
similarity index 82%
rename from backend/resources/migrations/sqlite/023_add_apprise_settings.up.sql
rename to backend/resources/migrations/sqlite/023_add_apprise_settings.sql
index afabd152e..c70b20ca2 100644
--- a/backend/resources/migrations/sqlite/023_add_apprise_settings.up.sql
+++ b/backend/resources/migrations/sqlite/023_add_apprise_settings.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS apprise_settings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
api_url TEXT NOT NULL,
@@ -7,3 +8,6 @@ CREATE TABLE IF NOT EXISTS apprise_settings (
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);
+
+-- +goose Down
+DROP TABLE IF EXISTS apprise_settings;
diff --git a/backend/resources/migrations/sqlite/024_add_api_keys.down.sql b/backend/resources/migrations/sqlite/024_add_api_keys.down.sql
deleted file mode 100644
index 42af8e148..000000000
--- a/backend/resources/migrations/sqlite/024_add_api_keys.down.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-DROP INDEX IF EXISTS idx_api_keys_key_prefix;
-DROP INDEX IF EXISTS idx_api_keys_key_hash;
-DROP INDEX IF EXISTS idx_api_keys_user_id;
-DROP TABLE IF EXISTS api_keys;
diff --git a/backend/resources/migrations/sqlite/024_add_api_keys.up.sql b/backend/resources/migrations/sqlite/024_add_api_keys.sql
similarity index 76%
rename from backend/resources/migrations/sqlite/024_add_api_keys.up.sql
rename to backend/resources/migrations/sqlite/024_add_api_keys.sql
index db413040f..366d4b155 100644
--- a/backend/resources/migrations/sqlite/024_add_api_keys.up.sql
+++ b/backend/resources/migrations/sqlite/024_add_api_keys.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS api_keys (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
@@ -15,3 +16,9 @@ CREATE TABLE IF NOT EXISTS api_keys (
CREATE INDEX IF NOT EXISTS idx_api_keys_user_id ON api_keys(user_id);
CREATE INDEX IF NOT EXISTS idx_api_keys_key_hash ON api_keys(key_hash);
CREATE INDEX IF NOT EXISTS idx_api_keys_key_prefix ON api_keys(key_prefix);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_api_keys_key_prefix;
+DROP INDEX IF EXISTS idx_api_keys_key_hash;
+DROP INDEX IF EXISTS idx_api_keys_user_id;
+DROP TABLE IF EXISTS api_keys;
diff --git a/backend/resources/migrations/sqlite/025_add_environment_api_key_pairing.down.sql b/backend/resources/migrations/sqlite/025_add_environment_api_key_pairing.down.sql
deleted file mode 100644
index d81f3a533..000000000
--- a/backend/resources/migrations/sqlite/025_add_environment_api_key_pairing.down.sql
+++ /dev/null
@@ -1,5 +0,0 @@
--- Remove environment_id column from api_keys table
-ALTER TABLE api_keys DROP COLUMN environment_id;
-
--- Remove api_key_id column from environments table
-ALTER TABLE environments DROP COLUMN api_key_id;
diff --git a/backend/resources/migrations/sqlite/025_add_environment_api_key_pairing.up.sql b/backend/resources/migrations/sqlite/025_add_environment_api_key_pairing.sql
similarity index 60%
rename from backend/resources/migrations/sqlite/025_add_environment_api_key_pairing.up.sql
rename to backend/resources/migrations/sqlite/025_add_environment_api_key_pairing.sql
index f81fe771c..f77f826ff 100644
--- a/backend/resources/migrations/sqlite/025_add_environment_api_key_pairing.up.sql
+++ b/backend/resources/migrations/sqlite/025_add_environment_api_key_pairing.sql
@@ -1,5 +1,13 @@
+-- +goose Up
-- Add api_key_id column to environments table for API key-based pairing
ALTER TABLE environments ADD COLUMN api_key_id TEXT REFERENCES api_keys(id) ON DELETE SET NULL;
-- Add environment_id column to api_keys table to link API keys to environments
ALTER TABLE api_keys ADD COLUMN environment_id TEXT REFERENCES environments(id) ON DELETE CASCADE;
+
+-- +goose Down
+-- Remove environment_id column from api_keys table
+ALTER TABLE api_keys DROP COLUMN environment_id;
+
+-- Remove api_key_id column from environments table
+ALTER TABLE environments DROP COLUMN api_key_id;
diff --git a/backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.down.sql b/backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.sql
similarity index 75%
rename from backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.down.sql
rename to backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.sql
index aabf89385..a9868a22f 100644
--- a/backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.down.sql
+++ b/backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.sql
@@ -1,3 +1,9 @@
+-- +goose Up
+-- Add notification_sent column to track if updates have been sent
+-- Existing indexes on repository and tag are preserved automatically
+ALTER TABLE image_updates ADD COLUMN notification_sent INTEGER DEFAULT 0;
+
+-- +goose Down
-- SQLite doesn't support DROP COLUMN directly, so we need to recreate the table
-- Create backup without notification_sent column
CREATE TABLE image_updates_backup AS SELECT
diff --git a/backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.up.sql b/backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.up.sql
deleted file mode 100644
index 3c304e99e..000000000
--- a/backend/resources/migrations/sqlite/026_add_notification_sent_to_image_updates.up.sql
+++ /dev/null
@@ -1,3 +0,0 @@
--- Add notification_sent column to track if updates have been sent
--- Existing indexes on repository and tag are preserved automatically
-ALTER TABLE image_updates ADD COLUMN notification_sent INTEGER DEFAULT 0;
diff --git a/backend/resources/migrations/sqlite/027_add_missing_indexes.down.sql b/backend/resources/migrations/sqlite/027_add_missing_indexes.down.sql
deleted file mode 100644
index efef67c37..000000000
--- a/backend/resources/migrations/sqlite/027_add_missing_indexes.down.sql
+++ /dev/null
@@ -1,16 +0,0 @@
--- Remove all indexes added in migration 027
-DROP INDEX IF EXISTS idx_environments_enabled;
-DROP INDEX IF EXISTS idx_environments_status;
-DROP INDEX IF EXISTS idx_environments_last_seen;
-DROP INDEX IF EXISTS idx_container_registries_enabled;
-DROP INDEX IF EXISTS idx_projects_status;
-DROP INDEX IF EXISTS idx_projects_name;
-DROP INDEX IF EXISTS idx_users_username;
-DROP INDEX IF EXISTS idx_users_email;
-DROP INDEX IF EXISTS idx_users_oidc_subject_id;
-DROP INDEX IF EXISTS idx_image_updates_has_update;
-DROP INDEX IF EXISTS idx_image_updates_has_update_notification;
-DROP INDEX IF EXISTS idx_image_updates_check_time;
-DROP INDEX IF EXISTS idx_image_updates_notification_sent;
-DROP INDEX IF EXISTS idx_notification_settings_enabled;
-DROP INDEX IF EXISTS idx_apprise_settings_enabled;
diff --git a/backend/resources/migrations/sqlite/027_add_missing_indexes.up.sql b/backend/resources/migrations/sqlite/027_add_missing_indexes.sql
similarity index 60%
rename from backend/resources/migrations/sqlite/027_add_missing_indexes.up.sql
rename to backend/resources/migrations/sqlite/027_add_missing_indexes.sql
index 8f0975c54..102e253fb 100644
--- a/backend/resources/migrations/sqlite/027_add_missing_indexes.up.sql
+++ b/backend/resources/migrations/sqlite/027_add_missing_indexes.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE INDEX IF NOT EXISTS idx_environments_enabled ON environments(enabled);
CREATE INDEX IF NOT EXISTS idx_environments_status ON environments(status);
CREATE INDEX IF NOT EXISTS idx_environments_last_seen ON environments(last_seen);
@@ -13,3 +14,21 @@ CREATE INDEX IF NOT EXISTS idx_image_updates_check_time ON image_updates(check_t
CREATE INDEX IF NOT EXISTS idx_image_updates_notification_sent ON image_updates(notification_sent);
CREATE INDEX IF NOT EXISTS idx_notification_settings_enabled ON notification_settings(enabled);
CREATE INDEX IF NOT EXISTS idx_apprise_settings_enabled ON apprise_settings(enabled);
+
+-- +goose Down
+-- Remove all indexes added in migration 027
+DROP INDEX IF EXISTS idx_environments_enabled;
+DROP INDEX IF EXISTS idx_environments_status;
+DROP INDEX IF EXISTS idx_environments_last_seen;
+DROP INDEX IF EXISTS idx_container_registries_enabled;
+DROP INDEX IF EXISTS idx_projects_status;
+DROP INDEX IF EXISTS idx_projects_name;
+DROP INDEX IF EXISTS idx_users_username;
+DROP INDEX IF EXISTS idx_users_email;
+DROP INDEX IF EXISTS idx_users_oidc_subject_id;
+DROP INDEX IF EXISTS idx_image_updates_has_update;
+DROP INDEX IF EXISTS idx_image_updates_has_update_notification;
+DROP INDEX IF EXISTS idx_image_updates_check_time;
+DROP INDEX IF EXISTS idx_image_updates_notification_sent;
+DROP INDEX IF EXISTS idx_notification_settings_enabled;
+DROP INDEX IF EXISTS idx_apprise_settings_enabled;
diff --git a/backend/resources/migrations/sqlite/028_add_gitops.down.sql b/backend/resources/migrations/sqlite/028_add_gitops.down.sql
deleted file mode 100644
index 4776b27b2..000000000
--- a/backend/resources/migrations/sqlite/028_add_gitops.down.sql
+++ /dev/null
@@ -1,6 +0,0 @@
--- Remove gitops_managed_by column from projects table
--- Note: SQLite doesn't support DROP COLUMN directly, so we'll leave it
--- or need to recreate the table if this is critical
-
-DROP TABLE IF EXISTS gitops_syncs;
-DROP TABLE IF EXISTS git_repositories;
diff --git a/backend/resources/migrations/sqlite/028_add_gitops.up.sql b/backend/resources/migrations/sqlite/028_add_gitops.sql
similarity index 87%
rename from backend/resources/migrations/sqlite/028_add_gitops.up.sql
rename to backend/resources/migrations/sqlite/028_add_gitops.sql
index 63744f1c3..cd1c748ee 100644
--- a/backend/resources/migrations/sqlite/028_add_gitops.up.sql
+++ b/backend/resources/migrations/sqlite/028_add_gitops.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS git_repositories (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
@@ -48,3 +49,11 @@ CREATE INDEX IF NOT EXISTS idx_gitops_syncs_last_sync_commit ON gitops_syncs(las
-- Add gitops_managed_by column to projects table
ALTER TABLE projects ADD COLUMN gitops_managed_by TEXT;
CREATE INDEX IF NOT EXISTS idx_projects_gitops_managed_by ON projects(gitops_managed_by);
+
+-- +goose Down
+-- Remove gitops_managed_by column from projects table
+-- Note: SQLite doesn't support DROP COLUMN directly, so we'll leave it
+-- or need to recreate the table if this is critical
+
+DROP TABLE IF EXISTS gitops_syncs;
+DROP TABLE IF EXISTS git_repositories;
diff --git a/backend/resources/migrations/sqlite/029_add_ssh_host_key_verification.down.sql b/backend/resources/migrations/sqlite/029_add_ssh_host_key_verification.down.sql
deleted file mode 100644
index 7ae4b4a5c..000000000
--- a/backend/resources/migrations/sqlite/029_add_ssh_host_key_verification.down.sql
+++ /dev/null
@@ -1,3 +0,0 @@
--- SQLite doesn't support DROP COLUMN directly, but we can recreate the table
--- For simplicity, we'll just leave the column in place (it's harmless)
--- In production, you'd want to recreate the table without this column
diff --git a/backend/resources/migrations/sqlite/029_add_ssh_host_key_verification.up.sql b/backend/resources/migrations/sqlite/029_add_ssh_host_key_verification.sql
similarity index 53%
rename from backend/resources/migrations/sqlite/029_add_ssh_host_key_verification.up.sql
rename to backend/resources/migrations/sqlite/029_add_ssh_host_key_verification.sql
index b6b8597cc..6a0fa253b 100644
--- a/backend/resources/migrations/sqlite/029_add_ssh_host_key_verification.up.sql
+++ b/backend/resources/migrations/sqlite/029_add_ssh_host_key_verification.sql
@@ -1,3 +1,9 @@
+-- +goose Up
-- Add ssh_host_key_verification column to git_repositories table
-- Values: 'strict' (use known_hosts), 'accept_new' (default - auto-add unknown hosts), 'skip' (disable verification)
ALTER TABLE git_repositories ADD COLUMN ssh_host_key_verification TEXT NOT NULL DEFAULT 'accept_new';
+
+-- +goose Down
+-- SQLite doesn't support DROP COLUMN directly, but we can recreate the table
+-- For simplicity, we'll just leave the column in place (it's harmless)
+-- In production, you'd want to recreate the table without this column
diff --git a/backend/resources/migrations/sqlite/030_remove_gitops_sync_enabled.down.sql b/backend/resources/migrations/sqlite/030_remove_gitops_sync_enabled.sql
similarity index 50%
rename from backend/resources/migrations/sqlite/030_remove_gitops_sync_enabled.down.sql
rename to backend/resources/migrations/sqlite/030_remove_gitops_sync_enabled.sql
index a459844e3..4f0f4afb6 100644
--- a/backend/resources/migrations/sqlite/030_remove_gitops_sync_enabled.down.sql
+++ b/backend/resources/migrations/sqlite/030_remove_gitops_sync_enabled.sql
@@ -1,3 +1,55 @@
+-- +goose Up
+-- Remove the enabled column from gitops_syncs table
+-- SQLite doesn't support DROP COLUMN directly, so we need to recreate the table
+-- Only autoSync field will control automatic syncing behavior
+
+-- Create new table without enabled column
+CREATE TABLE gitops_syncs_new (
+ id TEXT PRIMARY KEY,
+ name TEXT NOT NULL,
+ environment_id TEXT NOT NULL,
+ repository_id TEXT NOT NULL,
+ branch TEXT NOT NULL,
+ compose_path TEXT NOT NULL,
+ project_name TEXT NOT NULL,
+ project_id TEXT,
+ auto_sync BOOLEAN NOT NULL DEFAULT false,
+ sync_interval INTEGER NOT NULL DEFAULT 60,
+ last_sync_at DATETIME,
+ last_sync_status TEXT,
+ last_sync_error TEXT,
+ last_sync_commit TEXT,
+ created_at DATETIME NOT NULL,
+ updated_at DATETIME NOT NULL,
+ FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE CASCADE,
+ FOREIGN KEY (repository_id) REFERENCES git_repositories(id) ON DELETE CASCADE,
+ FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE SET NULL
+);
+
+-- Copy data from old table to new table
+INSERT INTO gitops_syncs_new (
+ id, name, environment_id, repository_id, branch, compose_path,
+ project_name, project_id, auto_sync, sync_interval, last_sync_at,
+ last_sync_status, last_sync_error, last_sync_commit, created_at, updated_at
+)
+SELECT
+ id, name, environment_id, repository_id, branch, compose_path,
+ project_name, project_id, auto_sync, sync_interval, last_sync_at,
+ last_sync_status, last_sync_error, last_sync_commit, created_at, updated_at
+FROM gitops_syncs;
+
+-- Drop old table
+DROP TABLE gitops_syncs;
+
+-- Rename new table to original name
+ALTER TABLE gitops_syncs_new RENAME TO gitops_syncs;
+
+-- Recreate indexes
+CREATE INDEX IF NOT EXISTS idx_gitops_syncs_environment_id ON gitops_syncs(environment_id);
+CREATE INDEX IF NOT EXISTS idx_gitops_syncs_repository_id ON gitops_syncs(repository_id);
+CREATE INDEX IF NOT EXISTS idx_gitops_syncs_project_id ON gitops_syncs(project_id);
+
+-- +goose Down
-- Re-add the enabled column to gitops_syncs table
-- SQLite doesn't support ADD COLUMN with constraints directly, so we need to recreate the table
diff --git a/backend/resources/migrations/sqlite/030_remove_gitops_sync_enabled.up.sql b/backend/resources/migrations/sqlite/030_remove_gitops_sync_enabled.up.sql
deleted file mode 100644
index b2a1f4acf..000000000
--- a/backend/resources/migrations/sqlite/030_remove_gitops_sync_enabled.up.sql
+++ /dev/null
@@ -1,49 +0,0 @@
--- Remove the enabled column from gitops_syncs table
--- SQLite doesn't support DROP COLUMN directly, so we need to recreate the table
--- Only autoSync field will control automatic syncing behavior
-
--- Create new table without enabled column
-CREATE TABLE gitops_syncs_new (
- id TEXT PRIMARY KEY,
- name TEXT NOT NULL,
- environment_id TEXT NOT NULL,
- repository_id TEXT NOT NULL,
- branch TEXT NOT NULL,
- compose_path TEXT NOT NULL,
- project_name TEXT NOT NULL,
- project_id TEXT,
- auto_sync BOOLEAN NOT NULL DEFAULT false,
- sync_interval INTEGER NOT NULL DEFAULT 60,
- last_sync_at DATETIME,
- last_sync_status TEXT,
- last_sync_error TEXT,
- last_sync_commit TEXT,
- created_at DATETIME NOT NULL,
- updated_at DATETIME NOT NULL,
- FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE CASCADE,
- FOREIGN KEY (repository_id) REFERENCES git_repositories(id) ON DELETE CASCADE,
- FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE SET NULL
-);
-
--- Copy data from old table to new table
-INSERT INTO gitops_syncs_new (
- id, name, environment_id, repository_id, branch, compose_path,
- project_name, project_id, auto_sync, sync_interval, last_sync_at,
- last_sync_status, last_sync_error, last_sync_commit, created_at, updated_at
-)
-SELECT
- id, name, environment_id, repository_id, branch, compose_path,
- project_name, project_id, auto_sync, sync_interval, last_sync_at,
- last_sync_status, last_sync_error, last_sync_commit, created_at, updated_at
-FROM gitops_syncs;
-
--- Drop old table
-DROP TABLE gitops_syncs;
-
--- Rename new table to original name
-ALTER TABLE gitops_syncs_new RENAME TO gitops_syncs;
-
--- Recreate indexes
-CREATE INDEX IF NOT EXISTS idx_gitops_syncs_environment_id ON gitops_syncs(environment_id);
-CREATE INDEX IF NOT EXISTS idx_gitops_syncs_repository_id ON gitops_syncs(repository_id);
-CREATE INDEX IF NOT EXISTS idx_gitops_syncs_project_id ON gitops_syncs(project_id);
diff --git a/backend/resources/migrations/sqlite/031_add_environment_is_edge.down.sql b/backend/resources/migrations/sqlite/031_add_environment_is_edge.down.sql
deleted file mode 100644
index 87ac3a0c7..000000000
--- a/backend/resources/migrations/sqlite/031_add_environment_is_edge.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- remove is_edge column from environments table
-ALTER TABLE environments DROP COLUMN is_edge;
diff --git a/backend/resources/migrations/sqlite/031_add_environment_is_edge.up.sql b/backend/resources/migrations/sqlite/031_add_environment_is_edge.sql
similarity index 52%
rename from backend/resources/migrations/sqlite/031_add_environment_is_edge.up.sql
rename to backend/resources/migrations/sqlite/031_add_environment_is_edge.sql
index dd8fed309..d56bbded8 100644
--- a/backend/resources/migrations/sqlite/031_add_environment_is_edge.up.sql
+++ b/backend/resources/migrations/sqlite/031_add_environment_is_edge.sql
@@ -1,2 +1,7 @@
+-- +goose Up
-- add is_edge column to environments table for edge agent mode
ALTER TABLE environments ADD COLUMN is_edge INTEGER NOT NULL DEFAULT 0;
+
+-- +goose Down
+-- remove is_edge column from environments table
+ALTER TABLE environments DROP COLUMN is_edge;
diff --git a/backend/resources/migrations/sqlite/032_add_volume_backups.down.sql b/backend/resources/migrations/sqlite/032_add_volume_backups.down.sql
deleted file mode 100644
index dc16e31ec..000000000
--- a/backend/resources/migrations/sqlite/032_add_volume_backups.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP TABLE volume_backups;
diff --git a/backend/resources/migrations/sqlite/032_add_volume_backups.up.sql b/backend/resources/migrations/sqlite/032_add_volume_backups.sql
similarity index 81%
rename from backend/resources/migrations/sqlite/032_add_volume_backups.up.sql
rename to backend/resources/migrations/sqlite/032_add_volume_backups.sql
index 9645bf005..ef8df6cde 100644
--- a/backend/resources/migrations/sqlite/032_add_volume_backups.up.sql
+++ b/backend/resources/migrations/sqlite/032_add_volume_backups.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE volume_backups (
id TEXT PRIMARY KEY,
volume_name TEXT NOT NULL,
@@ -6,3 +7,6 @@ CREATE TABLE volume_backups (
updated_at TIMESTAMP
);
CREATE INDEX idx_volume_backups_volume_name ON volume_backups(volume_name);
+
+-- +goose Down
+DROP TABLE volume_backups;
diff --git a/backend/resources/migrations/sqlite/033_add_vulnerability_scans.down.sql b/backend/resources/migrations/sqlite/033_add_vulnerability_scans.down.sql
deleted file mode 100644
index a943e6999..000000000
--- a/backend/resources/migrations/sqlite/033_add_vulnerability_scans.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- Remove vulnerability_scans table
-DROP TABLE IF EXISTS vulnerability_scans;
diff --git a/backend/resources/migrations/sqlite/033_add_vulnerability_scans.up.sql b/backend/resources/migrations/sqlite/033_add_vulnerability_scans.sql
similarity index 89%
rename from backend/resources/migrations/sqlite/033_add_vulnerability_scans.up.sql
rename to backend/resources/migrations/sqlite/033_add_vulnerability_scans.sql
index 0aa9a0489..d19d8592b 100644
--- a/backend/resources/migrations/sqlite/033_add_vulnerability_scans.up.sql
+++ b/backend/resources/migrations/sqlite/033_add_vulnerability_scans.sql
@@ -1,3 +1,4 @@
+-- +goose Up
-- Add vulnerability_scans table for storing vulnerability scan results
CREATE TABLE IF NOT EXISTS vulnerability_scans (
id TEXT PRIMARY KEY,
@@ -21,3 +22,7 @@ CREATE TABLE IF NOT EXISTS vulnerability_scans (
-- Create indexes for efficient querying
CREATE INDEX IF NOT EXISTS idx_vulnerability_scans_status ON vulnerability_scans(status);
CREATE INDEX IF NOT EXISTS idx_vulnerability_scans_scan_time ON vulnerability_scans(scan_time);
+
+-- +goose Down
+-- Remove vulnerability_scans table
+DROP TABLE IF EXISTS vulnerability_scans;
diff --git a/backend/resources/migrations/sqlite/034_add_vulnerability_ignores.down.sql b/backend/resources/migrations/sqlite/034_add_vulnerability_ignores.down.sql
deleted file mode 100644
index bf0cb0176..000000000
--- a/backend/resources/migrations/sqlite/034_add_vulnerability_ignores.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- Drop vulnerability_ignores table
-DROP TABLE IF EXISTS vulnerability_ignores;
diff --git a/backend/resources/migrations/sqlite/034_add_vulnerability_ignores.up.sql b/backend/resources/migrations/sqlite/034_add_vulnerability_ignores.sql
similarity index 89%
rename from backend/resources/migrations/sqlite/034_add_vulnerability_ignores.up.sql
rename to backend/resources/migrations/sqlite/034_add_vulnerability_ignores.sql
index 08aac3e06..3e9fa8e5a 100644
--- a/backend/resources/migrations/sqlite/034_add_vulnerability_ignores.up.sql
+++ b/backend/resources/migrations/sqlite/034_add_vulnerability_ignores.sql
@@ -1,3 +1,4 @@
+-- +goose Up
-- Add vulnerability_ignores table for storing ignored vulnerability records
CREATE TABLE IF NOT EXISTS vulnerability_ignores (
id TEXT PRIMARY KEY,
@@ -16,3 +17,7 @@ CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_env ON vulnerability_ignore
CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_image ON vulnerability_ignores(image_id);
CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_vuln ON vulnerability_ignores(vulnerability_id);
CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_composite ON vulnerability_ignores(environment_id, image_id, vulnerability_id, pkg_name, installed_version);
+
+-- +goose Down
+-- Drop vulnerability_ignores table
+DROP TABLE IF EXISTS vulnerability_ignores;
diff --git a/backend/resources/migrations/sqlite/035_backfill_missing_settings.down.sql b/backend/resources/migrations/sqlite/035_backfill_missing_settings.down.sql
deleted file mode 100644
index f46fde449..000000000
--- a/backend/resources/migrations/sqlite/035_backfill_missing_settings.down.sql
+++ /dev/null
@@ -1 +0,0 @@
--- No-op: data backfill migration cannot be safely reversed.
diff --git a/backend/resources/migrations/sqlite/035_backfill_missing_settings.up.sql b/backend/resources/migrations/sqlite/035_backfill_missing_settings.sql
similarity index 89%
rename from backend/resources/migrations/sqlite/035_backfill_missing_settings.up.sql
rename to backend/resources/migrations/sqlite/035_backfill_missing_settings.sql
index abb32653f..5aea94eed 100644
--- a/backend/resources/migrations/sqlite/035_backfill_missing_settings.up.sql
+++ b/backend/resources/migrations/sqlite/035_backfill_missing_settings.sql
@@ -1,3 +1,4 @@
+-- +goose Up
-- Backfill missing vulnerability scan settings defaults
INSERT OR IGNORE INTO settings (key, value) VALUES ('vulnerabilityScanEnabled', 'false');
UPDATE settings
@@ -17,3 +18,6 @@ UPDATE settings
SET value = ''
WHERE key = 'autoUpdateExcludedContainers'
AND value IS NULL;
+
+-- +goose Down
+-- No-op: data backfill migration cannot be safely reversed.
diff --git a/backend/resources/migrations/sqlite/036_notification_log_image_ref_text.down.sql b/backend/resources/migrations/sqlite/036_notification_log_image_ref_text.down.sql
deleted file mode 100644
index 2a3d4cf32..000000000
--- a/backend/resources/migrations/sqlite/036_notification_log_image_ref_text.down.sql
+++ /dev/null
@@ -1 +0,0 @@
--- No-op: SQLite doesn't enforce VARCHAR length constraints
diff --git a/backend/resources/migrations/sqlite/036_notification_log_image_ref_text.up.sql b/backend/resources/migrations/sqlite/036_notification_log_image_ref_text.sql
similarity index 70%
rename from backend/resources/migrations/sqlite/036_notification_log_image_ref_text.up.sql
rename to backend/resources/migrations/sqlite/036_notification_log_image_ref_text.sql
index bc12684af..ee86fbc76 100644
--- a/backend/resources/migrations/sqlite/036_notification_log_image_ref_text.up.sql
+++ b/backend/resources/migrations/sqlite/036_notification_log_image_ref_text.sql
@@ -1,3 +1,7 @@
+-- +goose Up
-- SQLite doesn't enforce VARCHAR length, but we recreate the table for consistency
-- SQLite treats VARCHAR(255) and TEXT the same, so this is a no-op for existing data
-- but documents the intended schema change
+
+-- +goose Down
+-- No-op: SQLite doesn't enforce VARCHAR length constraints
diff --git a/backend/resources/migrations/sqlite/037_add_image_builds.down.sql b/backend/resources/migrations/sqlite/037_add_image_builds.down.sql
deleted file mode 100644
index 3327a4894..000000000
--- a/backend/resources/migrations/sqlite/037_add_image_builds.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
--- Drop image_builds table
-DROP TABLE IF EXISTS image_builds;
diff --git a/backend/resources/migrations/sqlite/037_add_image_builds.up.sql b/backend/resources/migrations/sqlite/037_add_image_builds.sql
similarity index 93%
rename from backend/resources/migrations/sqlite/037_add_image_builds.up.sql
rename to backend/resources/migrations/sqlite/037_add_image_builds.sql
index 05559a7cb..3b210ef62 100644
--- a/backend/resources/migrations/sqlite/037_add_image_builds.up.sql
+++ b/backend/resources/migrations/sqlite/037_add_image_builds.sql
@@ -1,3 +1,4 @@
+-- +goose Up
-- Add image_builds table for storing build history
CREATE TABLE IF NOT EXISTS image_builds (
id TEXT PRIMARY KEY,
@@ -40,3 +41,7 @@ CREATE TABLE IF NOT EXISTS image_builds (
CREATE INDEX IF NOT EXISTS idx_image_builds_env ON image_builds(environment_id);
CREATE INDEX IF NOT EXISTS idx_image_builds_status ON image_builds(status);
CREATE INDEX IF NOT EXISTS idx_image_builds_created_at ON image_builds(created_at);
+
+-- +goose Down
+-- Drop image_builds table
+DROP TABLE IF EXISTS image_builds;
diff --git a/backend/resources/migrations/sqlite/038_create_kv_table.down.sql b/backend/resources/migrations/sqlite/038_create_kv_table.down.sql
deleted file mode 100644
index d4b20a7bd..000000000
--- a/backend/resources/migrations/sqlite/038_create_kv_table.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP TABLE IF EXISTS kv;
diff --git a/backend/resources/migrations/sqlite/038_create_kv_table.up.sql b/backend/resources/migrations/sqlite/038_create_kv_table.sql
similarity index 76%
rename from backend/resources/migrations/sqlite/038_create_kv_table.up.sql
rename to backend/resources/migrations/sqlite/038_create_kv_table.sql
index a9539dada..3b42692be 100644
--- a/backend/resources/migrations/sqlite/038_create_kv_table.up.sql
+++ b/backend/resources/migrations/sqlite/038_create_kv_table.sql
@@ -1,6 +1,10 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS kv (
key TEXT NOT NULL PRIMARY KEY,
value TEXT NOT NULL,
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME
);
+
+-- +goose Down
+DROP TABLE IF EXISTS kv;
diff --git a/backend/resources/migrations/sqlite/039_add_ecr_registry_support.down.sql b/backend/resources/migrations/sqlite/039_add_ecr_registry_support.down.sql
deleted file mode 100644
index 01840f457..000000000
--- a/backend/resources/migrations/sqlite/039_add_ecr_registry_support.down.sql
+++ /dev/null
@@ -1,24 +0,0 @@
--- Use create-copy-drop-rename to remove ECR columns in SQLite
--- (SQLite lacks DROP COLUMN IF EXISTS).
-DROP TABLE IF EXISTS container_registries_old;
-
-CREATE TABLE container_registries_old (
- id TEXT PRIMARY KEY,
- url TEXT NOT NULL,
- username TEXT NOT NULL,
- token TEXT NOT NULL,
- description TEXT,
- insecure BOOLEAN NOT NULL DEFAULT false,
- enabled BOOLEAN NOT NULL DEFAULT true,
- created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- updated_at DATETIME
-);
-
-INSERT INTO container_registries_old (id, url, username, token, description, insecure, enabled, created_at, updated_at)
-SELECT id, url, username, token, description, insecure, enabled, created_at, updated_at
-FROM container_registries;
-
-DROP TABLE container_registries;
-ALTER TABLE container_registries_old RENAME TO container_registries;
-
-CREATE INDEX IF NOT EXISTS idx_container_registries_enabled ON container_registries(enabled);
diff --git a/backend/resources/migrations/sqlite/039_add_ecr_registry_support.up.sql b/backend/resources/migrations/sqlite/039_add_ecr_registry_support.sql
similarity index 54%
rename from backend/resources/migrations/sqlite/039_add_ecr_registry_support.up.sql
rename to backend/resources/migrations/sqlite/039_add_ecr_registry_support.sql
index 405e2dc0a..b0c874b21 100644
--- a/backend/resources/migrations/sqlite/039_add_ecr_registry_support.up.sql
+++ b/backend/resources/migrations/sqlite/039_add_ecr_registry_support.sql
@@ -1,3 +1,4 @@
+-- +goose Up
-- Use create-copy-drop-rename for idempotent column additions in SQLite
-- (SQLite lacks ADD COLUMN IF NOT EXISTS).
DROP TABLE IF EXISTS container_registries_new;
@@ -28,3 +29,29 @@ DROP TABLE container_registries;
ALTER TABLE container_registries_new RENAME TO container_registries;
CREATE INDEX IF NOT EXISTS idx_container_registries_enabled ON container_registries(enabled);
+
+-- +goose Down
+-- Use create-copy-drop-rename to remove ECR columns in SQLite
+-- (SQLite lacks DROP COLUMN IF EXISTS).
+DROP TABLE IF EXISTS container_registries_old;
+
+CREATE TABLE container_registries_old (
+ id TEXT PRIMARY KEY,
+ url TEXT NOT NULL,
+ username TEXT NOT NULL,
+ token TEXT NOT NULL,
+ description TEXT,
+ insecure BOOLEAN NOT NULL DEFAULT false,
+ enabled BOOLEAN NOT NULL DEFAULT true,
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_at DATETIME
+);
+
+INSERT INTO container_registries_old (id, url, username, token, description, insecure, enabled, created_at, updated_at)
+SELECT id, url, username, token, description, insecure, enabled, created_at, updated_at
+FROM container_registries;
+
+DROP TABLE container_registries;
+ALTER TABLE container_registries_old RENAME TO container_registries;
+
+CREATE INDEX IF NOT EXISTS idx_container_registries_enabled ON container_registries(enabled);
diff --git a/backend/resources/migrations/sqlite/040_add_api_key_managed_by.down.sql b/backend/resources/migrations/sqlite/040_add_api_key_managed_by.down.sql
deleted file mode 100644
index 9f52fd0a7..000000000
--- a/backend/resources/migrations/sqlite/040_add_api_key_managed_by.down.sql
+++ /dev/null
@@ -1,51 +0,0 @@
-DROP TABLE IF EXISTS api_keys_old;
-
-CREATE TABLE api_keys_old (
- id TEXT PRIMARY KEY,
- name TEXT NOT NULL,
- description TEXT,
- key_hash TEXT NOT NULL,
- key_prefix TEXT NOT NULL,
- user_id TEXT NOT NULL,
- environment_id TEXT,
- expires_at DATETIME,
- last_used_at DATETIME,
- created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- updated_at DATETIME,
- FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
- FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE CASCADE
-);
-
-INSERT INTO api_keys_old (
- id,
- name,
- description,
- key_hash,
- key_prefix,
- user_id,
- environment_id,
- expires_at,
- last_used_at,
- created_at,
- updated_at
-)
-SELECT
- id,
- name,
- description,
- key_hash,
- key_prefix,
- user_id,
- environment_id,
- expires_at,
- last_used_at,
- created_at,
- updated_at
-FROM api_keys;
-
-DROP TABLE api_keys;
-ALTER TABLE api_keys_old RENAME TO api_keys;
-
-CREATE INDEX IF NOT EXISTS idx_api_keys_user_id ON api_keys(user_id);
-CREATE INDEX IF NOT EXISTS idx_api_keys_key_hash ON api_keys(key_hash);
-CREATE INDEX IF NOT EXISTS idx_api_keys_key_prefix ON api_keys(key_prefix);
diff --git a/backend/resources/migrations/sqlite/040_add_api_key_managed_by.up.sql b/backend/resources/migrations/sqlite/040_add_api_key_managed_by.sql
similarity index 52%
rename from backend/resources/migrations/sqlite/040_add_api_key_managed_by.up.sql
rename to backend/resources/migrations/sqlite/040_add_api_key_managed_by.sql
index c2d4dca3e..af54248b8 100644
--- a/backend/resources/migrations/sqlite/040_add_api_key_managed_by.up.sql
+++ b/backend/resources/migrations/sqlite/040_add_api_key_managed_by.sql
@@ -1,3 +1,4 @@
+-- +goose Up
-- Use create-copy-drop-rename for idempotent column additions in SQLite
-- (SQLite lacks ADD COLUMN IF NOT EXISTS).
DROP TABLE IF EXISTS api_keys_new;
@@ -52,3 +53,56 @@ ALTER TABLE api_keys_new RENAME TO api_keys;
CREATE INDEX IF NOT EXISTS idx_api_keys_user_id ON api_keys(user_id);
CREATE INDEX IF NOT EXISTS idx_api_keys_key_hash ON api_keys(key_hash);
CREATE INDEX IF NOT EXISTS idx_api_keys_key_prefix ON api_keys(key_prefix);
+
+-- +goose Down
+DROP TABLE IF EXISTS api_keys_old;
+
+CREATE TABLE api_keys_old (
+ id TEXT PRIMARY KEY,
+ name TEXT NOT NULL,
+ description TEXT,
+ key_hash TEXT NOT NULL,
+ key_prefix TEXT NOT NULL,
+ user_id TEXT NOT NULL,
+ environment_id TEXT,
+ expires_at DATETIME,
+ last_used_at DATETIME,
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_at DATETIME,
+ FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
+ FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE CASCADE
+);
+
+INSERT INTO api_keys_old (
+ id,
+ name,
+ description,
+ key_hash,
+ key_prefix,
+ user_id,
+ environment_id,
+ expires_at,
+ last_used_at,
+ created_at,
+ updated_at
+)
+SELECT
+ id,
+ name,
+ description,
+ key_hash,
+ key_prefix,
+ user_id,
+ environment_id,
+ expires_at,
+ last_used_at,
+ created_at,
+ updated_at
+FROM api_keys;
+
+DROP TABLE api_keys;
+ALTER TABLE api_keys_old RENAME TO api_keys;
+
+CREATE INDEX IF NOT EXISTS idx_api_keys_user_id ON api_keys(user_id);
+CREATE INDEX IF NOT EXISTS idx_api_keys_key_hash ON api_keys(key_hash);
+CREATE INDEX IF NOT EXISTS idx_api_keys_key_prefix ON api_keys(key_prefix);
diff --git a/backend/resources/migrations/sqlite/041_add_query_performance_indexes.down.sql b/backend/resources/migrations/sqlite/041_add_query_performance_indexes.down.sql
deleted file mode 100644
index 6573189cc..000000000
--- a/backend/resources/migrations/sqlite/041_add_query_performance_indexes.down.sql
+++ /dev/null
@@ -1,32 +0,0 @@
-CREATE INDEX IF NOT EXISTS idx_api_keys_user_id ON api_keys(user_id);
-CREATE INDEX IF NOT EXISTS idx_events_environment_id ON events(environment_id);
-CREATE INDEX IF NOT EXISTS idx_image_update_repository ON image_updates(repository);
-CREATE INDEX IF NOT EXISTS idx_image_update_tag ON image_updates(tag);
-CREATE INDEX IF NOT EXISTS idx_volume_backups_volume_name ON volume_backups(volume_name);
-CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_env ON vulnerability_ignores(environment_id);
-CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_vuln ON vulnerability_ignores(vulnerability_id);
-CREATE INDEX IF NOT EXISTS idx_vulnerability_scans_status ON vulnerability_scans(status);
-
-DROP INDEX IF EXISTS idx_vulnerability_ignores_env_vulnerability_id;
-DROP INDEX IF EXISTS idx_events_environment_timestamp;
-DROP INDEX IF EXISTS idx_image_updates_repository_tag;
-DROP INDEX IF EXISTS idx_image_builds_environment_status;
-DROP INDEX IF EXISTS idx_image_builds_environment_created_at;
-DROP INDEX IF EXISTS idx_volume_backups_volume_name_created_at;
-DROP INDEX IF EXISTS idx_compose_templates_lookup_description;
-DROP INDEX IF EXISTS idx_compose_templates_lookup_name;
-DROP INDEX IF EXISTS idx_projects_dir_name_not_null;
-DROP INDEX IF EXISTS idx_projects_path;
-DROP INDEX IF EXISTS idx_gitops_syncs_environment_project_id;
-DROP INDEX IF EXISTS idx_gitops_syncs_environment_repository_id;
-DROP INDEX IF EXISTS idx_gitops_syncs_environment_last_sync_status;
-DROP INDEX IF EXISTS idx_gitops_syncs_auto_sync_true;
-DROP INDEX IF EXISTS idx_gitops_syncs_environment_auto_sync;
-DROP INDEX IF EXISTS idx_git_repositories_auth_type;
-DROP INDEX IF EXISTS idx_git_repositories_enabled_url;
-DROP INDEX IF EXISTS idx_vulnerability_ignores_env_created_at;
-DROP INDEX IF EXISTS idx_vulnerability_scans_status_total_count;
-DROP INDEX IF EXISTS idx_api_keys_user_managed_by_created_at;
-DROP INDEX IF EXISTS idx_api_keys_expires_at_not_null;
-DROP INDEX IF EXISTS idx_environments_enabled_true;
-DROP INDEX IF EXISTS idx_environments_access_token_not_null;
diff --git a/backend/resources/migrations/sqlite/041_add_query_performance_indexes.up.sql b/backend/resources/migrations/sqlite/041_add_query_performance_indexes.sql
similarity index 59%
rename from backend/resources/migrations/sqlite/041_add_query_performance_indexes.up.sql
rename to backend/resources/migrations/sqlite/041_add_query_performance_indexes.sql
index 55d9059dd..af414e766 100644
--- a/backend/resources/migrations/sqlite/041_add_query_performance_indexes.up.sql
+++ b/backend/resources/migrations/sqlite/041_add_query_performance_indexes.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE INDEX IF NOT EXISTS idx_environments_access_token_not_null
ON environments(access_token)
WHERE access_token IS NOT NULL;
@@ -80,3 +81,37 @@ DROP INDEX IF EXISTS idx_volume_backups_volume_name;
DROP INDEX IF EXISTS idx_vulnerability_ignores_env;
DROP INDEX IF EXISTS idx_vulnerability_ignores_vuln;
DROP INDEX IF EXISTS idx_vulnerability_scans_status;
+
+-- +goose Down
+CREATE INDEX IF NOT EXISTS idx_api_keys_user_id ON api_keys(user_id);
+CREATE INDEX IF NOT EXISTS idx_events_environment_id ON events(environment_id);
+CREATE INDEX IF NOT EXISTS idx_image_update_repository ON image_updates(repository);
+CREATE INDEX IF NOT EXISTS idx_image_update_tag ON image_updates(tag);
+CREATE INDEX IF NOT EXISTS idx_volume_backups_volume_name ON volume_backups(volume_name);
+CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_env ON vulnerability_ignores(environment_id);
+CREATE INDEX IF NOT EXISTS idx_vulnerability_ignores_vuln ON vulnerability_ignores(vulnerability_id);
+CREATE INDEX IF NOT EXISTS idx_vulnerability_scans_status ON vulnerability_scans(status);
+
+DROP INDEX IF EXISTS idx_vulnerability_ignores_env_vulnerability_id;
+DROP INDEX IF EXISTS idx_events_environment_timestamp;
+DROP INDEX IF EXISTS idx_image_updates_repository_tag;
+DROP INDEX IF EXISTS idx_image_builds_environment_status;
+DROP INDEX IF EXISTS idx_image_builds_environment_created_at;
+DROP INDEX IF EXISTS idx_volume_backups_volume_name_created_at;
+DROP INDEX IF EXISTS idx_compose_templates_lookup_description;
+DROP INDEX IF EXISTS idx_compose_templates_lookup_name;
+DROP INDEX IF EXISTS idx_projects_dir_name_not_null;
+DROP INDEX IF EXISTS idx_projects_path;
+DROP INDEX IF EXISTS idx_gitops_syncs_environment_project_id;
+DROP INDEX IF EXISTS idx_gitops_syncs_environment_repository_id;
+DROP INDEX IF EXISTS idx_gitops_syncs_environment_last_sync_status;
+DROP INDEX IF EXISTS idx_gitops_syncs_auto_sync_true;
+DROP INDEX IF EXISTS idx_gitops_syncs_environment_auto_sync;
+DROP INDEX IF EXISTS idx_git_repositories_auth_type;
+DROP INDEX IF EXISTS idx_git_repositories_enabled_url;
+DROP INDEX IF EXISTS idx_vulnerability_ignores_env_created_at;
+DROP INDEX IF EXISTS idx_vulnerability_scans_status_total_count;
+DROP INDEX IF EXISTS idx_api_keys_user_managed_by_created_at;
+DROP INDEX IF EXISTS idx_api_keys_expires_at_not_null;
+DROP INDEX IF EXISTS idx_environments_enabled_true;
+DROP INDEX IF EXISTS idx_environments_access_token_not_null;
diff --git a/backend/resources/migrations/sqlite/042_add_directory_sync.down.sql b/backend/resources/migrations/sqlite/042_add_directory_sync.sql
similarity index 64%
rename from backend/resources/migrations/sqlite/042_add_directory_sync.down.sql
rename to backend/resources/migrations/sqlite/042_add_directory_sync.sql
index 5e12cefdf..45e0d1a0d 100644
--- a/backend/resources/migrations/sqlite/042_add_directory_sync.down.sql
+++ b/backend/resources/migrations/sqlite/042_add_directory_sync.sql
@@ -1,3 +1,20 @@
+-- +goose Up
+-- Add directory sync support to gitops_syncs table
+-- sync_directory: when true, syncs entire directory containing compose file (default: true)
+-- synced_files: JSON array of file paths that were synced (for cleanup on updates)
+-- max_sync_files: maximum number of files to sync (0 = unlimited)
+-- max_sync_total_size: maximum total size in bytes (0 = unlimited)
+-- max_sync_binary_size: maximum binary file size in bytes (0 = unlimited)
+
+ALTER TABLE gitops_syncs ADD COLUMN sync_directory INTEGER NOT NULL DEFAULT 1;
+ALTER TABLE gitops_syncs ADD COLUMN synced_files TEXT;
+ALTER TABLE gitops_syncs ADD COLUMN max_sync_files INTEGER NOT NULL DEFAULT 500;
+ALTER TABLE gitops_syncs ADD COLUMN max_sync_total_size INTEGER NOT NULL DEFAULT 52428800;
+ALTER TABLE gitops_syncs ADD COLUMN max_sync_binary_size INTEGER NOT NULL DEFAULT 10485760;
+
+CREATE INDEX IF NOT EXISTS idx_gitops_syncs_sync_directory ON gitops_syncs(sync_directory);
+
+-- +goose Down
-- Remove directory sync columns from gitops_syncs table
-- SQLite doesn't support DROP COLUMN in older versions, so we recreate the table
diff --git a/backend/resources/migrations/sqlite/042_add_directory_sync.up.sql b/backend/resources/migrations/sqlite/042_add_directory_sync.up.sql
deleted file mode 100644
index dac5166aa..000000000
--- a/backend/resources/migrations/sqlite/042_add_directory_sync.up.sql
+++ /dev/null
@@ -1,14 +0,0 @@
--- Add directory sync support to gitops_syncs table
--- sync_directory: when true, syncs entire directory containing compose file (default: true)
--- synced_files: JSON array of file paths that were synced (for cleanup on updates)
--- max_sync_files: maximum number of files to sync (0 = unlimited)
--- max_sync_total_size: maximum total size in bytes (0 = unlimited)
--- max_sync_binary_size: maximum binary file size in bytes (0 = unlimited)
-
-ALTER TABLE gitops_syncs ADD COLUMN sync_directory INTEGER NOT NULL DEFAULT 1;
-ALTER TABLE gitops_syncs ADD COLUMN synced_files TEXT;
-ALTER TABLE gitops_syncs ADD COLUMN max_sync_files INTEGER NOT NULL DEFAULT 500;
-ALTER TABLE gitops_syncs ADD COLUMN max_sync_total_size INTEGER NOT NULL DEFAULT 52428800;
-ALTER TABLE gitops_syncs ADD COLUMN max_sync_binary_size INTEGER NOT NULL DEFAULT 10485760;
-
-CREATE INDEX IF NOT EXISTS idx_gitops_syncs_sync_directory ON gitops_syncs(sync_directory);
diff --git a/backend/resources/migrations/sqlite/043_add_hidden_swarm_node_agents.down.sql b/backend/resources/migrations/sqlite/043_add_hidden_swarm_node_agents.down.sql
deleted file mode 100644
index 2c64f302b..000000000
--- a/backend/resources/migrations/sqlite/043_add_hidden_swarm_node_agents.down.sql
+++ /dev/null
@@ -1,8 +0,0 @@
-DROP INDEX IF EXISTS idx_environments_parent_swarm_node;
-DROP INDEX IF EXISTS idx_environments_swarm_node_id;
-DROP INDEX IF EXISTS idx_environments_parent_environment_id;
-DROP INDEX IF EXISTS idx_environments_hidden;
-
-ALTER TABLE environments DROP COLUMN swarm_node_id;
-ALTER TABLE environments DROP COLUMN parent_environment_id;
-ALTER TABLE environments DROP COLUMN hidden;
diff --git a/backend/resources/migrations/sqlite/043_add_hidden_swarm_node_agents.up.sql b/backend/resources/migrations/sqlite/043_add_hidden_swarm_node_agents.sql
similarity index 58%
rename from backend/resources/migrations/sqlite/043_add_hidden_swarm_node_agents.up.sql
rename to backend/resources/migrations/sqlite/043_add_hidden_swarm_node_agents.sql
index 1669437d6..8bd9233e3 100644
--- a/backend/resources/migrations/sqlite/043_add_hidden_swarm_node_agents.up.sql
+++ b/backend/resources/migrations/sqlite/043_add_hidden_swarm_node_agents.sql
@@ -1,3 +1,4 @@
+-- +goose Up
ALTER TABLE environments ADD COLUMN hidden INTEGER NOT NULL DEFAULT 0;
ALTER TABLE environments ADD COLUMN parent_environment_id TEXT;
ALTER TABLE environments ADD COLUMN swarm_node_id TEXT;
@@ -6,3 +7,13 @@ CREATE INDEX IF NOT EXISTS idx_environments_hidden ON environments(hidden);
CREATE INDEX IF NOT EXISTS idx_environments_parent_environment_id ON environments(parent_environment_id);
CREATE INDEX IF NOT EXISTS idx_environments_swarm_node_id ON environments(swarm_node_id);
CREATE INDEX IF NOT EXISTS idx_environments_parent_swarm_node ON environments(parent_environment_id, swarm_node_id);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_environments_parent_swarm_node;
+DROP INDEX IF EXISTS idx_environments_swarm_node_id;
+DROP INDEX IF EXISTS idx_environments_parent_environment_id;
+DROP INDEX IF EXISTS idx_environments_hidden;
+
+ALTER TABLE environments DROP COLUMN swarm_node_id;
+ALTER TABLE environments DROP COLUMN parent_environment_id;
+ALTER TABLE environments DROP COLUMN hidden;
diff --git a/backend/resources/migrations/sqlite/044_allow_nested_project_paths.down.sql b/backend/resources/migrations/sqlite/044_allow_nested_project_paths.sql
similarity index 53%
rename from backend/resources/migrations/sqlite/044_allow_nested_project_paths.down.sql
rename to backend/resources/migrations/sqlite/044_allow_nested_project_paths.sql
index 955625440..6d52d3b38 100644
--- a/backend/resources/migrations/sqlite/044_allow_nested_project_paths.down.sql
+++ b/backend/resources/migrations/sqlite/044_allow_nested_project_paths.sql
@@ -1,3 +1,61 @@
+-- +goose NO TRANSACTION
+-- +goose Up
+PRAGMA foreign_keys=OFF;
+
+ALTER TABLE projects RENAME TO projects_old;
+
+CREATE TABLE projects (
+ id TEXT PRIMARY KEY,
+ name TEXT NOT NULL,
+ dir_name TEXT,
+ path TEXT NOT NULL,
+ status TEXT NOT NULL,
+ service_count INTEGER NOT NULL DEFAULT 0,
+ running_count INTEGER NOT NULL DEFAULT 0,
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_at DATETIME,
+ status_reason TEXT,
+ gitops_managed_by TEXT
+);
+
+INSERT INTO projects (
+ id,
+ name,
+ dir_name,
+ path,
+ status,
+ service_count,
+ running_count,
+ created_at,
+ updated_at,
+ status_reason,
+ gitops_managed_by
+)
+SELECT
+ id,
+ name,
+ dir_name,
+ path,
+ status,
+ service_count,
+ running_count,
+ created_at,
+ updated_at,
+ status_reason,
+ gitops_managed_by
+FROM projects_old;
+
+DROP TABLE projects_old;
+
+CREATE INDEX IF NOT EXISTS idx_projects_status ON projects(status);
+CREATE INDEX IF NOT EXISTS idx_projects_name ON projects(name);
+CREATE INDEX IF NOT EXISTS idx_projects_gitops_managed_by ON projects(gitops_managed_by);
+CREATE INDEX IF NOT EXISTS idx_projects_dir_name_not_null ON projects(dir_name) WHERE dir_name IS NOT NULL;
+CREATE UNIQUE INDEX IF NOT EXISTS idx_projects_path_unique ON projects(path);
+
+PRAGMA foreign_keys=ON;
+
+-- +goose Down
PRAGMA foreign_keys=OFF;
-- Rollback is only safe when dir_name values remain unique.
diff --git a/backend/resources/migrations/sqlite/044_allow_nested_project_paths.up.sql b/backend/resources/migrations/sqlite/044_allow_nested_project_paths.up.sql
deleted file mode 100644
index 794939acb..000000000
--- a/backend/resources/migrations/sqlite/044_allow_nested_project_paths.up.sql
+++ /dev/null
@@ -1,54 +0,0 @@
-PRAGMA foreign_keys=OFF;
-
-ALTER TABLE projects RENAME TO projects_old;
-
-CREATE TABLE projects (
- id TEXT PRIMARY KEY,
- name TEXT NOT NULL,
- dir_name TEXT,
- path TEXT NOT NULL,
- status TEXT NOT NULL,
- service_count INTEGER NOT NULL DEFAULT 0,
- running_count INTEGER NOT NULL DEFAULT 0,
- created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- updated_at DATETIME,
- status_reason TEXT,
- gitops_managed_by TEXT
-);
-
-INSERT INTO projects (
- id,
- name,
- dir_name,
- path,
- status,
- service_count,
- running_count,
- created_at,
- updated_at,
- status_reason,
- gitops_managed_by
-)
-SELECT
- id,
- name,
- dir_name,
- path,
- status,
- service_count,
- running_count,
- created_at,
- updated_at,
- status_reason,
- gitops_managed_by
-FROM projects_old;
-
-DROP TABLE projects_old;
-
-CREATE INDEX IF NOT EXISTS idx_projects_status ON projects(status);
-CREATE INDEX IF NOT EXISTS idx_projects_name ON projects(name);
-CREATE INDEX IF NOT EXISTS idx_projects_gitops_managed_by ON projects(gitops_managed_by);
-CREATE INDEX IF NOT EXISTS idx_projects_dir_name_not_null ON projects(dir_name) WHERE dir_name IS NOT NULL;
-CREATE UNIQUE INDEX IF NOT EXISTS idx_projects_path_unique ON projects(path);
-
-PRAGMA foreign_keys=ON;
diff --git a/backend/resources/migrations/sqlite/045_add_webhooks.down.sql b/backend/resources/migrations/sqlite/045_add_webhooks.down.sql
deleted file mode 100644
index 0457cf1c1..000000000
--- a/backend/resources/migrations/sqlite/045_add_webhooks.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP TABLE IF EXISTS webhooks;
diff --git a/backend/resources/migrations/sqlite/045_add_webhooks.up.sql b/backend/resources/migrations/sqlite/045_add_webhooks.sql
similarity index 92%
rename from backend/resources/migrations/sqlite/045_add_webhooks.up.sql
rename to backend/resources/migrations/sqlite/045_add_webhooks.sql
index ddd78c2fd..2f8300ec5 100644
--- a/backend/resources/migrations/sqlite/045_add_webhooks.up.sql
+++ b/backend/resources/migrations/sqlite/045_add_webhooks.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS webhooks (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
@@ -16,3 +17,6 @@ CREATE TABLE IF NOT EXISTS webhooks (
CREATE INDEX IF NOT EXISTS idx_webhooks_token_prefix ON webhooks(token_prefix);
CREATE INDEX IF NOT EXISTS idx_webhooks_environment_id ON webhooks(environment_id);
+
+-- +goose Down
+DROP TABLE IF EXISTS webhooks;
diff --git a/backend/resources/migrations/sqlite/046_nullable_api_key_user_id.down.sql b/backend/resources/migrations/sqlite/046_nullable_api_key_user_id.down.sql
deleted file mode 100644
index 2295401f0..000000000
--- a/backend/resources/migrations/sqlite/046_nullable_api_key_user_id.down.sql
+++ /dev/null
@@ -1,61 +0,0 @@
--- Remove environment bootstrap keys (user_id IS NULL) before restoring the NOT NULL constraint.
-PRAGMA foreign_keys=OFF;
-
-DROP TABLE IF EXISTS api_keys_old;
-
-CREATE TABLE api_keys_old (
- id TEXT PRIMARY KEY,
- name TEXT NOT NULL,
- description TEXT,
- key_hash TEXT NOT NULL,
- key_prefix TEXT NOT NULL,
- managed_by TEXT,
- user_id TEXT NOT NULL,
- environment_id TEXT,
- expires_at DATETIME,
- last_used_at DATETIME,
- created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- updated_at DATETIME,
- FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
- FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE CASCADE
-);
-
-INSERT INTO api_keys_old (
- id,
- name,
- description,
- key_hash,
- key_prefix,
- managed_by,
- user_id,
- environment_id,
- expires_at,
- last_used_at,
- created_at,
- updated_at
-)
-SELECT
- id,
- name,
- description,
- key_hash,
- key_prefix,
- managed_by,
- user_id,
- environment_id,
- expires_at,
- last_used_at,
- created_at,
- updated_at
-FROM api_keys
-WHERE user_id IS NOT NULL;
-
-DROP TABLE api_keys;
-ALTER TABLE api_keys_old RENAME TO api_keys;
-
-CREATE INDEX IF NOT EXISTS idx_api_keys_key_hash ON api_keys(key_hash);
-CREATE INDEX IF NOT EXISTS idx_api_keys_key_prefix ON api_keys(key_prefix);
-CREATE INDEX IF NOT EXISTS idx_api_keys_expires_at_not_null ON api_keys(expires_at) WHERE expires_at IS NOT NULL;
-CREATE INDEX IF NOT EXISTS idx_api_keys_user_managed_by_created_at ON api_keys(user_id, managed_by, created_at, id);
-
-PRAGMA foreign_keys=ON;
diff --git a/backend/resources/migrations/sqlite/046_nullable_api_key_user_id.sql b/backend/resources/migrations/sqlite/046_nullable_api_key_user_id.sql
new file mode 100644
index 000000000..dccec3d60
--- /dev/null
+++ b/backend/resources/migrations/sqlite/046_nullable_api_key_user_id.sql
@@ -0,0 +1,126 @@
+-- +goose NO TRANSACTION
+-- +goose Up
+-- Environment bootstrap keys are owned by the system, not a user.
+-- Allow user_id to be NULL so agent-side key creation doesn't violate the FK constraint.
+PRAGMA foreign_keys=OFF;
+
+DROP TABLE IF EXISTS api_keys_new;
+
+CREATE TABLE api_keys_new (
+ id TEXT PRIMARY KEY,
+ name TEXT NOT NULL,
+ description TEXT,
+ key_hash TEXT NOT NULL,
+ key_prefix TEXT NOT NULL,
+ managed_by TEXT,
+ user_id TEXT,
+ environment_id TEXT,
+ expires_at DATETIME,
+ last_used_at DATETIME,
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_at DATETIME,
+ FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
+ FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE CASCADE
+);
+
+INSERT INTO api_keys_new (
+ id,
+ name,
+ description,
+ key_hash,
+ key_prefix,
+ managed_by,
+ user_id,
+ environment_id,
+ expires_at,
+ last_used_at,
+ created_at,
+ updated_at
+)
+SELECT
+ id,
+ name,
+ description,
+ key_hash,
+ key_prefix,
+ managed_by,
+ user_id,
+ environment_id,
+ expires_at,
+ last_used_at,
+ created_at,
+ updated_at
+FROM api_keys;
+
+DROP TABLE api_keys;
+ALTER TABLE api_keys_new RENAME TO api_keys;
+
+CREATE INDEX IF NOT EXISTS idx_api_keys_key_hash ON api_keys(key_hash);
+CREATE INDEX IF NOT EXISTS idx_api_keys_key_prefix ON api_keys(key_prefix);
+CREATE INDEX IF NOT EXISTS idx_api_keys_expires_at_not_null ON api_keys(expires_at) WHERE expires_at IS NOT NULL;
+CREATE INDEX IF NOT EXISTS idx_api_keys_user_managed_by_created_at ON api_keys(user_id, managed_by, created_at, id);
+
+PRAGMA foreign_keys=ON;
+
+-- +goose Down
+-- Remove environment bootstrap keys (user_id IS NULL) before restoring the NOT NULL constraint.
+PRAGMA foreign_keys=OFF;
+
+DROP TABLE IF EXISTS api_keys_old;
+
+CREATE TABLE api_keys_old (
+ id TEXT PRIMARY KEY,
+ name TEXT NOT NULL,
+ description TEXT,
+ key_hash TEXT NOT NULL,
+ key_prefix TEXT NOT NULL,
+ managed_by TEXT,
+ user_id TEXT NOT NULL,
+ environment_id TEXT,
+ expires_at DATETIME,
+ last_used_at DATETIME,
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_at DATETIME,
+ FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
+ FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE CASCADE
+);
+
+INSERT INTO api_keys_old (
+ id,
+ name,
+ description,
+ key_hash,
+ key_prefix,
+ managed_by,
+ user_id,
+ environment_id,
+ expires_at,
+ last_used_at,
+ created_at,
+ updated_at
+)
+SELECT
+ id,
+ name,
+ description,
+ key_hash,
+ key_prefix,
+ managed_by,
+ user_id,
+ environment_id,
+ expires_at,
+ last_used_at,
+ created_at,
+ updated_at
+FROM api_keys
+WHERE user_id IS NOT NULL;
+
+DROP TABLE api_keys;
+ALTER TABLE api_keys_old RENAME TO api_keys;
+
+CREATE INDEX IF NOT EXISTS idx_api_keys_key_hash ON api_keys(key_hash);
+CREATE INDEX IF NOT EXISTS idx_api_keys_key_prefix ON api_keys(key_prefix);
+CREATE INDEX IF NOT EXISTS idx_api_keys_expires_at_not_null ON api_keys(expires_at) WHERE expires_at IS NOT NULL;
+CREATE INDEX IF NOT EXISTS idx_api_keys_user_managed_by_created_at ON api_keys(user_id, managed_by, created_at, id);
+
+PRAGMA foreign_keys=ON;
diff --git a/backend/resources/migrations/sqlite/046_nullable_api_key_user_id.up.sql b/backend/resources/migrations/sqlite/046_nullable_api_key_user_id.up.sql
deleted file mode 100644
index 43d4a3527..000000000
--- a/backend/resources/migrations/sqlite/046_nullable_api_key_user_id.up.sql
+++ /dev/null
@@ -1,61 +0,0 @@
--- Environment bootstrap keys are owned by the system, not a user.
--- Allow user_id to be NULL so agent-side key creation doesn't violate the FK constraint.
-PRAGMA foreign_keys=OFF;
-
-DROP TABLE IF EXISTS api_keys_new;
-
-CREATE TABLE api_keys_new (
- id TEXT PRIMARY KEY,
- name TEXT NOT NULL,
- description TEXT,
- key_hash TEXT NOT NULL,
- key_prefix TEXT NOT NULL,
- managed_by TEXT,
- user_id TEXT,
- environment_id TEXT,
- expires_at DATETIME,
- last_used_at DATETIME,
- created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- updated_at DATETIME,
- FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
- FOREIGN KEY (environment_id) REFERENCES environments(id) ON DELETE CASCADE
-);
-
-INSERT INTO api_keys_new (
- id,
- name,
- description,
- key_hash,
- key_prefix,
- managed_by,
- user_id,
- environment_id,
- expires_at,
- last_used_at,
- created_at,
- updated_at
-)
-SELECT
- id,
- name,
- description,
- key_hash,
- key_prefix,
- managed_by,
- user_id,
- environment_id,
- expires_at,
- last_used_at,
- created_at,
- updated_at
-FROM api_keys;
-
-DROP TABLE api_keys;
-ALTER TABLE api_keys_new RENAME TO api_keys;
-
-CREATE INDEX IF NOT EXISTS idx_api_keys_key_hash ON api_keys(key_hash);
-CREATE INDEX IF NOT EXISTS idx_api_keys_key_prefix ON api_keys(key_prefix);
-CREATE INDEX IF NOT EXISTS idx_api_keys_expires_at_not_null ON api_keys(expires_at) WHERE expires_at IS NOT NULL;
-CREATE INDEX IF NOT EXISTS idx_api_keys_user_managed_by_created_at ON api_keys(user_id, managed_by, created_at, id);
-
-PRAGMA foreign_keys=ON;
diff --git a/backend/resources/migrations/sqlite/047_add_gitops_sync_target_type.down.sql b/backend/resources/migrations/sqlite/047_add_gitops_sync_target_type.down.sql
deleted file mode 100644
index a5b0f9088..000000000
--- a/backend/resources/migrations/sqlite/047_add_gitops_sync_target_type.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE gitops_syncs DROP COLUMN target_type;
diff --git a/backend/resources/migrations/sqlite/047_add_gitops_sync_target_type.up.sql b/backend/resources/migrations/sqlite/047_add_gitops_sync_target_type.sql
similarity index 50%
rename from backend/resources/migrations/sqlite/047_add_gitops_sync_target_type.up.sql
rename to backend/resources/migrations/sqlite/047_add_gitops_sync_target_type.sql
index c1bbb0a79..67f75c8a2 100644
--- a/backend/resources/migrations/sqlite/047_add_gitops_sync_target_type.up.sql
+++ b/backend/resources/migrations/sqlite/047_add_gitops_sync_target_type.sql
@@ -1 +1,5 @@
+-- +goose Up
ALTER TABLE gitops_syncs ADD COLUMN target_type TEXT NOT NULL DEFAULT 'project';
+
+-- +goose Down
+ALTER TABLE gitops_syncs DROP COLUMN target_type;
diff --git a/backend/resources/migrations/sqlite/048_add_compose_project_name.down.sql b/backend/resources/migrations/sqlite/048_add_compose_project_name.sql
similarity index 91%
rename from backend/resources/migrations/sqlite/048_add_compose_project_name.down.sql
rename to backend/resources/migrations/sqlite/048_add_compose_project_name.sql
index 517e327b7..cefe74696 100644
--- a/backend/resources/migrations/sqlite/048_add_compose_project_name.down.sql
+++ b/backend/resources/migrations/sqlite/048_add_compose_project_name.sql
@@ -1,3 +1,8 @@
+-- +goose NO TRANSACTION
+-- +goose Up
+ALTER TABLE projects ADD COLUMN compose_project_name TEXT;
+
+-- +goose Down
PRAGMA foreign_keys=OFF;
ALTER TABLE projects RENAME TO projects_old;
diff --git a/backend/resources/migrations/sqlite/048_add_compose_project_name.up.sql b/backend/resources/migrations/sqlite/048_add_compose_project_name.up.sql
deleted file mode 100644
index 9155e4826..000000000
--- a/backend/resources/migrations/sqlite/048_add_compose_project_name.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE projects ADD COLUMN compose_project_name TEXT;
diff --git a/backend/resources/migrations/sqlite/049_add_projects_name_index.down.sql b/backend/resources/migrations/sqlite/049_add_projects_name_index.down.sql
deleted file mode 100644
index 2177cfdbb..000000000
--- a/backend/resources/migrations/sqlite/049_add_projects_name_index.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-DROP INDEX IF EXISTS idx_projects_name;
diff --git a/backend/resources/migrations/sqlite/049_add_projects_name_index.sql b/backend/resources/migrations/sqlite/049_add_projects_name_index.sql
new file mode 100644
index 000000000..3f38b2ab0
--- /dev/null
+++ b/backend/resources/migrations/sqlite/049_add_projects_name_index.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+CREATE INDEX IF NOT EXISTS idx_projects_name ON projects (name);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_projects_name;
diff --git a/backend/resources/migrations/sqlite/049_add_projects_name_index.up.sql b/backend/resources/migrations/sqlite/049_add_projects_name_index.up.sql
deleted file mode 100644
index 2deb77b44..000000000
--- a/backend/resources/migrations/sqlite/049_add_projects_name_index.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-CREATE INDEX IF NOT EXISTS idx_projects_name ON projects (name);
diff --git a/backend/resources/migrations/sqlite/050_add_project_archived.down.sql b/backend/resources/migrations/sqlite/050_add_project_archived.down.sql
deleted file mode 100644
index bd71b4c9a..000000000
--- a/backend/resources/migrations/sqlite/050_add_project_archived.down.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-DROP INDEX IF EXISTS idx_projects_is_archived;
-ALTER TABLE projects DROP COLUMN archived_at;
-ALTER TABLE projects DROP COLUMN is_archived;
diff --git a/backend/resources/migrations/sqlite/050_add_project_archived.up.sql b/backend/resources/migrations/sqlite/050_add_project_archived.sql
similarity index 53%
rename from backend/resources/migrations/sqlite/050_add_project_archived.up.sql
rename to backend/resources/migrations/sqlite/050_add_project_archived.sql
index b98dc887a..b4675d3f5 100644
--- a/backend/resources/migrations/sqlite/050_add_project_archived.up.sql
+++ b/backend/resources/migrations/sqlite/050_add_project_archived.sql
@@ -1,3 +1,9 @@
+-- +goose Up
ALTER TABLE projects ADD COLUMN is_archived BOOLEAN NOT NULL DEFAULT 0;
ALTER TABLE projects ADD COLUMN archived_at DATETIME;
CREATE INDEX idx_projects_is_archived ON projects(is_archived);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_projects_is_archived;
+ALTER TABLE projects DROP COLUMN archived_at;
+ALTER TABLE projects DROP COLUMN is_archived;
diff --git a/backend/resources/migrations/sqlite/051_add_user_sessions.down.sql b/backend/resources/migrations/sqlite/051_add_user_sessions.down.sql
deleted file mode 100644
index 58349aa4c..000000000
--- a/backend/resources/migrations/sqlite/051_add_user_sessions.down.sql
+++ /dev/null
@@ -1,3 +0,0 @@
-DROP INDEX IF EXISTS idx_user_sessions_expires_at;
-DROP INDEX IF EXISTS idx_user_sessions_user_id;
-DROP TABLE IF EXISTS user_sessions;
diff --git a/backend/resources/migrations/sqlite/051_add_user_sessions.up.sql b/backend/resources/migrations/sqlite/051_add_user_sessions.sql
similarity index 75%
rename from backend/resources/migrations/sqlite/051_add_user_sessions.up.sql
rename to backend/resources/migrations/sqlite/051_add_user_sessions.sql
index 9bb6ac613..5c1c295d6 100644
--- a/backend/resources/migrations/sqlite/051_add_user_sessions.up.sql
+++ b/backend/resources/migrations/sqlite/051_add_user_sessions.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE user_sessions (
id TEXT PRIMARY KEY,
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
@@ -13,3 +14,8 @@ CREATE TABLE user_sessions (
CREATE INDEX idx_user_sessions_user_id ON user_sessions(user_id);
CREATE INDEX idx_user_sessions_expires_at ON user_sessions(expires_at);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_user_sessions_expires_at;
+DROP INDEX IF EXISTS idx_user_sessions_user_id;
+DROP TABLE IF EXISTS user_sessions;
diff --git a/backend/resources/migrations/sqlite/052_add_project_image_refs.down.sql b/backend/resources/migrations/sqlite/052_add_project_image_refs.down.sql
deleted file mode 100644
index e2a56cc0c..000000000
--- a/backend/resources/migrations/sqlite/052_add_project_image_refs.down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE projects DROP COLUMN image_refs_json;
diff --git a/backend/resources/migrations/sqlite/052_add_project_image_refs.sql b/backend/resources/migrations/sqlite/052_add_project_image_refs.sql
new file mode 100644
index 000000000..c5e4639c2
--- /dev/null
+++ b/backend/resources/migrations/sqlite/052_add_project_image_refs.sql
@@ -0,0 +1,5 @@
+-- +goose Up
+ALTER TABLE projects ADD COLUMN image_refs_json TEXT NOT NULL DEFAULT '';
+
+-- +goose Down
+ALTER TABLE projects DROP COLUMN image_refs_json;
diff --git a/backend/resources/migrations/sqlite/052_add_project_image_refs.up.sql b/backend/resources/migrations/sqlite/052_add_project_image_refs.up.sql
deleted file mode 100644
index 5758bb697..000000000
--- a/backend/resources/migrations/sqlite/052_add_project_image_refs.up.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE projects ADD COLUMN image_refs_json TEXT NOT NULL DEFAULT '';
diff --git a/backend/resources/migrations/sqlite/053_drop_deprecated_v2.down.sql b/backend/resources/migrations/sqlite/053_drop_deprecated_v2.down.sql
deleted file mode 100644
index 4cffbb72a..000000000
--- a/backend/resources/migrations/sqlite/053_drop_deprecated_v2.down.sql
+++ /dev/null
@@ -1,10 +0,0 @@
--- v2.0.0 rollback: recreate the apprise_settings table shape (data is not restored).
-CREATE TABLE IF NOT EXISTS apprise_settings (
- id INTEGER PRIMARY KEY AUTOINCREMENT,
- api_url TEXT NOT NULL,
- enabled INTEGER NOT NULL DEFAULT 0,
- image_update_tag VARCHAR(255),
- container_update_tag VARCHAR(255),
- created_at DATETIME,
- updated_at DATETIME
-);
diff --git a/backend/resources/migrations/sqlite/053_drop_deprecated_v2.sql b/backend/resources/migrations/sqlite/053_drop_deprecated_v2.sql
new file mode 100644
index 000000000..13d4aabd1
--- /dev/null
+++ b/backend/resources/migrations/sqlite/053_drop_deprecated_v2.sql
@@ -0,0 +1,25 @@
+-- +goose Up
+-- v2.0.0: drop the Apprise notification service table and deprecated settings rows.
+DROP TABLE IF EXISTS apprise_settings;
+
+DELETE FROM settings WHERE key IN (
+ 'dockerPruneMode',
+ 'scheduledPruneContainers',
+ 'scheduledPruneImages',
+ 'scheduledPruneVolumes',
+ 'scheduledPruneNetworks',
+ 'scheduledPruneBuildCache',
+ 'authOidcConfig'
+);
+
+-- +goose Down
+-- v2.0.0 rollback: recreate the apprise_settings table shape (data is not restored).
+CREATE TABLE IF NOT EXISTS apprise_settings (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ api_url TEXT NOT NULL,
+ enabled INTEGER NOT NULL DEFAULT 0,
+ image_update_tag VARCHAR(255),
+ container_update_tag VARCHAR(255),
+ created_at DATETIME,
+ updated_at DATETIME
+);
diff --git a/backend/resources/migrations/sqlite/053_drop_deprecated_v2.up.sql b/backend/resources/migrations/sqlite/053_drop_deprecated_v2.up.sql
deleted file mode 100644
index c3bbe402d..000000000
--- a/backend/resources/migrations/sqlite/053_drop_deprecated_v2.up.sql
+++ /dev/null
@@ -1,12 +0,0 @@
--- v2.0.0: drop the Apprise notification service table and deprecated settings rows.
-DROP TABLE IF EXISTS apprise_settings;
-
-DELETE FROM settings WHERE key IN (
- 'dockerPruneMode',
- 'scheduledPruneContainers',
- 'scheduledPruneImages',
- 'scheduledPruneVolumes',
- 'scheduledPruneNetworks',
- 'scheduledPruneBuildCache',
- 'authOidcConfig'
-);
diff --git a/backend/resources/migrations/sqlite/054_add_rbac.down.sql b/backend/resources/migrations/sqlite/054_add_rbac.down.sql
deleted file mode 100644
index 0bc7893ed..000000000
--- a/backend/resources/migrations/sqlite/054_add_rbac.down.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-
-DELETE FROM settings WHERE key = 'oidcGroupsClaim';
-
-DROP INDEX IF EXISTS idx_orm_claim;
-DROP TABLE IF EXISTS oidc_role_mappings;
-
-DROP INDEX IF EXISTS idx_akp_uniq;
-DROP INDEX IF EXISTS idx_akp_key;
-DROP TABLE IF EXISTS api_key_permissions;
-
-DROP INDEX IF EXISTS idx_ura_uniq;
-DROP INDEX IF EXISTS idx_ura_env;
-DROP INDEX IF EXISTS idx_ura_role;
-DROP INDEX IF EXISTS idx_ura_user;
-DROP TABLE IF EXISTS user_role_assignments;
-
-DROP TABLE IF EXISTS roles;
diff --git a/backend/resources/migrations/sqlite/054_add_rbac.up.sql b/backend/resources/migrations/sqlite/054_add_rbac.sql
similarity index 84%
rename from backend/resources/migrations/sqlite/054_add_rbac.up.sql
rename to backend/resources/migrations/sqlite/054_add_rbac.sql
index 0428fc398..50fe4e94b 100644
--- a/backend/resources/migrations/sqlite/054_add_rbac.up.sql
+++ b/backend/resources/migrations/sqlite/054_add_rbac.sql
@@ -1,4 +1,4 @@
-
+-- +goose Up
CREATE TABLE IF NOT EXISTS roles (
id TEXT PRIMARY KEY,
name TEXT NOT NULL UNIQUE,
@@ -58,3 +58,21 @@ CREATE TABLE IF NOT EXISTS oidc_role_mappings (
);
CREATE INDEX IF NOT EXISTS idx_orm_claim ON oidc_role_mappings(claim_value);
+
+-- +goose Down
+DELETE FROM settings WHERE key = 'oidcGroupsClaim';
+
+DROP INDEX IF EXISTS idx_orm_claim;
+DROP TABLE IF EXISTS oidc_role_mappings;
+
+DROP INDEX IF EXISTS idx_akp_uniq;
+DROP INDEX IF EXISTS idx_akp_key;
+DROP TABLE IF EXISTS api_key_permissions;
+
+DROP INDEX IF EXISTS idx_ura_uniq;
+DROP INDEX IF EXISTS idx_ura_env;
+DROP INDEX IF EXISTS idx_ura_role;
+DROP INDEX IF EXISTS idx_ura_user;
+DROP TABLE IF EXISTS user_role_assignments;
+
+DROP TABLE IF EXISTS roles;
diff --git a/backend/resources/migrations/sqlite/055_add_activities.down.sql b/backend/resources/migrations/sqlite/055_add_activities.down.sql
deleted file mode 100644
index 58d060bf5..000000000
--- a/backend/resources/migrations/sqlite/055_add_activities.down.sql
+++ /dev/null
@@ -1,2 +0,0 @@
-DROP TABLE IF EXISTS activity_messages;
-DROP TABLE IF EXISTS activities;
diff --git a/backend/resources/migrations/sqlite/055_add_activities.up.sql b/backend/resources/migrations/sqlite/055_add_activities.sql
similarity index 92%
rename from backend/resources/migrations/sqlite/055_add_activities.up.sql
rename to backend/resources/migrations/sqlite/055_add_activities.sql
index 03a95b719..7bde28efd 100644
--- a/backend/resources/migrations/sqlite/055_add_activities.up.sql
+++ b/backend/resources/migrations/sqlite/055_add_activities.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE activities (
id TEXT PRIMARY KEY,
created_at DATETIME NOT NULL,
@@ -39,3 +40,7 @@ CREATE TABLE activity_messages (
);
CREATE INDEX idx_activity_messages_activity_created ON activity_messages(activity_id, created_at);
+
+-- +goose Down
+DROP TABLE IF EXISTS activity_messages;
+DROP TABLE IF EXISTS activities;
diff --git a/backend/resources/migrations/sqlite/056_add_federated_credentials.down.sql b/backend/resources/migrations/sqlite/056_add_federated_credentials.down.sql
deleted file mode 100644
index 2173d5356..000000000
--- a/backend/resources/migrations/sqlite/056_add_federated_credentials.down.sql
+++ /dev/null
@@ -1,13 +0,0 @@
-DROP INDEX IF EXISTS idx_user_sessions_federated_credential_id;
-ALTER TABLE user_sessions DROP COLUMN federated_credential_id;
-ALTER TABLE user_sessions DROP COLUMN source;
-ALTER TABLE users DROP COLUMN is_service_account;
-
-DROP INDEX IF EXISTS idx_federated_credentials_role_id;
-DROP INDEX IF EXISTS idx_federated_credentials_identity_user_id;
-DROP INDEX IF EXISTS idx_federated_credentials_enabled;
-DROP INDEX IF EXISTS idx_federated_credentials_issuer_url;
-DROP INDEX IF EXISTS idx_federated_token_replays_expires_at;
-DROP INDEX IF EXISTS idx_federated_token_replays_issuer_url;
-DROP TABLE IF EXISTS federated_token_replays;
-DROP TABLE IF EXISTS federated_credentials;
diff --git a/backend/resources/migrations/sqlite/056_add_federated_credentials.up.sql b/backend/resources/migrations/sqlite/056_add_federated_credentials.sql
similarity index 74%
rename from backend/resources/migrations/sqlite/056_add_federated_credentials.up.sql
rename to backend/resources/migrations/sqlite/056_add_federated_credentials.sql
index 9c171e97d..73adb386b 100644
--- a/backend/resources/migrations/sqlite/056_add_federated_credentials.up.sql
+++ b/backend/resources/migrations/sqlite/056_add_federated_credentials.sql
@@ -1,3 +1,4 @@
+-- +goose Up
CREATE TABLE IF NOT EXISTS federated_credentials (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
@@ -43,3 +44,18 @@ ALTER TABLE user_sessions ADD COLUMN source TEXT;
ALTER TABLE user_sessions ADD COLUMN federated_credential_id TEXT REFERENCES federated_credentials(id) ON DELETE SET NULL;
CREATE INDEX IF NOT EXISTS idx_user_sessions_federated_credential_id ON user_sessions(federated_credential_id);
+
+-- +goose Down
+DROP INDEX IF EXISTS idx_user_sessions_federated_credential_id;
+ALTER TABLE user_sessions DROP COLUMN federated_credential_id;
+ALTER TABLE user_sessions DROP COLUMN source;
+ALTER TABLE users DROP COLUMN is_service_account;
+
+DROP INDEX IF EXISTS idx_federated_credentials_role_id;
+DROP INDEX IF EXISTS idx_federated_credentials_identity_user_id;
+DROP INDEX IF EXISTS idx_federated_credentials_enabled;
+DROP INDEX IF EXISTS idx_federated_credentials_issuer_url;
+DROP INDEX IF EXISTS idx_federated_token_replays_expires_at;
+DROP INDEX IF EXISTS idx_federated_token_replays_issuer_url;
+DROP TABLE IF EXISTS federated_token_replays;
+DROP TABLE IF EXISTS federated_credentials;
diff --git a/go.work.sum b/go.work.sum
index caff613b1..3ecd434da 100644
--- a/go.work.sum
+++ b/go.work.sum
@@ -33,6 +33,8 @@ cyphar.com/go-pathrs v0.2.4 h1:iD/mge36swa1UFKdINkr1Frkpp6wZsy3YYEildj9cLY=
cyphar.com/go-pathrs v0.2.4/go.mod h1:y8f1EMG7r+hCuFf/rXsKqMJrJAUoADZGNh5/vZPKcGc=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
+filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo=
+filippo.io/edwards25519 v1.2.0/go.mod h1:xzAOLCNug/yB62zG1bQ8uziwrIqIuxhctzJT18Q77mc=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4=
github.com/99designs/keyring v1.2.1 h1:tYLp1ULvO7i3fI5vE21ReQuj99QFSs7lGm0xWyJo87o=
@@ -70,8 +72,12 @@ github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
+github.com/ClickHouse/ch-go v0.71.0 h1:bUdZ/EZj/LcVHsMqaRUP2holqygrPWQKeMjc6nZoyRM=
+github.com/ClickHouse/ch-go v0.71.0/go.mod h1:NwbNc+7jaqfY58dmdDUbG4Jl22vThgx1cYjBw0vtgXw=
github.com/ClickHouse/clickhouse-go v1.4.3 h1:iAFMa2UrQdR5bHJ2/yaSLffZkxpcOYQMCUuKeNXGdqc=
github.com/ClickHouse/clickhouse-go v1.4.3/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI=
+github.com/ClickHouse/clickhouse-go/v2 v2.45.0 h1:iHt15nA4iYhfde5bDQAcLAat9BAh7B5ksPRNRa4UI7s=
+github.com/ClickHouse/clickhouse-go/v2 v2.45.0/go.mod h1:giJfUVlMkcfUEPVfRpt51zZaGEx9i17gCos8gBl392c=
github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.3 h1:2afWGsMzkIcN8Qm4mgPJKZWyroE5QBszMiDMYEBrnfw=
github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.3/go.mod h1:dppbR7CwXD4pgtV9t3wD1812RaLDcBjtblcDF5f1vI0=
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.30.0 h1:sBEjpZlNHzK1voKq9695PJSX2o5NEXl7/OL3coiIY0c=
@@ -116,6 +122,8 @@ github.com/andybalholm/brotli v1.2.1/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUS
github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g=
+github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ=
+github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw=
github.com/apache/arrow/go/v10 v10.0.1 h1:n9dERvixoC/1JjDmBcs9FPaEryoANa2sCgVFo6ez9cI=
github.com/apache/arrow/go/v10 v10.0.1/go.mod h1:YvhnlEePVnBS4+0z3fhPfUy7W1Ikj0Ih0vcRo/gZ1M0=
github.com/apache/thrift v0.16.0 h1:qEy6UW60iVOlUy+b9ZR0d5WzUWYGOo4HfopoyBaNmoY=
@@ -319,6 +327,8 @@ github.com/cockroachdb/cockroach-go/v2 v2.1.1/go.mod h1:7NtUnP6eK+l6k483WSYNrq3K
github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5 h1:xD/lrqdvwsc+O2bjSSi3YqY73Ke3LAiSCx49aCesA0E=
github.com/cockroachdb/errors v1.2.4 h1:Lap807SXTH5tri2TivECb/4abUkMZC9zRoLarvcKDqs=
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOiXqcou5a3rIlMc7oJbMQkeLk0VQJ7zgqY=
+github.com/coder/websocket v1.8.14 h1:9L0p0iKiNOibykf283eHkKUHHrpG7f65OE3BhhO7v9g=
+github.com/coder/websocket v1.8.14/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
github.com/compose-spec/compose-go/v2 v2.9.1/go.mod h1:Oky9AZGTRB4E+0VbTPZTUu4Kp+oEMMuwZXZtPPVT1iE=
github.com/container-storage-interface/spec v1.2.0 h1:bD9KIVgaVKKkQ/UbVUY9kCaH/CJbhNxe0eeB4JeJV2s=
github.com/container-storage-interface/spec v1.2.0/go.mod h1:6URME8mwIBbpVyZV93Ce5St17xBiQJQY67NDsuohiy4=
@@ -420,6 +430,10 @@ github.com/dvsekhvalnov/jose2go v1.7.0 h1:bnQc8+GMnidJZA8zc6lLEAb4xNrIqHwO+9Tzqv
github.com/dvsekhvalnov/jose2go v1.7.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712 h1:aaQcKT9WumO6JEJcRyTqFVq4XUZiUcKR2/GI31TOcz8=
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
+github.com/elastic/go-sysinfo v1.15.4 h1:A3zQcunCxik14MgXu39cXFXcIw2sFXZ0zL886eyiv1Q=
+github.com/elastic/go-sysinfo v1.15.4/go.mod h1:ZBVXmqS368dOn/jvijV/zHLfakWTYHBZPk3G244lHrU=
+github.com/elastic/go-windows v1.0.2 h1:yoLLsAsV5cfg9FLhZ9EXZ2n2sQFKeDYrHenkcivY4vI=
+github.com/elastic/go-windows v1.0.2/go.mod h1:bGcDpBzXgYSqM0Gx3DM4+UxFj300SZLixie9u9ixLM8=
github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes=
github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
@@ -463,8 +477,6 @@ github.com/fsouza/fake-gcs-server v1.17.0/go.mod h1:D1rTE4YCyHFNa99oyJJ5HyclvN/0
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/getarcaneapp/arcane/types v0.0.0-20251219045603-8a9960a2bf04/go.mod h1:7Wj+0JnpYq4RQS+otyM6e4zkyJKDC01wxkWPyFCHwZA=
-github.com/getarcaneapp/updater v0.3.4 h1:xLkME2B6PAElLVY7+NnLqv3bITrs9IK3fkkHCOcdAYU=
-github.com/getarcaneapp/updater v0.3.4/go.mod h1:2ENitZR/lA5MuBn60OZYR5wvU3ZCE+pAgfrebfOlRDA=
github.com/getsentry/raven-go v0.2.0 h1:no+xWJRb5ZI7eE8TWgIq1jLulQiIoLG0IfYxv5JYMGs=
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
github.com/gin-contrib/cors v1.7.7/go.mod h1:K5tW0RkzJtWSiOdikXloy8VEZlgdVNpHNw8FpjUPNrE=
@@ -481,6 +493,10 @@ github.com/go-chi/chi/v5 v5.2.2/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hH
github.com/go-chi/chi/v5 v5.2.5 h1:Eg4myHZBjyvJmAFjFvWgrqDTXFyOzjj7YIm3L3mu6Ug=
github.com/go-chi/chi/v5 v5.2.5/go.mod h1:X7Gx4mteadT3eDOMTsXzmI4/rwUpOwBHLpAfupzFJP0=
github.com/go-co-op/gocron/v2 v2.18.2/go.mod h1:Zii6he+Zfgy5W9B+JKk/KwejFOW0kZTFvHtwIpR4aBI=
+github.com/go-faster/city v1.0.1 h1:4WAxSZ3V2Ws4QRDrscLEDcibJY8uf41H6AhXDrNDcGw=
+github.com/go-faster/city v1.0.1/go.mod h1:jKcUJId49qdW3L1qKHH/3wPeUstCVpVSXTM6vO3VcTw=
+github.com/go-faster/errors v0.7.1 h1:MkJTnDoEdi9pDabt1dpWf7AA8/BaSYZqibYyhZ20AYg=
+github.com/go-faster/errors v0.7.1/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7FPGZP2quo=
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/go-jose/go-jose/v3 v3.0.0 h1:s6rrhirfEP/CGIoc6p+PZAeogN2SxKav6Wp7+dyMWVo=
@@ -553,6 +569,8 @@ github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
+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=
github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
@@ -783,6 +801,8 @@ github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh
github.com/mattn/go-runewidth v0.0.17/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
github.com/mattn/go-sqlite3 v1.6.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
+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 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
@@ -791,10 +811,14 @@ github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos
github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ=
github.com/mdlayher/vsock v1.2.1 h1:pC1mTJTvjo1r9n9fbm7S1j04rCgCzhCOS5DY0zqHlnQ=
github.com/mdlayher/vsock v1.2.1/go.mod h1:NRfCibel++DgeMD8z/hP+PPTjlNJsdPOmxcnENvE+SE=
+github.com/mfridman/xflag v0.1.0 h1:TWZrZwG1QklFX5S4j1vxfF1sZbZeZSGofMwPMLAF29M=
+github.com/mfridman/xflag v0.1.0/go.mod h1:/483ywM5ZO5SuMVjrIGquYNE5CzLrj5Ux/LxWWnjRaE=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/microsoft/go-mssqldb v1.0.0 h1:k2p2uuG8T5T/7Hp7/e3vMGTnnR0sU4h8d1CcC71iLHU=
github.com/microsoft/go-mssqldb v1.0.0/go.mod h1:+4wZTUnz/SV6nffv+RRRB/ss8jPng5Sho2SmM1l2ts4=
+github.com/microsoft/go-mssqldb v1.9.8 h1:d4IFMvF/o+HdpXUqbBfzHvn/NlFA75YGcfHUUvDFJEM=
+github.com/microsoft/go-mssqldb v1.9.8/go.mod h1:eGSRSGAW4hKMy5YcAenhCDjIRm2rhqIdmmwgciMzLus=
github.com/miekg/pkcs11 v1.0.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
github.com/miekg/pkcs11 v1.1.1 h1:Ugu9pdy6vAYku5DEpVWVFPYnzV+bxB+iRdbuFSu7TvU=
github.com/miekg/pkcs11 v1.1.1/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs=
@@ -896,6 +920,8 @@ github.com/otiai10/copy v1.14.1 h1:5/7E6qsUMBaH5AnQ0sSLzzTg1oTECmcCmT6lvF45Na8=
github.com/otiai10/copy v1.14.1/go.mod h1:oQwrEDDOci3IM8dJF0d8+jnbfPDllW6vUjNc3DoZm9I=
github.com/otiai10/mint v1.6.3 h1:87qsV/aw1F5as1eH1zS/yqHY85ANKVMgkDrf9rcxbQs=
github.com/otiai10/mint v1.6.3/go.mod h1:MJm72SBthJjz8qhefc4z1PYEieWmy8Bku7CjcAqyUSM=
+github.com/paulmach/orb v0.13.0 h1:r7n7mQGGF+cj/CbcivEj9J3HGK+XR+yXnvzRdq9saIw=
+github.com/paulmach/orb v0.13.0/go.mod h1:6scRWINywA2Jf05dcjOfLfxrUIMECvTSG2MVbRLxu/k=
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7 h1:Dx7Ovyv/SFnMFw3fD4oEoeorXc6saIiQ23LrGLth0Gw=
github.com/petermattis/goid v0.0.0-20240813172612-4fcff4a6cae7/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4=
github.com/phayes/permbits v0.0.0-20190612203442-39d7c581d2ee h1:P6U24L02WMfj9ymZTxl7CxS73JC99x3ukk+DBkgQGQs=
@@ -904,6 +930,8 @@ github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
github.com/pierrec/lz4/v4 v4.1.16 h1:kQPfno+wyx6C5572ABwV+Uo3pDFzQ7yhyGchSyRda0c=
github.com/pierrec/lz4/v4 v4.1.16/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
+github.com/pierrec/lz4/v4 v4.1.26 h1:GrpZw1gZttORinvzBdXPUXATeqlJjqUG/D87TKMnhjY=
+github.com/pierrec/lz4/v4 v4.1.26/go.mod h1:EoQMVJgeeEOMsCqCzqFm2O0cJvljX2nGZjcRIPL34O4=
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=
@@ -952,6 +980,8 @@ github.com/schollz/progressbar/v3 v3.18.0 h1:uXdoHABRFmNIjUfte/Ex7WtuyVslrw2wVPQ
github.com/schollz/progressbar/v3 v3.18.0/go.mod h1:IsO3lpbaGuzh8zIMzgY3+J8l4C8GjO0Y9S69eFvNsec=
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
+github.com/segmentio/asm v1.2.1 h1:DTNbBqs57ioxAD4PrArqftgypG4/qNpXoJx8TVXxPR0=
+github.com/segmentio/asm v1.2.1/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
github.com/segmentio/ksuid v1.0.4 h1:sBo2BdShXjmcugAMwjugoGUdUV0pcxY5mW4xKRn3v4c=
github.com/segmentio/ksuid v1.0.4/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE=
github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b h1:h+3JX2VoWTFuyQEo87pStk/a99dzIO1mM9KxIyLPGTU=
@@ -960,6 +990,8 @@ github.com/shirou/gopsutil/v4 v4.25.11 h1:X53gB7muL9Gnwwo2evPSE+SfOrltMoR6V3xJAX
github.com/shirou/gopsutil/v4 v4.25.11/go.mod h1:EivAfP5x2EhLp2ovdpKSozecVXn1TmuG7SMzs/Wh4PU=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
+github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
+github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/sigstore/fulcio v1.7.1 h1:RcoW20Nz49IGeZyu3y9QYhyyV3ZKQ85T+FXPKkvE+aQ=
github.com/sigstore/fulcio v1.7.1/go.mod h1:7lYY+hsd8Dt+IvKQRC+KEhWpCZ/GlmNvwIa5JhypMS8=
github.com/sigstore/fulcio v1.8.5 h1:HYTD1/L5wlBp8JxsWxUf8hmfaNBBF/x3r3p5l6tZwbA=
@@ -1024,6 +1056,8 @@ github.com/tonistiigi/go-archvariant v1.0.0 h1:5LC1eDWiBNflnTF1prCiX09yfNHIxDC/a
github.com/tonistiigi/go-archvariant v1.0.0/go.mod h1:TxFmO5VS6vMq2kvs3ht04iPXtu2rUT/erOnGFYfk5Ho=
github.com/tonistiigi/jaeger-ui-rest v0.0.0-20250408171107-3dd17559e117 h1:XFwyh2JZwR5aiKLXHX2C1n0v5F11dCJpyGL1W/Cpl3U=
github.com/tonistiigi/jaeger-ui-rest v0.0.0-20250408171107-3dd17559e117/go.mod h1:3Ez1Paeg+0Ghu3KwpEGC1HgZ4CHDlg+Ez/5Baeomk54=
+github.com/tursodatabase/libsql-client-go v0.0.0-20251219100830-236aa1ff8acc h1:lzi/5fg2EfinRlh3v//YyIhnc4tY7BTqazQGwb1ar+0=
+github.com/tursodatabase/libsql-client-go v0.0.0-20251219100830-236aa1ff8acc/go.mod h1:08inkKyguB6CGGssc/JzhmQWwBgFQBgjlYFjxjRh7nU=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
@@ -1050,6 +1084,8 @@ github.com/vbauerster/mpb/v8 v8.12.0 h1:+gneY3ifzc88tKDzOtfG8k8gfngCx615S2ZmFM4l
github.com/vbauerster/mpb/v8 v8.12.0/go.mod h1:V02YIuMVo301Y1VE9VtZlD8s84OMsk+EKN6mwvf/588=
github.com/vektah/gqlparser/v2 v2.5.30 h1:EqLwGAFLIzt1wpx1IPpY67DwUujF1OfzgEyDsLrN6kE=
github.com/vektah/gqlparser/v2 v2.5.30/go.mod h1:D1/VCZtV3LPnQrcPBeR/q5jkSQIPti0uYCP/RI0gIeo=
+github.com/vertica/vertica-sql-go v1.3.6 h1:uDJPdBivsI5EwfX3NMDWZaQlVs9zTnVyxE/nYhr3bY0=
+github.com/vertica/vertica-sql-go v1.3.6/go.mod h1:jnn2GFuv+O2Jcjktb7zyc4Utlbu9YVqpHH/lx63+1M4=
github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW6bV0=
github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4=
github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY=
@@ -1078,6 +1114,10 @@ github.com/xyproto/randomstring v1.2.0 h1:y7PXAEBM3XlwJjPG2JQg4voxBYZ4+hPgRdGKCf
github.com/xyproto/randomstring v1.2.0/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
github.com/yashtewari/glob-intersection v0.2.0 h1:8iuHdN88yYuCzCdjt0gDe+6bAhUwBeEWqThExu54RFg=
github.com/yashtewari/glob-intersection v0.2.0/go.mod h1:LK7pIC3piUjovexikBbJ26Yml7g8xa5bsjfx2v1fwok=
+github.com/ydb-platform/ydb-go-genproto v0.0.0-20260311095541-ebbf792c1180 h1:avIdi8eGXjKbn1WLokNR1Ofnz1k8t7tJ88YQLD/iCi8=
+github.com/ydb-platform/ydb-go-genproto v0.0.0-20260311095541-ebbf792c1180/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I=
+github.com/ydb-platform/ydb-go-sdk/v3 v3.135.0 h1:8c/M2B5W5xJd968DCedPv7DvQHuKzzhGGsO6J9x2+5U=
+github.com/ydb-platform/ydb-go-sdk/v3 v3.135.0/go.mod h1:VYUUkRJkKuQPkIpgtZJj6+58Fa2g8ccAqdmaaK6HP5k=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
@@ -1102,6 +1142,8 @@ github.com/zeebo/errs v1.4.0 h1:XNdoD/RRMKP7HD0UhJnIzUy74ISdGGxURlYG8HSWSfM=
github.com/zeebo/errs v1.4.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4=
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
+github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
+github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
github.com/zmap/zcrypto v0.0.0-20210511125630-18f1e0152cfc h1:zkGwegkOW709y0oiAraH/3D8njopUR/pARHv4tZZ6pw=
github.com/zmap/zcrypto v0.0.0-20210511125630-18f1e0152cfc/go.mod h1:FM4U1E3NzlNMRnSUTU3P1UdukWhYGifqEsjk9fn7BCk=
github.com/zmap/zlint/v3 v3.1.0 h1:WjVytZo79m/L1+/Mlphl09WBob6YTGljN5IGWZFpAv0=
@@ -1355,6 +1397,8 @@ google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
+google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY=
+google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo=
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 h1:rHWScKit0gvAPuOnu87KpaYtjK5zBMLcULh7gxkCXu4=
google.golang.org/genproto v0.0.0-20250603155806-513f23925822/go.mod h1:HubltRL7rMh0LfnQPkMH4NPDFEWp0jw3vixw7jEM53s=
google.golang.org/genproto v0.0.0-20250922171735-9219d122eba9 h1:LvZVVaPE0JSqL+ZWb6ErZfnEOKIqqFWUJE2D0fObSmc=
@@ -1425,6 +1469,8 @@ gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g=
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=
+howett.net/plist v1.0.1 h1:37GdZ8tP09Q35o9ych3ehygcsL+HqKSwzctveSlarvM=
+howett.net/plist v1.0.1/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
k8s.io/api v0.34.1 h1:jC+153630BMdlFukegoEL8E/yT7aLyQkIVuwhmwDgJM=
k8s.io/api v0.34.1/go.mod h1:SB80FxFtXn5/gwzCoN6QCtPD7Vbu5w2n1S0J5gFfTYk=
k8s.io/api v0.35.2 h1:tW7mWc2RpxW7HS4CoRXhtYHSzme1PN1UjGHJ1bdrtdw=