Skip to content
This repository was archived by the owner on May 1, 2026. It is now read-only.

Commit b9207a8

Browse files
rwloveclaude
andcommitted
Remove SQLite backend and migration tooling
PostgreSQL is now the only supported backend. POSTGRES_DSN is required. - Delete internal/db/{sqlite,edit,bulk,quote_str}.go - Delete internal/store/sqlite.go - Delete internal/migrate/migrate.go - Remove SQLite fallback from api/server.go; Start() now takes no args - Simplify cmd/api/main.go (no DATA_DIR flag) - Drop DBPath, DirPath, PostgresEnabled from models.Conf - Remove migration route, handler, and UI card from the frontend - Remove MigrateFromSQLite() from store.APIClient - Drop modernc.org/sqlite and sqlx from go.mod Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 311d3d1 commit b9207a8

16 files changed

Lines changed: 40 additions & 566 deletions

File tree

.claude/launch.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": "0.0.1",
3+
"configurations": [
4+
{
5+
"name": "ExerciseDiary-Frontend",
6+
"runtimeExecutable": "go",
7+
"runtimeArgs": ["run", "./cmd/frontend/", "-a", "http://localhost:8851", "-p", "8080"],
8+
"port": 8080
9+
}
10+
]
11+
}

cmd/api/main.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
11
package main
22

33
import (
4-
"flag"
5-
"os"
6-
74
_ "time/tzdata"
85

96
"github.com/rwlove/WorkoutDiary/internal/api"
107
)
118

129
func main() {
13-
// DATA_DIR env var sets the data directory; -d flag overrides it.
14-
dataDir := os.Getenv("DATA_DIR")
15-
if dataDir == "" {
16-
dataDir = "/data/WorkoutDiary"
17-
}
18-
flag.StringVar(&dataDir, "d", dataDir, "Path to data directory (overrides DATA_DIR env var)")
19-
flag.Parse()
20-
21-
api.Start(dataDir)
10+
api.Start()
2211
}

go.mod

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ go 1.25.0
55
require (
66
github.com/gin-gonic/gin v1.12.0
77
github.com/google/uuid v1.6.0
8-
github.com/jmoiron/sqlx v1.4.0
8+
github.com/jackc/pgx/v5 v5.9.2
99
github.com/shopspring/decimal v1.4.0
1010
github.com/spf13/viper v1.21.0
1111
golang.org/x/crypto v0.50.0
12-
modernc.org/sqlite v1.50.0
1312
)
1413

