From ebba95213847a129016c313be5dcdbcbb812ef32 Mon Sep 17 00:00:00 2001
From: soryu <soryu@soryu.co>
Date: Wed, 4 Feb 2026 01:18:31 +0000
Subject: Fix default chain status

---
 makima/migrations/20260204100000_chain_default_pending.sql | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 makima/migrations/20260204100000_chain_default_pending.sql

(limited to 'makima/migrations/20260204100000_chain_default_pending.sql')

diff --git a/makima/migrations/20260204100000_chain_default_pending.sql b/makima/migrations/20260204100000_chain_default_pending.sql
new file mode 100644
index 0000000..2803562
--- /dev/null
+++ b/makima/migrations/20260204100000_chain_default_pending.sql
@@ -0,0 +1,12 @@
+-- Fix chain default status to 'pending' instead of 'active'
+-- Chains should start as pending until explicitly started
+
+-- Change default for new chains
+ALTER TABLE chains ALTER COLUMN status SET DEFAULT 'pending';
+
+-- Update any chains that have no contracts and are 'active' to 'pending'
+-- (These were likely created but never properly started)
+UPDATE chains
+SET status = 'pending'
+WHERE status = 'active'
+  AND id NOT IN (SELECT DISTINCT chain_id FROM chain_contracts WHERE chain_id IS NOT NULL);
-- 
cgit v1.2.3

