blob: bc89ff8396e3ee373c606913c6c6db68dc1cea69 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
-- Drop the legacy contracts + supervisor task-grouping system.
--
-- Context: contracts were the pre-directive grouping for tasks. The
-- "supervisor" was a special task type (`is_supervisor=true`) that
-- coordinated a tree of subtasks under one contract. Both have been
-- inert for several PRs — no creation path remains, the LLM removal
-- (#135) took out the last surface that spawned them, and the
-- directives system reads its own active contract body for spec text.
--
-- This migration drops every remnant in one shot. The user authorised
-- a DB wipe; CASCADE is intentional.
--
-- Survives:
-- * `pending_questions` (in-memory only in server state.rs) — the
-- directive Ask command still uses this backchannel.
-- * `orders` (already had contract_id dropped, line 20260216).
-- * `directive_documents` (the user-facing "contract" surface).
-- ---------------------------------------------------------------------------
-- Drop FK columns first so the parent tables can go cleanly.
-- ---------------------------------------------------------------------------
-- Tasks: legacy contract grouping + supervisor flags.
ALTER TABLE tasks DROP COLUMN IF EXISTS contract_id CASCADE;
ALTER TABLE tasks DROP COLUMN IF EXISTS is_supervisor CASCADE;
ALTER TABLE tasks DROP COLUMN IF EXISTS supervisor_task_id CASCADE;
ALTER TABLE tasks DROP COLUMN IF EXISTS supervisor_worktree_task_id CASCADE;
-- directive_steps: legacy contract-backed step machinery.
ALTER TABLE directive_steps DROP COLUMN IF EXISTS contract_id CASCADE;
ALTER TABLE directive_steps DROP COLUMN IF EXISTS contract_type CASCADE;
-- files: legacy contract + phase association.
ALTER TABLE files DROP COLUMN IF EXISTS contract_id CASCADE;
ALTER TABLE files DROP COLUMN IF EXISTS contract_phase CASCADE;
-- history_events: drop contract scope; events stay task-level only.
ALTER TABLE history_events DROP COLUMN IF EXISTS contract_id CASCADE;
ALTER TABLE history_events DROP COLUMN IF EXISTS phase CASCADE;
-- ---------------------------------------------------------------------------
-- Drop dependent tables. Order is FK-safe: leaf tables first.
-- ---------------------------------------------------------------------------
DROP TABLE IF EXISTS contract_chat_messages CASCADE;
DROP TABLE IF EXISTS contract_chat_conversations CASCADE;
DROP TABLE IF EXISTS contract_events CASCADE;
DROP TABLE IF EXISTS contract_repositories CASCADE;
DROP TABLE IF EXISTS contract_type_templates CASCADE;
DROP TABLE IF EXISTS supervisor_heartbeats CASCADE;
DROP TABLE IF EXISTS supervisor_states CASCADE;
DROP TABLE IF EXISTS mesh_chat_messages CASCADE;
DROP TABLE IF EXISTS mesh_chat_conversations CASCADE;
-- Final boss: the contracts table itself.
DROP TABLE IF EXISTS contracts CASCADE;
|