Skip to content

Commit dcc1d36

Browse files
feat: use time.Time for timestamps; use timestamp with TZ
1 parent 77314dd commit dcc1d36

16 files changed

+103
-89
lines changed

.envrc.local

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
if use flake; then
1+
if nix flake show &> /dev/null; then
22
use flake
33
fi
44

5+
# test variables
56
CONDUIT_DATABASE_URL="postgresql://local:local@localhost:5432/local?sslmode=disable"
6-
CONDUIT_MIGRATION_DIR="migrations"
7+
CONDUIT_MIGRATION_DIR="internal/migrations"

go.mod

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
module go.inout.gg/shield
22

3-
go 1.23.1
3+
go 1.23.2
44

55
require (
66
github.com/coreos/go-oidc/v3 v3.12.0
77
github.com/go-playground/mold/v4 v4.5.1
8-
github.com/go-playground/validator/v10 v10.24.0
9-
github.com/go-webauthn/webauthn v0.11.2
8+
github.com/go-playground/validator/v10 v10.25.0
9+
github.com/go-webauthn/webauthn v0.12.1
1010
github.com/golang-jwt/jwt/v5 v5.2.1
1111
github.com/google/uuid v1.6.0
1212
github.com/jackc/pgx/v5 v5.7.2
1313
github.com/joho/godotenv v1.5.1
1414
github.com/stretchr/testify v1.10.0
1515
go.inout.gg/conduit v0.0.0-20241026233153-c576e2d3127b
16-
go.inout.gg/foundations v0.0.0-20250205123612-530692516766
17-
golang.org/x/crypto v0.32.0
18-
golang.org/x/oauth2 v0.26.0
16+
go.inout.gg/foundations v0.0.0-20250224230405-eb5de94dbf2e
17+
golang.org/x/crypto v0.35.0
18+
golang.org/x/oauth2 v0.27.0
1919
golang.org/x/text v0.22.0
2020
)
2121

