21 lines
499 B
PL/PgSQL
21 lines
499 B
PL/PgSQL
BEGIN;
|
|
|
|
UPDATE golden_steps AS action
|
|
SET status = 'IN_PROGRESS',
|
|
completed_at = NULL,
|
|
updated_at = now()
|
|
WHERE action.action_type = 'MANUAL'
|
|
AND action.status = 'COMPLETED'
|
|
AND NOT EXISTS (
|
|
SELECT 1
|
|
FROM growth_coach_events AS event
|
|
WHERE event.entity_type = 'ACTION'
|
|
AND event.entity_id = action.id
|
|
AND event.event_type = 'action.transitioned'
|
|
AND event.payload ->> 'status' = 'COMPLETED'
|
|
);
|
|
|
|
INSERT INTO schema_migrations(version) VALUES (7);
|
|
|
|
COMMIT;
|