Skip to content

Commit a6b1abb

Browse files
refactor: rename DB table cron_locks -> process_lock
Signed-off-by: Robert Zaremba <robert@zaremba.ch>
1 parent c6ec0e6 commit a6b1abb

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

packages/btcindexer/db/migrations/0001_initial_schema.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ CREATE TABLE IF NOT EXISTS presign_objects (
128128

129129
CREATE INDEX IF NOT EXISTS presign_objects_sui_network_created_at ON presign_objects(sui_network, created_at);
130130

131-
CREATE TABLE IF NOT EXISTS cron_locks (
131+
CREATE TABLE IF NOT EXISTS process_locks (
132132
lock_name TEXT NOT NULL PRIMARY KEY,
133133
acquired_at INTEGER NOT NULL,
134134
expires_at INTEGER NOT NULL

packages/lib/src/test-helpers/init_db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const tables = [
4242
"btc_blocks",
4343
"indexer_state",
4444
"presign_objects",
45-
"cron_locks",
45+
"process_locks",
4646
"setups",
4747
];
4848

packages/sui-indexer/src/storage.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ describe("IndexerStorage", () => {
601601
describe("Distributed Lock", () => {
602602
async function getLock(lockName: string) {
603603
return db
604-
.prepare("SELECT * FROM cron_locks WHERE lock_name = ?")
604+
.prepare("SELECT * FROM process_locks WHERE lock_name = ?")
605605
.bind(lockName)
606606
.first<{ lock_name: string; acquired_at: number; expires_at: number }>();
607607
}
@@ -634,7 +634,7 @@ describe("IndexerStorage", () => {
634634
const expiredTime = Date.now() - 10000;
635635
await db
636636
.prepare(
637-
"INSERT INTO cron_locks (lock_name, acquired_at, expires_at) VALUES (?, ?, ?)",
637+
"INSERT INTO process_locks (lock_name, acquired_at, expires_at) VALUES (?, ?, ?)",
638638
)
639639
.bind("test-lock", expiredTime - 60000, expiredTime)
640640
.run();
@@ -664,7 +664,7 @@ describe("IndexerStorage", () => {
664664
const expiredTime = now - 10000;
665665
await db
666666
.prepare(
667-
"INSERT INTO cron_locks (lock_name, acquired_at, expires_at) VALUES (?, ?, ?)",
667+
"INSERT INTO process_locks (lock_name, acquired_at, expires_at) VALUES (?, ?, ?)",
668668
)
669669
.bind("lock-x", expiredTime - 60000, expiredTime)
670670
.run();

packages/sui-indexer/src/storage.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -866,11 +866,11 @@ export class D1Storage {
866866
try {
867867
const { results } = await this.db
868868
.prepare(
869-
`INSERT INTO cron_locks (lock_name, acquired_at, expires_at)
869+
`INSERT INTO process_locks (lock_name, acquired_at, expires_at)
870870
VALUES ${valueRows}
871871
ON CONFLICT(lock_name) DO UPDATE
872872
SET acquired_at = excluded.acquired_at, expires_at = excluded.expires_at
873-
WHERE cron_locks.expires_at <= excluded.acquired_at
873+
WHERE process_locks.expires_at <= excluded.acquired_at
874874
RETURNING lock_name, acquired_at`,
875875
)
876876
.bind(...params)
@@ -891,7 +891,7 @@ export class D1Storage {
891891

892892
try {
893893
await this.db
894-
.prepare(`DELETE FROM cron_locks WHERE lock_name IN (${placeholders})`)
894+
.prepare(`DELETE FROM process_locks WHERE lock_name IN (${placeholders})`)
895895
.bind(...lockNames)
896896
.run();
897897
} catch (error) {

0 commit comments

Comments
 (0)