@@ -28,8 +28,8 @@ require (
2828
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
2929
github.com/go-playground/locales v0.14.1 // indirect
3030
github.com/go-playground/universal-translator v0.18.1 // indirect
31-
github.com/go-webauthn/x v0.1.14 // indirect
32-
github.com/google/go-tpm v0.9.1 // indirect
31+
github.com/go-webauthn/x v0.1.18 // indirect
32+
github.com/google/go-tpm v0.9.3 // indirect
3333
github.com/gosimple/slug v1.15.0 // indirect
3434
github.com/gosimple/unidecode v1.0.1 // indirect
3535
github.com/jackc/pgpassfile v1.0.0 // indirect
@@ -39,7 +39,7 @@ require (
3939
github.com/leodido/go-urn v1.4.0 // indirect
4040
github.com/mitchellh/mapstructure v1.5.0 // indirect
4141
github.com/pmezard/go-difflib v1.0.0 // indirect
42-
github.com/rogpeppe/go-internal v1.13.1 // indirect
42+
github.com/rogpeppe/go-internal v1.14.1 // indirect
4343
github.com/russross/blackfriday/v2 v2.1.0 // indirect
4444
github.com/segmentio/go-camelcase v0.0.0-20160726192923-7085f1e3c734 // indirect
4545
github.com/segmentio/go-snakecase v1.2.0 // indirect
@@ -48,6 +48,6 @@ require (
4848
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
4949
golang.org/x/net v0.34.0 // indirect
5050
golang.org/x/sync v0.11.0 // indirect
51-
golang.org/x/sys v0.29.0 // indirect
51+
golang.org/x/sys v0.30.0 // indirect
5252
gopkg.in/yaml.v3 v3.0.1 // indirect
5353
)

go.sum

+18-18
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ github.com/go-playground/mold/v4 v4.5.1 h1:jenr15aZVqnarO/9t9coOyhVKp6RGHyK4kBsE
2222
github.com/go-playground/mold/v4 v4.5.1/go.mod h1:/+Bq5O2PKkSVSQV4YUXVZPqiqw4kLv5s2uFPt7TVBFI=
2323
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
2424
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
25-
github.com/go-playground/validator/v10 v10.24.0 h1:KHQckvo8G6hlWnrPX4NJJ+aBfWNAE/HH+qdL2cBpCmg=
26-
github.com/go-playground/validator/v10 v10.24.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
27-
github.com/go-webauthn/webauthn v0.11.2 h1:Fgx0/wlmkClTKlnOsdOQ+K5HcHDsDcYIvtYmfhEOSUc=
28-
github.com/go-webauthn/webauthn v0.11.2/go.mod h1:aOtudaF94pM71g3jRwTYYwQTG1KyTILTcZqN1srkmD0=
29-
github.com/go-webauthn/x v0.1.14 h1:1wrB8jzXAofojJPAaRxnZhRgagvLGnLjhCAwg3kTpT0=
30-
github.com/go-webauthn/x v0.1.14/go.mod h1:UuVvFZ8/NbOnkDz3y1NaxtUN87pmtpC1PQ+/5BBQRdc=
25+
github.com/go-playground/validator/v10 v10.25.0 h1:5Dh7cjvzR7BRZadnsVOzPhWsrwUr0nmsZJxEAnFLNO8=
26+
github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus=
27+
github.com/go-webauthn/webauthn v0.12.1 h1:fQNKWc+gd7i1TW8FmlB0jQTHyc2GYYlV/QdLUxo+MSA=
28+
github.com/go-webauthn/webauthn v0.12.1/go.mod h1:Q13xKHZi459wU8IoFjm8jQ6CMRyad+kegblwMFFhQGU=
29+
github.com/go-webauthn/x v0.1.18 h1:9xxiKRKCHx/1R2RF+4xb1qY5QDIO0RlTmH5L02lmRH4=
30+
github.com/go-webauthn/x v0.1.18/go.mod h1:Q/uHdGGFrZ7psEcoEStYunurZuG3Z9UDZJetM8qDTtA=
3131
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
3232
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
3333
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
3434
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
35-
github.com/google/go-tpm v0.9.1 h1:0pGc4X//bAlmZzMKf8iz6IsDo1nYTbYJ6FZN/rg4zdM=
36-
github.com/google/go-tpm v0.9.1/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
35+
github.com/google/go-tpm v0.9.3 h1:+yx0/anQuGzi+ssRqeD6WpXjW2L/V0dItUayO0i9sRc=
36+
github.com/google/go-tpm v0.9.3/go.mod h1:h9jEsEECg7gtLis0upRBQU+GhYVH6jMjrFxI8u6bVUY=
3737
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
3838
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
3939
github.com/gosimple/slug v1.15.0 h1:wRZHsRrRcs6b0XnxMUBM6WK1U1Vg5B0R7VkIf1Xzobo=
@@ -60,8 +60,8 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
6060
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
6161
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6262
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
63-
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
64-
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
63+
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
64+
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
6565
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
6666
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
6767
github.com/segmentio/go-camelcase v0.0.0-20160726192923-7085f1e3c734 h1:Cpx2WLIv6fuPvaJAHNhYOgYzk/8RcJXu/8+mOrxf2KM=
@@ -81,18 +81,18 @@ github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGC
8181
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
8282
go.inout.gg/conduit v0.0.0-20241026233153-c576e2d3127b h1:AUCafWPnbB5tLJh2D9k81jl+iyQnfTQS2bLrr27IKfY=
8383
go.inout.gg/conduit v0.0.0-20241026233153-c576e2d3127b/go.mod h1:qEwpFTi4ynxp2ad6/bFfWdyiZmWcO7+m+XVm+hO/+oI=
84-
go.inout.gg/foundations v0.0.0-20250205123612-530692516766 h1:diUD96xM4ImxOSkVXXhLKwtTzf5WDxW6Qcj24oOgrqY=
85-
go.inout.gg/foundations v0.0.0-20250205123612-530692516766/go.mod h1:erNmFIJahxlOFPU4RJW4WMFgSmjhcFdFkvSE5Iz6b7M=
86-
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
87-
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
84+
go.inout.gg/foundations v0.0.0-20250224230405-eb5de94dbf2e h1:0bCCojxIfx9OVUF+7AhjdJJ+mWFMKo7JY8f4qdxAm30=
85+
go.inout.gg/foundations v0.0.0-20250224230405-eb5de94dbf2e/go.mod h1:erNmFIJahxlOFPU4RJW4WMFgSmjhcFdFkvSE5Iz6b7M=
86+
golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
87+
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
8888
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
8989
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
90-
golang.org/x/oauth2 v0.26.0 h1:afQXWNNaeC4nvZ0Ed9XvCCzXM6UHJG7iCg0W4fPqSBE=
91-
golang.org/x/oauth2 v0.26.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
90+
golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
91+
golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
9292
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
9393
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
94-
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
95-
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
94+
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
95+
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
9696
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
9797
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
9898
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

internal/dbsqlc/models.go

+17-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/dbsqlc/passkey_query.sql.go

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/dbsqlc/password_query.sql.go

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/dbsqlc/session_query.sql.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

internal/dbsqlc/query.sql.go internal/dbsqlc/user_query.sql.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/migrations/1726951117573_initial_schema.sql

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
CREATE TABLE IF NOT EXISTS shield_users (
44
id UUID NOT NULL,
5-
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
6-
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
5+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
6+
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
77
email VARCHAR(255) NOT NULL,
88
is_email_verified BOOLEAN NOT NULL DEFAULT FALSE,
99
PRIMARY KEY (id),
@@ -12,8 +12,8 @@ CREATE TABLE IF NOT EXISTS shield_users (
1212

1313
CREATE TABLE IF NOT EXISTS shield_user_email_verification_tokens (
1414
id UUID NOT NULL,
15-
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
16-
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
15+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
16+
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
1717
is_used BOOLEAN NOT NULL DEFAULT FALSE,
1818
token VARCHAR(16) NOT NULL,
1919
email VARCHAR(255) NOT NULL,
@@ -27,8 +27,8 @@ CREATE TABLE IF NOT EXISTS shield_user_email_verification_tokens (
2727

2828
CREATE TABLE IF NOT EXISTS shield_user_credentials (
2929
id UUID NOT NULL,
30-
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
31-
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
30+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
31+
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
3232
name VARCHAR(255) NOT NULL,
3333
user_id UUID NOT NULL,
3434
user_credential_key VARCHAR(255) NOT NULL, -- can be SSO user ID, email, etc.
@@ -42,11 +42,11 @@ CREATE TABLE IF NOT EXISTS shield_user_credentials (
4242

4343
CREATE TABLE IF NOT EXISTS shield_password_reset_tokens (
4444
id UUID NOT NULL,
45-
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
46-
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
45+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
46+
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
4747
is_used BOOLEAN NOT NULL DEFAULT FALSE,
4848
token VARCHAR(16) NOT NULL,
49-
expires_at TIMESTAMP NOT NULL,
49+
expires_at TIMESTAMP WITH TIME ZONE NOT NULL,
5050
user_id UUID NOT NULL,
5151
PRIMARY KEY (user_id, id),
5252
UNIQUE (token),
@@ -59,9 +59,9 @@ CREATE TABLE IF NOT EXISTS shield_password_reset_tokens (
5959

6060
CREATE TABLE IF NOT EXISTS shield_user_sessions (
6161
id UUID NOT NULL,
62-
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
63-
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
64-
expires_at TIMESTAMP NOT NULL,
62+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
63+
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
64+
expires_at TIMESTAMP WITH TIME ZONE NOT NULL,
6565
user_id UUID NOT NULL,
6666
evicted_by UUID NULL,
6767
PRIMARY KEY (user_id, id),

internal/migrations/1731842623024_recovery_code.sql

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
CREATE TABLE IF NOT EXISTS shield_recovery_codes (
44
id UUID NOT NULL,
5-
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
6-
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
5+
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
6+
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
77
user_id UUID NOT NULL,
88
recovery_code_hash VARCHAR(4095) NOT NULL,
99
is_consumable BOOL NOT NULL DEFAULT TRUE,
1010
evicted_by UUID NULL,
11-
evicted_at TIMESTAMP NULL DEFAULT NULL,
11+
evicted_at TIMESTAMP WITH TIME ZONE NULL DEFAULT NULL,
1212
PRIMARY KEY (id),
1313
FOREIGN KEY (user_id) REFERENCES shield_users (id)
1414
ON DELETE CASCADE,

0 commit comments

Comments
 (0)