Skip to content

Commit f619401

Browse files
committed
Make project screenshot assets NOT NULL
1 parent 4691421 commit f619401

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package migrations
2+
3+
import (
4+
"context"
5+
"time"
6+
7+
"git.handmade.network/hmn/hmn/src/migration/types"
8+
"github.com/jackc/pgx/v5"
9+
)
10+
11+
func init() {
12+
registerMigration(NonNullProjectScreenshots{})
13+
}
14+
15+
type NonNullProjectScreenshots struct{}
16+
17+
func (m NonNullProjectScreenshots) Version() types.MigrationVersion {
18+
return types.MigrationVersion(time.Date(2026, 7, 25, 14, 11, 6, 0, time.UTC))
19+
}
20+
21+
func (m NonNullProjectScreenshots) Name() string {
22+
return "NonNullProjectScreenshots"
23+
}
24+
25+
func (m NonNullProjectScreenshots) Description() string {
26+
return "Make the asset column on project screenshots NOT NULL"
27+
}
28+
29+
func (m NonNullProjectScreenshots) Up(ctx context.Context, tx pgx.Tx) error {
30+
_, err := tx.Exec(ctx,
31+
`
32+
ALTER TABLE project_screenshot
33+
ALTER COLUMN asset_id SET NOT NULL;
34+
`,
35+
)
36+
return err
37+
}
38+
39+
func (m NonNullProjectScreenshots) Down(ctx context.Context, tx pgx.Tx) error {
40+
_, err := tx.Exec(ctx,
41+
`
42+
ALTER TABLE project_screenshot
43+
ALTER COLUMN asset_id DROP NOT NULL;
44+
`,
45+
)
46+
return err
47+
}

0 commit comments

Comments
 (0)