Should a SurrealDB migration call http::post?
HTTP call in a migration
Warning: the statement succeeds, then writes fail, access changes, or the table is held up.
What happens
http::get, http::post and the other http functions make a network request from the database server when the statement runs. In a migration that request fires in every environment the migration reaches, and again on every re-run, and the migration now fails when the remote service is down.
Why it is dangerous on a populated table
Table size does not change this one: the request leaves the server every time the migration runs, in every environment, and the migration fails whenever the remote side does.
Fires on
http::post('https://hooks.example.com/deployed', { version: '42' });The safe pattern
Send notifications from the deploy pipeline, not from the schema migration. HTTP calls inside DEFINE EVENT or DEFINE FUNCTION bodies run later, at write or call time, and the rule stays silent on them.
-- deploy pipeline, after the migration succeeds:
-- curl -X POST https://hooks.example.com/deployedFixtures
The rule ships with these files and the test suite runs them on every change: the first set must fire, the second must stay silent.
Fires (2)
http::post('https://hooks.example.com/deployed', { version: '42' });LET $flags = http::get('https://config.example.com/flags.json');
UPDATE settings:global SET flags = $flags;Stays silent (2)
DEFINE EVENT order_paid ON TABLE purchase ASYNC WHEN $event = 'UPDATE' AND $after.paid = true THEN { http::post('https://hooks.example.com/paid', $after) };DEFINE FUNCTION fn::notify($body: object) { RETURN http::post('https://hooks.example.com/notify', $body); };How to check locally
SurrealDB support is in beta: this rule runs locally in the free CLI over .surql migrations, static only, and not in the hosted service yet. No install, nothing leaves your machine:
npx bolvrk check migration.surql --engine=surrealdb