Skip to content

Commit

Permalink
foreign key
Browse files Browse the repository at this point in the history
  • Loading branch information
lostman committed Oct 18, 2023
1 parent 684a4f7 commit e537288
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
CREATE TABLE IF NOT EXISTS index_status (
id bigserial primary key,
indexer_id bigint,
namespace varchar(32) not null,
identifier varchar(32) not null,
status TEXT NOT NULL,
status_message TEXT NOT NULL,
UNIQUE(namespace, identifier)
UNIQUE(namespace, identifier),
FOREIGN KEY (indexer_id) REFERENCES index_registry (id)
);
6 changes: 4 additions & 2 deletions packages/fuel-indexer-database/postgres/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,13 +985,15 @@ pub async fn set_indexer_status(
identifier: &str,
status: IndexerStatus,
) -> sqlx::Result<()> {
let indexer_id = get_indexer_id(conn, namespace, identifier).await?;
sqlx::query(
"INSERT INTO index_status (namespace, identifier, status, status_message)
VALUES ($1, $2, $3, $4)
"INSERT INTO index_status (indexer_id, namespace, identifier, status, status_message)
VALUES ($1, $2, $3, $4, $5)
ON CONFLICT (namespace, identifier)
DO UPDATE
SET status = EXCLUDED.status, status_message = EXCLUDED.status_message;",
)
.bind(indexer_id)
.bind(namespace)
.bind(identifier)
.bind(status.status_kind.to_string())
Expand Down

0 comments on commit e537288

Please sign in to comment.