Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: allow for default presets #18445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: database changes
Signed-off-by: Danny Kopping <[email protected]>
  • Loading branch information
dannykopping committed Jun 18, 2025
commit 89da41b03473dd40a95380ef4fccbb53cbdaafdd
1 change: 0 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,4 @@ Read [cursor rules](.cursorrules).

The frontend is contained in the site folder.

For building Frontend refer to [this document](docs/contributing/frontend.md)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by: link is dead.

Copy link
Member

@aslilac aslilac Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's in docs/about/contributing/ now. can you leave this as is and I'll do a quick pr to fix the link?

sorry, I just looked at the whole file and this diff makes more sense now. the line got duplicated, with one having the out of date path and one having the correct path. you're just removing the stale one.

For building Frontend refer to [this document](docs/about/contributing/frontend.md)
1 change: 1 addition & 0 deletions coderd/database/dbfake/dbfake.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ func (t TemplateVersionBuilder) Do() TemplateVersionResponse {
CreatedAt: version.CreatedAt,
DesiredInstances: preset.DesiredInstances,
InvalidateAfterSecs: preset.InvalidateAfterSecs,
IsDefault: false,
})
}

Expand Down
1 change: 1 addition & 0 deletions coderd/database/dbgen/dbgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,7 @@ func Preset(t testing.TB, db database.Store, seed database.InsertPresetParams) d
CreatedAt: takeFirst(seed.CreatedAt, dbtime.Now()),
DesiredInstances: seed.DesiredInstances,
InvalidateAfterSecs: seed.InvalidateAfterSecs,
IsDefault: seed.IsDefault,
})
require.NoError(t, err, "insert preset")
return preset
Expand Down
5 changes: 4 additions & 1 deletion coderd/database/dump.sql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DROP INDEX IF EXISTS idx_template_version_presets_default;
ALTER TABLE template_version_presets DROP COLUMN IF EXISTS is_default;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obligatory reminder to check migration number before merge

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALTER TABLE template_version_presets ADD COLUMN is_default BOOLEAN NOT NULL DEFAULT FALSE;

-- Add a unique constraint to ensure only one default preset per template version
CREATE UNIQUE INDEX idx_template_version_presets_default
ON template_version_presets (template_version_id)
WHERE is_default = TRUE;
1 change: 1 addition & 0 deletions coderd/database/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions coderd/database/queries/presets.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ INSERT INTO template_version_presets (
name,
created_at,
desired_instances,
invalidate_after_secs
invalidate_after_secs,
is_default
)
VALUES (
@id,
@template_version_id,
@name,
@created_at,
@desired_instances,
@invalidate_after_secs
@invalidate_after_secs,
@is_default
) RETURNING *;

-- name: InsertPresetParameters :many
Expand Down Expand Up @@ -69,3 +71,4 @@ SELECT tvp.*, tv.template_id, tv.organization_id FROM
template_version_presets tvp
INNER JOIN template_versions tv ON tvp.template_version_id = tv.id
WHERE tvp.id = @preset_id;

1 change: 1 addition & 0 deletions coderd/database/unique_constraint.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.