Skip to content

Commit

Permalink
force one entry
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeiannucci committed Oct 8, 2024
1 parent 85931e5 commit e225c69
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions sequencer/api/migrations/V38__upgrade_certificate.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
CREATE TABLE upgrade_certificate (
-- The ID is always set to 0. Setting it explicitly allows us to enforce with every insert or
-- update that there is only a single entry in this table: the latest known state.
id INT PRIMARY KEY,
id bool PRIMARY KEY DEFAULT true,
data BYTEA
);
REVOKE DELETE, TRUNCATE ON upgrade_certificate FROM public;
4 changes: 2 additions & 2 deletions sequencer/src/persistence/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ impl SequencerPersistence for Persistence {
.db
.read()
.await?
.query_opt_static("SELECT * FROM upgrade_certificate where id = 0")
.query_opt_static("SELECT * FROM upgrade_certificate where id = true")
.await?;

result
Expand All @@ -580,7 +580,7 @@ impl SequencerPersistence for Persistence {
"upgrade_certificate",
["id", "data"],
["id"],
[[sql_param(&0i32), sql_param(&upgrade_certificate_bytes)]],
[[sql_param(&true), sql_param(&upgrade_certificate_bytes)]],
)
.await?;
tx.commit().await
Expand Down

0 comments on commit e225c69

Please sign in to comment.