-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
200 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- +goose Up | ||
CREATE TABLE users( | ||
id INTEGER PRIMARY KEY, | ||
created_at TIMESTAMP NOT NULL, | ||
updated_at TIMESTAMP NOT NULL | ||
); | ||
|
||
CREATE TABLE user_job_postings( | ||
created_at TIMESTAMP NOT NULL, | ||
user_id INTEGER NOT NULL, | ||
position TEXT NOT NULL, | ||
company_id TEXT NOT NULL, | ||
FOREIGN KEY (user_id) REFERENCES users(id), | ||
FOREIGN KEY (position) REFERENCES job_postings(position), | ||
FOREIGN KEY (company_id) REFERENCES job_postings(company_id) | ||
); | ||
|
||
-- +goose Down | ||
DROP TABLE users; | ||
DROP TABLE user_job_postings; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- name: CreateUserJobPosting :exec | ||
INSERT INTO user_job_postings (created_at, user_id, position, company_id) | ||
VALUES (CURRENT_TIMESTAMP, ?, ?, ?); | ||
|
||
-- name: GetUserJobPostings :many | ||
SELECT job_postings.position, job_postings.url as job_posting_url, companies.name as company_name, last_posted, companies.avatar as company_avatar | ||
FROM user_job_postings | ||
JOIN companies on job_postings.company_id = companies.id | ||
JOIN job_postings on user_job_postings.position = job_postings.position AND user_job_postings.company_id = job_postings.company_id | ||
WHERE user_job_postings.user_id = ? | ||
ORDER BY job_postings.last_posted DESC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- name: CreateUser :exec | ||
INSERT INTO users (created_at, updated_at) | ||
VALUES (CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); | ||
|
||
-- name: GetUser :one | ||
SELECT * FROM users WHERE id = ?; |