1514
require (
1615
github.com/bytedance/gopkg v0.1.4 // indirect
1716
github.com/bytedance/sonic v1.15.1 // indirect
1817
github.com/bytedance/sonic/loader v0.5.1 // indirect
1918
github.com/cloudwego/base64x v0.1.7 // indirect
20-
github.com/dustin/go-humanize v1.0.1 // indirect
2119
github.com/fsnotify/fsnotify v1.10.0 // indirect
2220
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
2321
github.com/gin-contrib/sse v1.1.1 // indirect
@@ -29,19 +27,16 @@ require (
2927
github.com/goccy/go-yaml v1.19.2 // indirect
3028
github.com/jackc/pgpassfile v1.0.0 // indirect
3129
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
32-
github.com/jackc/pgx/v5 v5.9.2 // indirect
3330
github.com/jackc/puddle/v2 v2.2.2 // indirect
3431
github.com/json-iterator/go v1.1.12 // indirect
3532
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
3633
github.com/leodido/go-urn v1.4.0 // indirect
3734
github.com/mattn/go-isatty v0.0.22 // indirect
3835
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
3936
github.com/modern-go/reflect2 v1.0.2 // indirect
40-
github.com/ncruces/go-strftime v1.0.0 // indirect
4137
github.com/pelletier/go-toml/v2 v2.3.0 // indirect
4238
github.com/quic-go/qpack v0.6.0 // indirect
4339
github.com/quic-go/quic-go v0.59.0 // indirect
44-
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
4540
github.com/sagikazarmark/locafero v0.12.0 // indirect
4641
github.com/spf13/afero v1.15.0 // indirect
4742
github.com/spf13/cast v1.10.0 // indirect
@@ -56,9 +51,5 @@ require (
5651
golang.org/x/sync v0.20.0 // indirect
5752
golang.org/x/sys v0.43.0 // indirect
5853
golang.org/x/text v0.36.0 // indirect
59-
golang.org/x/tools v0.44.0 // indirect
6054
google.golang.org/protobuf v1.36.11 // indirect
61-
modernc.org/libc v1.72.1 // indirect
62-
modernc.org/mathutil v1.7.1 // indirect
63-
modernc.org/memory v1.11.0 // indirect
6455
)

go.sum

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
2-
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
31
github.com/bytedance/gopkg v0.1.4 h1:oZnQwnX82KAIWb7033bEwtxvTqXcYMxDBaQxo5JJHWM=
42
github.com/bytedance/gopkg v0.1.4/go.mod h1:v1zWfPm21Fb+OsyXN2VAHdL6TBb2L88anLQgdyje6R4=
53
github.com/bytedance/sonic v1.15.1 h1:nJD5PmM0vY7J8CT6MxoqbVAAMhkSmV2HgRAUrrpLoOw=
@@ -11,8 +9,6 @@ github.com/cloudwego/base64x v0.1.7/go.mod h1:Cu1PV9zfrSf7ET2tIbWbbEy7jO7HHJ13q4
119
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1210
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1311
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
14-
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
15-
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
1612
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
1713
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
1814
github.com/fsnotify/fsnotify v1.10.0 h1:Xx/5Ydg9CeBDX/wi4VJqStNtohYjitZhhlHt4h3St1M=
@@ -31,8 +27,6 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
3127
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
3228
github.com/go-playground/validator/v10 v10.30.2 h1:JiFIMtSSHb2/XBUbWM4i/MpeQm9ZK2xqPNk8vgvu5JQ=
3329
github.com/go-playground/validator/v10 v10.30.2/go.mod h1:mAf2pIOVXjTEBrwUMGKkCWKKPs9NheYGabeB04txQSc=
34-
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
35-
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
3630
github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=
3731
github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
3832
github.com/goccy/go-json v0.10.6 h1:p8HrPJzOakx/mn/bQtjgNjdTcN+/S6FcG2CTtQOrHVU=
@@ -42,12 +36,8 @@ github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7Lk
4236
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
4337
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
4438
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
45-
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
46-
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
4739
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
4840
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
49-
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
50-
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
5141
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
5242
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
5343
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
@@ -56,8 +46,6 @@ github.com/jackc/pgx/v5 v5.9.2 h1:3ZhOzMWnR4yJ+RW1XImIPsD1aNSz4T4fyP7zlQb56hw=
5646
github.com/jackc/pgx/v5 v5.9.2/go.mod h1:mal1tBGAFfLHvZzaYh77YS/eC6IX9OWbRV1QIIM0Jn4=
5747
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
5848
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
59-
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
60-
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
6149
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
6250
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
6351
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
@@ -68,19 +56,13 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
6856
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
6957
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
7058
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
71-
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
72-
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
7359
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
7460
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
75-
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
76-
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
7761
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
7862
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
7963
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
8064
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
8165
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
82-
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
83-
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
8466
github.com/pelletier/go-toml/v2 v2.3.0 h1:k59bC/lIZREW0/iVaQR8nDHxVq8OVlIzYCOJf421CaM=
8567
github.com/pelletier/go-toml/v2 v2.3.0/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
8668
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -89,8 +71,6 @@ github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
8971
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
9072
github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=
9173
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
92-
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
93-
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
9474
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
9575
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
9676
github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88eegjfxfHb4=
@@ -133,8 +113,6 @@ golang.org/x/arch v0.26.0 h1:jZ6dpec5haP/fUv1kLCbuJy6dnRrfX6iVK08lZBFpk4=
133113
golang.org/x/arch v0.26.0/go.mod h1:0X+GdSIP+kL5wPmpK7sdkEVTt2XoYP0cSjQSbZBwOi8=
134114
golang.org/x/crypto v0.50.0 h1:zO47/JPrL6vsNkINmLoo/PH1gcxpls50DNogFvB5ZGI=
135115
golang.org/x/crypto v0.50.0/go.mod h1:3muZ7vA7PBCE6xgPX7nkzzjiUq87kRItoJQM1Yo8S+Q=
136-
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
137-
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
138116
golang.org/x/net v0.53.0 h1:d+qAbo5L0orcWAr0a9JweQpjXF19LMXJE8Ey7hwOdUA=
139117
golang.org/x/net v0.53.0/go.mod h1:JvMuJH7rrdiCfbeHoo3fCQU24Lf5JJwT9W3sJFulfgs=
140118
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
@@ -143,8 +121,6 @@ golang.org/x/sys v0.43.0 h1:Rlag2XtaFTxp19wS8MXlJwTvoh8ArU6ezoyFsMyCTNI=
143121
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
144122
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
145123
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
146-
golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c=
147-
golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI=
148124
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
149125
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
150126
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -153,31 +129,3 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV
153129
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
154130
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
155131
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
156-
modernc.org/cc/v4 v4.28.1 h1:XpLbkYVQ24E8tX5u8+yWGvaxerxkR/S4zqxI8ZoSBuc=
157-
modernc.org/cc/v4 v4.28.1/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=
158-
modernc.org/ccgo/v4 v4.33.0 h1:dspBCm75jsj8Y/ufwAMVfe375L2iYdMyQ2QG/v3hL54=
159-
modernc.org/ccgo/v4 v4.33.0/go.mod h1:+RhXBoRYzRwaH21mV/aj6XvQRDtfjcZfAlPMsQo8CR0=
160-
modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM=
161-
modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU=
162-
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
163-
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
164-
modernc.org/gc/v3 v3.1.2 h1:ZtDCnhonXSZexk/AYsegNRV1lJGgaNZJuKjJSWKyEqo=
165-
modernc.org/gc/v3 v3.1.2/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=
166-
modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=
167-
modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=
168-
modernc.org/libc v1.72.1 h1:db1xwJ6u1kE3KHTFTTbe2GCrczHPKzlURP0aDC4NGD0=
169-
modernc.org/libc v1.72.1/go.mod h1:HRMiC/PhPGLIPM7GzAFCbI+oSgE3dhZ8FWftmRrHVlY=
170-
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
171-
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
172-
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
173-
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
174-
modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=
175-
modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
176-
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
177-
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
178-
modernc.org/sqlite v1.50.0 h1:eMowQSWLK0MeiQTdmz3lqoF5dqclujdlIKeJA11+7oM=
179-
modernc.org/sqlite v1.50.0/go.mod h1:m0w8xhwYUVY3H6pSDwc3gkJ/irZT/0YEXwBlhaxQEew=
180-
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
181-
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
182-
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
183-
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=

internal/api/server.go

Lines changed: 17 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ import (
88

99
"github.com/gin-gonic/gin"
1010
"github.com/rwlove/WorkoutDiary/internal/auth"
11-
"github.com/rwlove/WorkoutDiary/internal/check"
1211
"github.com/rwlove/WorkoutDiary/internal/conf"
1312
"github.com/rwlove/WorkoutDiary/internal/db"
14-
"github.com/rwlove/WorkoutDiary/internal/migrate"
1513
"github.com/rwlove/WorkoutDiary/internal/models"
1614
"github.com/rwlove/WorkoutDiary/internal/store"
1715
)
@@ -22,11 +20,10 @@ var (
2220
dataStore store.Store
2321
)
2422

25-
// Start initialises the database, reads config from environment variables,
26-
// and begins serving the JSON API.
23+
// Start reads config from environment variables and begins serving the JSON API.
24+
// POSTGRES_DSN is required.
2725
//
28-
// dataDir is the only required parameter — it sets where the SQLite database
29-
// lives. All other settings (port, API key, theme, auth, …) are read from
26+
// All other settings (port, API key, theme, auth, …) are read from
3027
// environment variables:
3128
//
3229
// PORT listen port (default: 8851)
@@ -40,32 +37,23 @@ var (
4037
// AUTH_USER username (default: "")
4138
// AUTH_PASSWORD bcrypt password (default: "")
4239
// AUTH_EXPIRE session expiry (default: 7d)
43-
func Start(dataDir string) {
40+
func Start() {
4441
appConfig, authConf = conf.GetFromEnv()
45-
appConfig.DirPath = dataDir
46-
appConfig.DBPath = dataDir + "/sqlite.db"
47-
// ConfPath left empty — Settings changes are in-memory only in env-var mode.
48-
check.Path(appConfig.DBPath)
4942

5043
apiKey := os.Getenv("API_KEY")
5144
postgresDSN := os.Getenv("POSTGRES_DSN")
45+
if postgresDSN == "" {
46+
log.Fatal("ERROR: POSTGRES_DSN environment variable is required")
47+
}
5248

53-
if postgresDSN != "" {
54-
log.Println("INFO: starting API server with PostgreSQL backend")
55-
pgStore, err := store.NewPostgres(postgresDSN)
56-
if err != nil {
57-
log.Fatalf("ERROR: connect to postgres: %v", err)
58-
}
59-
if err := db.MigratePostgres(pgStore.Pool()); err != nil {
60-
log.Fatalf("ERROR: postgres schema migration: %v", err)
61-
}
62-
dataStore = pgStore
63-
appConfig.PostgresEnabled = true
64-
} else {
65-
log.Println("INFO: starting API server with SQLite backend, db =", appConfig.DBPath)
66-
db.Create(appConfig.DBPath)
67-
dataStore = store.NewSQLite(appConfig.DBPath)
49+
pgStore, err := store.NewPostgres(postgresDSN)
50+
if err != nil {
51+
log.Fatalf("ERROR: connect to postgres: %v", err)
52+
}
53+
if err := db.MigratePostgres(pgStore.Pool()); err != nil {
54+
log.Fatalf("ERROR: postgres schema migration: %v", err)
6855
}
56+
dataStore = pgStore
6957

7058
gin.SetMode(gin.ReleaseMode)
7159
r := gin.Default()
@@ -95,17 +83,14 @@ func Start(dataDir string) {
9583
r.PUT("/api/config", putConfig)
9684
r.PUT("/api/config/auth", putConfigAuth)
9785

98-
// Migration (only registered when PostgreSQL is active)
99-
if appConfig.PostgresEnabled {
100-
r.POST("/api/migrate/sqlite-to-postgres", migrateFromSQLite)
101-
}
102-
10386
address := appConfig.Host + ":" + appConfig.Port
10487
log.Println("=================================== ")
10588
log.Printf("API server at http://%s", address)
10689
log.Println("=================================== ")
10790

108-
check.IfError(r.Run(address))
91+
if err := r.Run(address); err != nil {
92+
log.Fatalf("ERROR: server failed: %v", err)
93+
}
10994
}
11095

11196
// ─── middleware ───────────────────────────────────────────────────────────────
@@ -264,22 +249,6 @@ func putConfig(c *gin.Context) {
264249
c.Status(http.StatusOK)
265250
}
266251

267-
// ─── migration ────────────────────────────────────────────────────────────────
268-
269-
func migrateFromSQLite(c *gin.Context) {
270-
pgStore, ok := dataStore.(*store.PostgresStore)
271-
if !ok {
272-
c.JSON(http.StatusBadRequest, gin.H{"error": "not using postgres store"})
273-
return
274-
}
275-
result, err := migrate.SQLiteToPostgres(appConfig.DBPath, pgStore)
276-
if err != nil {
277-
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
278-
return
279-
}
280-
c.JSON(http.StatusOK, result)
281-
}
282-
283252
func putConfigAuth(c *gin.Context) {
284253
var body struct {
285254
User string `json:"user"`
@@ -307,4 +276,3 @@ func putConfigAuth(c *gin.Context) {
307276
conf.Write(appConfig, authConf)
308277
c.Status(http.StatusOK)
309278
}
310-

internal/db/bulk.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)