@@ -107,6 +107,36 @@ UPDATE opportunity SET flags = flags - 'plan' - 'batchSize'
107107WHERE id = ' OPPORTUNITY_ID' ;
108108```
109109
110+ ## Opportunity State Management
111+
112+ The ` opportunity ` table uses a ` state ` column (integer) to track lifecycle status. Values come from ` OpportunityState ` enum in ` @dailydotdev/schema ` .
113+
114+ ### OpportunityState Values
115+
116+ | Value | Name | Description |
117+ | -------| ------| -------------|
118+ | 0 | UNSPECIFIED | Default/unset |
119+ | 1 | DRAFT | Not yet published |
120+ | 2 | LIVE | Active and visible |
121+ | 3 | CLOSED | No longer active |
122+ | 4 | IN_REVIEW | Pending review |
123+
124+ ### Update Opportunity State
125+
126+ ``` sql
127+ -- Set to LIVE
128+ UPDATE opportunity SET state = 2 WHERE id = ' OPPORTUNITY_ID' RETURNING id, state, title;
129+
130+ -- Set to DRAFT
131+ UPDATE opportunity SET state = 1 WHERE id = ' OPPORTUNITY_ID' RETURNING id, state, title;
132+
133+ -- Set to CLOSED
134+ UPDATE opportunity SET state = 3 WHERE id = ' OPPORTUNITY_ID' RETURNING id, state, title;
135+
136+ -- Set to IN_REVIEW
137+ UPDATE opportunity SET state = 4 WHERE id = ' OPPORTUNITY_ID' RETURNING id, state, title;
138+ ```
139+
110140## Instructions
111141
112142When the user asks for local environment help:
@@ -122,6 +152,57 @@ Common requests:
122152- "Run SQL: ..." → Execute via docker
123153- "Reset payment for X" → Run reset queries
124154- "Check subscription for X" → Query and display current state
155+ - "Update opp X to live/draft/closed" → Update opportunity state
156+
157+ ## Discovering Schema Information
158+
159+ When handling requests not covered in this skill, use these techniques to discover the correct schema:
160+
161+ ### 1. Check Entity Definitions
162+
163+ Entity files define column names and types:
164+ ``` bash
165+ # Find the entity file
166+ grep -r " TableName" src/entity/ --include=" *.ts"
167+ # Read the entity to see column definitions
168+ ```
169+
170+ Key location: ` src/entity/ ` - TypeORM entities with ` @Column ` decorators show actual DB column names.
171+
172+ ### 2. Find Enum Values
173+
174+ Many columns use integer enums from ` @dailydotdev/schema ` . To find enum values:
175+
176+ ``` bash
177+ # Search for enum usage in codebase
178+ grep -r " EnumName\." src/ --include=" *.ts" | head -20
179+
180+ # Find enum definition in schema package
181+ grep -r " EnumName" node_modules/@dailydotdev/schema/dist/ --include=" *.d.ts"
182+ ```
183+
184+ Common enum locations: ` node_modules/@dailydotdev/schema/dist/daily-api/*_pb.d.ts `
185+
186+ ### 3. Query Existing Data
187+
188+ When unsure about column names or values:
189+ ``` sql
190+ -- Check table structure
191+ \d tablename
192+
193+ -- See existing values
194+ SELECT DISTINCT column_name FROM tablename LIMIT 10 ;
195+
196+ -- Inspect a specific row
197+ SELECT * FROM tablename WHERE id = ' xxx' LIMIT 1 ;
198+ ```
199+
200+ ### 4. Common Gotchas
201+
202+ - ** Column naming** : Entity property names may differ from DB columns (e.g., ` state ` not ` status ` )
203+ - ** Integer enums** : Many "status" fields are integers, not strings - find the enum definition
204+ - ** JSONB fields** : Use ` jsonb_build_object() ` for updates, ` -> ` or ` ->> ` for queries
205+ - ** Quoted columns** : PostgreSQL requires double quotes for camelCase columns (e.g., ` "organizationId" ` )
125206
126207## Continuous Improvement
127208
0 commit comments