lazyBoy/migrations/029_computer_boot_attempts.sql

7 lines
438 B
SQL

-- A crashed API must not leave permanent booting state. Attempt identity fences
-- late replies after a timed-out attempt is reclaimed by another API process.
ALTER TABLE computers ADD COLUMN boot_attempt TEXT;
ALTER TABLE computers ADD COLUMN boot_started_at TIMESTAMPTZ;
UPDATE computers SET boot_started_at=updated_at WHERE state='booting';
CREATE INDEX computer_boot_deadline_idx ON computers(boot_started_at) WHERE state='booting';