Skip to content

Commit 540205c

Browse files
committed
Logo is optional
1 parent 01657a8 commit 540205c

File tree

11 files changed

+68
-56
lines changed

11 files changed

+68
-56
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- +goose Up
2+
-- Make logo_url nullable in projects table
3+
ALTER TABLE projects ALTER COLUMN logo_url DROP NOT NULL;
4+
5+
-- +goose Down
6+
-- Revert logo_url to NOT NULL (note: this will fail if there are NULL values)
7+
ALTER TABLE projects ALTER COLUMN logo_url SET NOT NULL;

backend/internal/database/queries/projects.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ VALUES (
7979
@description::text,
8080
@startdate::timestamptz,
8181
@enddate::timestamptz,
82-
@logourl::text,
82+
sqlc.narg('logourl')::text,
8383
@colorprimary::text,
8484
@colorsecondary::text,
8585
@colortertiary::text,
@@ -91,10 +91,10 @@ RETURNING id, name, description, start_date, end_date, logo_url, color_primary,
9191
UPDATE projects
9292
SET
9393
name = COALESCE(@name::text, name),
94-
description = COALESCE(@description::text, description),
94+
description = COALESCE(sqlc.narg('description')::text, description),
9595
start_date = COALESCE(@startdate::timestamptz, start_date),
9696
end_date = COALESCE(@enddate::timestamptz, end_date),
97-
logo_url = COALESCE(@logourl::text, logo_url),
97+
logo_url = COALESCE(sqlc.narg('logourl')::text, logo_url),
9898
color_primary = COALESCE(@colorprimary::text, color_primary),
9999
color_secondary = COALESCE(@colorsecondary::text, color_secondary),
100100
color_tertiary = COALESCE(@colortertiary::text, color_tertiary),

backend/internal/database/sqlc/models.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/internal/database/sqlc/projects.sql.go

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/internal/graph/api/generated.go

Lines changed: 5 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/internal/graph/api/model/models_gen.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/internal/graph/api/schema.resolvers.go

Lines changed: 24 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/internal/loaders/project_by_id.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,19 @@ func projectByIDBatchFunc(db *database.DB, c *cache.CacheWithRegistry) func(cont
4343

4444
// Convert to GraphQL model and populate cache
4545
for _, row := range rows {
46+
var logo *string
47+
if row.LogoUrl != nil {
48+
logo = row.LogoUrl
49+
}
50+
4651
project := &model.Project{
4752
ID: row.ID,
4853
Name: row.Name,
4954
Description: row.Description,
5055
StartDate: scalars.DateTime{Time: row.StartDate.Time},
5156
EndDate: scalars.DateTime{Time: row.EndDate.Time},
5257
Branding: &model.Branding{
53-
Logo: row.LogoUrl,
58+
Logo: logo,
5459
Colors: &model.Colors{
5560
Primary: row.ColorPrimary,
5661
Secondary: row.ColorSecondary,

backend/internal/loaders/projects_by_user.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,19 @@ func projectsByUserBatchFunc(db *database.DB, c *cache.CacheWithRegistry) func(c
4141

4242
// Group projects by user ID and convert to GraphQL model
4343
for _, row := range rows {
44+
var logo *string
45+
if row.LogoUrl != nil {
46+
logo = row.LogoUrl
47+
}
48+
4449
project := &model.Project{
4550
ID: row.ID,
4651
Name: row.Name,
4752
Description: row.Description,
4853
StartDate: scalars.DateTime{Time: row.StartDate.Time},
4954
EndDate: scalars.DateTime{Time: row.EndDate.Time},
5055
Branding: &model.Branding{
51-
Logo: row.LogoUrl,
56+
Logo: logo,
5257
Colors: &model.Colors{
5358
Primary: row.ColorPrimary,
5459
Secondary: row.ColorSecondary,

gql/shared.graphqls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ type Track {
7676
}
7777

7878
type Branding {
79-
logo: String!
79+
logo: String
8080
colors: Colors!
8181
rounding: Int! # border-radius in pixels
8282
}
@@ -326,7 +326,7 @@ input AgeRangeInput {
326326
}
327327

328328
input BrandingInput {
329-
logo: String!
329+
logo: String
330330
colors: ColorsInput!
331331
rounding: Int!
332332
}

0 commit comments

Comments
 (0)