Skip to content

Commit 9bcff30

Browse files
authored
fix(coderd/database): migrate workspaces.last_used_at to timestamptz (#9699)
1 parent 1f5eb08 commit 9bcff30

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

coderd/database/dump.sql

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ALTER TABLE ONLY workspaces
2+
ALTER COLUMN last_used_at
3+
SET DATA TYPE timestamp
4+
USING last_used_at::timestamptz AT TIME ZONE 'UTC',
5+
ALTER COLUMN last_used_at
6+
SET DEFAULT '0001-01-01 00:00:00'::timestamp;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ALTER TABLE ONLY workspaces
2+
ALTER COLUMN last_used_at
3+
SET DATA TYPE timestamptz
4+
USING last_used_at::timestamp AT TIME ZONE 'UTC',
5+
ALTER COLUMN last_used_at
6+
SET DEFAULT '0001-01-01 00:00:00+00:00'::timestamptz;

coderd/workspaces_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,12 +1515,8 @@ func TestWorkspaceFilterManual(t *testing.T) {
15151515
t.Run("LastUsed", func(t *testing.T) {
15161516
t.Parallel()
15171517

1518-
// nolint:gocritic // https://github.com/coder/coder/issues/9682
1519-
db, ps := dbtestutil.NewDB(t, dbtestutil.WithTimezone("UTC"))
15201518
client, _, api := coderdtest.NewWithAPI(t, &coderdtest.Options{
15211519
IncludeProvisionerDaemon: true,
1522-
Database: db,
1523-
Pubsub: ps,
15241520
})
15251521
user := coderdtest.CreateFirstUser(t, client)
15261522
authToken := uuid.NewString()

enterprise/coderd/templates_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/coder/coder/v2/coderd/audit"
1414
"github.com/coder/coder/v2/coderd/coderdtest"
1515
"github.com/coder/coder/v2/coderd/database"
16-
"github.com/coder/coder/v2/coderd/database/dbtestutil"
1716
"github.com/coder/coder/v2/coderd/rbac"
1817
"github.com/coder/coder/v2/codersdk"
1918
"github.com/coder/coder/v2/cryptorand"
@@ -369,14 +368,10 @@ func TestTemplates(t *testing.T) {
369368
t.Run("UpdateLastUsedAt", func(t *testing.T) {
370369
t.Parallel()
371370

372-
// nolint:gocritic // https://github.com/coder/coder/issues/9682
373-
db, ps := dbtestutil.NewDB(t, dbtestutil.WithTimezone("UTC"))
374371
ctx := testutil.Context(t, testutil.WaitMedium)
375372
client, user := coderdenttest.New(t, &coderdenttest.Options{
376373
Options: &coderdtest.Options{
377374
IncludeProvisionerDaemon: true,
378-
Database: db,
379-
Pubsub: ps,
380375
},
381376
LicenseOptions: &coderdenttest.LicenseOptions{
382377
Features: license.Features{

0 commit comments

Comments
 (0)