-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: postgres datastore implementation - part 2 (#205)
Signed-off-by: Michal Fiedorowicz <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Luke Tucker <[email protected]>
- Loading branch information
1 parent
3b38a6a
commit 3f46f8a
Showing
33 changed files
with
1,432 additions
and
1,500 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
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
-- name: CreateChangeSet :one | ||
|
||
INSERT INTO change_sets (change_set_ksuid, ingestion_log_id, branch_name) | ||
INSERT INTO change_sets (external_id, ingestion_log_id, branch_id) | ||
VALUES ($1, $2, $3) | ||
RETURNING *; | ||
|
||
-- name: CreateChange :one | ||
|
||
INSERT INTO changes (change_ksuid, change_set_id, change_type, object_type, object_id, object_version, data, | ||
INSERT INTO changes (external_id, change_set_id, change_type, object_type, object_id, object_version, data, | ||
sequence_number) | ||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8) | ||
RETURNING *; |
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 |
---|---|---|
@@ -1,4 +1,39 @@ | ||
-- name: CreateIngestionLog :one | ||
INSERT INTO ingestion_logs (ingestion_log_ksuid, data_type, state, request_id, ingestion_ts, producer_app_name, | ||
INSERT INTO ingestion_logs (external_id, data_type, state, request_id, ingestion_ts, producer_app_name, | ||
producer_app_version, sdk_name, sdk_version, entity, source_metadata) | ||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING *; | ||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) | ||
RETURNING *; | ||
|
||
-- name: UpdateIngestionLogStateWithError :exec | ||
UPDATE ingestion_logs | ||
SET state = $2, | ||
error = $3 | ||
WHERE id = $1 | ||
RETURNING *; | ||
|
||
-- name: CountIngestionLogsPerState :many | ||
SELECT state, COUNT(*) AS count | ||
FROM ingestion_logs | ||
GROUP BY state; | ||
|
||
-- name: RetrieveIngestionLogs :many | ||
SELECT * | ||
FROM ingestion_logs | ||
WHERE (state = sqlc.narg('state') OR sqlc.narg('state') IS NULL) | ||
AND (data_type = sqlc.narg('data_type') OR sqlc.narg('data_type') IS NULL) | ||
AND (ingestion_ts >= sqlc.narg('ingestion_ts_start') OR sqlc.narg('ingestion_ts_start') IS NULL) | ||
AND (ingestion_ts <= sqlc.narg('ingestion_ts_end') OR sqlc.narg('ingestion_ts_end') IS NULL) | ||
ORDER BY id DESC | ||
LIMIT sqlc.arg('limit') OFFSET sqlc.arg('offset'); | ||
|
||
-- name: RetrieveIngestionLogsWithChangeSets :many | ||
SELECT v_ingestion_logs_with_change_set.* | ||
FROM v_ingestion_logs_with_change_set | ||
WHERE (v_ingestion_logs_with_change_set.state = sqlc.narg('state') OR sqlc.narg('state') IS NULL) | ||
AND (v_ingestion_logs_with_change_set.data_type = sqlc.narg('data_type') OR sqlc.narg('data_type') IS NULL) | ||
AND (v_ingestion_logs_with_change_set.ingestion_ts >= sqlc.narg('ingestion_ts_start') OR | ||
sqlc.narg('ingestion_ts_start') IS NULL) | ||
AND (v_ingestion_logs_with_change_set.ingestion_ts <= sqlc.narg('ingestion_ts_end') OR | ||
sqlc.narg('ingestion_ts_end') IS NULL) | ||
ORDER BY v_ingestion_logs_with_change_set.id DESC | ||
LIMIT sqlc.arg('limit') OFFSET sqlc.arg('offset'); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.