Skip to content

Commit

Permalink
pkg/database: add query field to the nars table (#102)
Browse files Browse the repository at this point in the history
Add query column to nars table

- Add `query` column to nars table
- Quote reserved keyword `query` in SQL statements
- Update database models and queries to support new column
  • Loading branch information
kalbasit authored Dec 13, 2024
1 parent 29da605 commit e8b3d97
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 38 deletions.
6 changes: 6 additions & 0 deletions db/migrations/20241213014846_add-query-to-nars-table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- migrate:up
ALTER TABLE nars ADD COLUMN `query` TEXT NOT NULL DEFAULT '';


-- migrate:down
ALTER TABLE nars DROP COLUMN `query`;
4 changes: 2 additions & 2 deletions db/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ RETURNING *;

-- name: CreateNar :one
INSERT INTO nars (
narinfo_id, hash, compression, file_size
narinfo_id, hash, compression, `query`, file_size
) VALUES (
?, ?, ?, ?
?, ?, ?, ?, ?
)
RETURNING *;

Expand Down
1 change: 1 addition & 0 deletions pkg/database/models.go

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

80 changes: 44 additions & 36 deletions pkg/database/query.sql.go

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

0 comments on commit e8b3d97

Please sign in to comment.