Skip to content

Commit 8073fc3

Browse files
feat(seed): pin demo shop as default connection
- Adds connection_pin row for admin user pointing to Demo Shop - Uses ON CONFLICT to handle re-runs (moves pin instead of failing) - Ensures Demo Shop is auto-selected on first login Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
1 parent 3e76ddd commit 8073fc3

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎scripts/self-host/seed-demo-data.sh‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,21 @@ JSON
232232
echo " Created demo connection: $connection_id"
233233
fi
234234

235+
# Pin the demo connection as the default for the admin user
236+
if [[ -n "${connection_id:-}" ]]; then
237+
echo " Pinning demo connection as default..."
238+
compose exec -T postgres psql -U postgres -d dba_agent -v ON_ERROR_STOP=1 <<EOSQL
239+
-- Pin the demo shop as the admin's default connection
240+
-- The unique constraint on username ensures one pin per user
241+
INSERT INTO connection_pin (username, connection_id, created_at, updated_at)
242+
VALUES ('${DEEPSQL_INITIAL_ADMIN_EMAIL}', '${connection_id}', NOW(), NOW())
243+
ON CONFLICT (username) DO UPDATE SET
244+
connection_id = EXCLUDED.connection_id,
245+
updated_at = NOW();
246+
EOSQL
247+
echo " Demo connection pinned as default."
248+
fi
249+
235250
# ============================================================================
236251
# Step 4: Run real workload to populate pg_stat_statements
237252
# ============================================================================

0 commit comments

Comments
 (0)