Skip to content

Commit 8b86cd7

Browse files
authored
fix: stop the schedule seed overwriting operator edits (#2951)
#2848 changed the seed's conflict clause to DO UPDATE SET command so the 46 existing rows would migrate from `pnpm hardhat <task>` to the new `pnpm exec tsx tasks/run.ts <task>` invocation. Seeds re-run on every runner boot, so that also silently overwrote parameters operators had set in the admin UI: on 2026-07-27 the deploy reset all 46 rows to stock defaults, losing the flags on stake_validator and remove_validator. The migration it was added for has now completed — the seed applied on the 23:15:59Z boot, so every row already carries the tsx invocation. Reverting to DO NOTHING therefore loses nothing and stops future deploys from clobbering operator state. cron_expr, enabled and signer_override were never in the clause and were unaffected throughout. Also drop the duplicate seed application in runner.ts: runContainer already applies every migrations/seed_*.sql before starting the scheduler, so this ran the same file twice per boot and bypassed the client-side seed validation.
1 parent a8de78d commit 8b86cd7

2 files changed

Lines changed: 6 additions & 22 deletions

File tree

contracts/migrations/seed_schedules.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ INSERT INTO schedules (product, name, command, cron_expr, timezone, enabled, not
5757
('origin-dollar', 'ousd_rebalancer', 'cd /app && pnpm exec tsx tasks/run.ts ousdRebalancer --network mainnet', '0 0 1 1 *', 'UTC', false, 'Manual: Run now to rebalance OUSD Morpho strategies'),
5858
('origin-dollar', 'queue_proposal', 'cd /app && pnpm exec tsx tasks/run.ts queueGovernorSixProposal --network mainnet', '0 0 1 1 *', 'UTC', false, 'Manual: add --propid then Run now'),
5959
('origin-dollar', 'execute_proposal', 'cd /app && pnpm exec tsx tasks/run.ts executeGovernorSixProposal --network mainnet', '0 0 1 1 *', 'UTC', false, 'Manual: add --propid then Run now')
60-
ON CONFLICT (product, name) DO UPDATE SET command = EXCLUDED.command;
60+
ON CONFLICT (product, name) DO NOTHING;

contracts/runner.ts

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
11
import { existsSync, readFileSync } from "node:fs";
2-
import { dirname, resolve } from "node:path";
3-
import { fileURLToPath } from "node:url";
42

5-
import {
6-
type ActionsCatalog,
7-
createPool,
8-
runContainer,
9-
} from "@oplabs/talos-client";
3+
import { type ActionsCatalog, runContainer } from "@oplabs/talos-client";
104

115
const databaseUrl = process.env.DATABASE_URL;
126
if (!databaseUrl) {
137
throw new Error("DATABASE_URL env var required");
148
}
159

16-
// Apply contracts/migrations/seed_schedules.sql before the runner boots so
17-
// any new schedule rows in that file land in the shared Talos Postgres on
18-
// container start. The file uses INSERT ... ON CONFLICT DO NOTHING, so it
19-
// is safe to re-run on every restart and only adds previously-unseen rows.
20-
const __dirname = dirname(fileURLToPath(import.meta.url));
21-
const seedSqlPath = resolve(__dirname, "migrations/seed_schedules.sql");
22-
const seedSql = readFileSync(seedSqlPath, "utf8");
23-
const pool = createPool({ connectionString: databaseUrl });
24-
try {
25-
await pool.query(seedSql);
26-
console.log(`[runner] applied ${seedSqlPath}`);
27-
} finally {
28-
await pool.end();
29-
}
10+
// Seeds are applied by runContainer (@oplabs/talos-client applySeedFiles),
11+
// which reads every <workdir>/migrations/seed_*.sql before starting the
12+
// scheduler. Applying them here too was redundant, and bypassed the
13+
// client-side validation of seed contents.
3014

3115
// The catalog is dumped at image build time by docker/dump-actions-catalog.cjs
3216
// (Node, where hardhat works). Reading it here keeps the runner's bun parent

0 commit comments

Comments
 (0)