Skip to content
This repository has been archived by the owner on Jan 25, 2025. It is now read-only.

Commit

Permalink
Refactor database schema to include ExhibitionReviewLog table
Browse files Browse the repository at this point in the history
  • Loading branch information
tahirmurata committed Sep 25, 2024
1 parent 49a3f44 commit b6cd648
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
10 changes: 10 additions & 0 deletions internal/sqlc/models.go

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

19 changes: 11 additions & 8 deletions internal/sqlc/query.sql.go

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

6 changes: 3 additions & 3 deletions sql/query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ ORDER BY id DESC
LIMIT 10;
-- name: UpdateFoodStallLog :exec
UPDATE food_stall_logs
SET quantity = $1,
food_id = $2,
SET quantity = $2,
food_id = $3,
updated_at = now()
WHERE id = $3;
WHERE id = $1;
-- name: CountEntryLogByNodeId :one
SELECT COUNT(*)
FROM entry_logs
Expand Down
12 changes: 12 additions & 0 deletions sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CREATE TABLE nodes (
name TEXT NOT NULL,
ip INET UNIQUE,
type node_type NOT NULL,
is_review BOOLEAN DEFAULT FALSE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Expand Down Expand Up @@ -93,6 +94,17 @@ CREATE TABLE exhibition_logs (
FOREIGN KEY (node_id) REFERENCES nodes(id),
FOREIGN KEY (visitor_id) REFERENCES visitors(id)
);
-- ExhibitionReviewLog table
CREATE TABLE exhibition_review_logs (
id BIGSERIAL PRIMARY KEY,
node_id BIGINT,
visitor_id BIGINT,
rating INTEGER NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (node_id) REFERENCES nodes(id),
FOREIGN KEY (visitor_id) REFERENCES visitors(id)
);
-- Create indexes
CREATE INDEX idx_nodes_key ON nodes (key);
CREATE INDEX idx_visitors_id ON visitors (id);
Expand Down

0 comments on commit b6cd648

Please sign in to comment.