@intentsolutionsio/supabase-pack 1.0.0 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +73 -47
- package/package.json +4 -4
- package/skills/supabase-advanced-troubleshooting/SKILL.md +404 -200
- package/skills/supabase-advanced-troubleshooting/references/errors.md +11 -0
- package/skills/supabase-advanced-troubleshooting/references/evidence-collection-framework.md +34 -0
- package/skills/supabase-advanced-troubleshooting/references/examples.md +11 -0
- package/skills/supabase-advanced-troubleshooting/references/rls-edge-functions-realtime.md +363 -0
- package/skills/supabase-advanced-troubleshooting/references/systematic-isolation.md +56 -0
- package/skills/supabase-advanced-troubleshooting/references/timing-analysis.md +35 -0
- package/skills/supabase-architecture-variants/SKILL.md +395 -216
- package/skills/supabase-architecture-variants/references/errors.md +11 -0
- package/skills/supabase-architecture-variants/references/examples.md +12 -0
- package/skills/supabase-architecture-variants/references/serverless-and-multi-tenant.md +251 -0
- package/skills/supabase-architecture-variants/references/variant-a-monolith-(simple).md +44 -0
- package/skills/supabase-architecture-variants/references/variant-b-service-layer-(moderate).md +72 -0
- package/skills/supabase-architecture-variants/references/variant-c-microservice-(complex).md +81 -0
- package/skills/supabase-auth-storage-realtime-core/SKILL.md +471 -37
- package/skills/supabase-ci-integration/SKILL.md +315 -67
- package/skills/supabase-ci-integration/references/errors.md +10 -0
- package/skills/supabase-ci-integration/references/examples.md +36 -0
- package/skills/supabase-ci-integration/references/implementation.md +54 -0
- package/skills/supabase-common-errors/SKILL.md +320 -62
- package/skills/supabase-common-errors/references/errors.md +53 -0
- package/skills/supabase-common-errors/references/examples.md +23 -0
- package/skills/supabase-cost-tuning/SKILL.md +365 -131
- package/skills/supabase-cost-tuning/references/cost-estimation.md +34 -0
- package/skills/supabase-cost-tuning/references/cost-reduction-strategies.md +40 -0
- package/skills/supabase-cost-tuning/references/errors.md +11 -0
- package/skills/supabase-cost-tuning/references/examples.md +15 -0
- package/skills/supabase-data-handling/SKILL.md +378 -145
- package/skills/supabase-data-handling/references/errors.md +11 -0
- package/skills/supabase-data-handling/references/examples.md +27 -0
- package/skills/supabase-data-handling/references/implementation.md +223 -0
- package/skills/supabase-data-handling/references/retention-and-backup.md +221 -0
- package/skills/supabase-debug-bundle/SKILL.md +267 -73
- package/skills/supabase-debug-bundle/references/errors.md +12 -0
- package/skills/supabase-debug-bundle/references/examples.md +24 -0
- package/skills/supabase-debug-bundle/references/implementation.md +54 -0
- package/skills/supabase-deploy-integration/SKILL.md +258 -147
- package/skills/supabase-deploy-integration/references/errors.md +11 -0
- package/skills/supabase-deploy-integration/references/examples.md +21 -0
- package/skills/supabase-deploy-integration/references/google-cloud-run.md +36 -0
- package/skills/supabase-deploy-integration/references/vercel-deployment.md +35 -0
- package/skills/supabase-enterprise-rbac/SKILL.md +327 -160
- package/skills/supabase-enterprise-rbac/references/api-scoping-and-enforcement.md +255 -0
- package/skills/supabase-enterprise-rbac/references/errors.md +11 -0
- package/skills/supabase-enterprise-rbac/references/examples.md +12 -0
- package/skills/supabase-enterprise-rbac/references/role-implementation.md +33 -0
- package/skills/supabase-enterprise-rbac/references/sso-integration.md +35 -0
- package/skills/supabase-hello-world/SKILL.md +160 -54
- package/skills/supabase-incident-runbook/SKILL.md +453 -131
- package/skills/supabase-incident-runbook/references/errors.md +11 -0
- package/skills/supabase-incident-runbook/references/examples.md +10 -0
- package/skills/supabase-incident-runbook/references/immediate-actions-by-error-type.md +41 -0
- package/skills/supabase-install-auth/SKILL.md +186 -50
- package/skills/supabase-install-auth/references/examples.md +102 -0
- package/skills/supabase-known-pitfalls/SKILL.md +411 -241
- package/skills/supabase-known-pitfalls/references/errors.md +11 -0
- package/skills/supabase-known-pitfalls/references/examples.md +12 -0
- package/skills/supabase-load-scale/SKILL.md +346 -217
- package/skills/supabase-load-scale/references/capacity-planning.md +47 -0
- package/skills/supabase-load-scale/references/errors.md +11 -0
- package/skills/supabase-load-scale/references/examples.md +26 -0
- package/skills/supabase-load-scale/references/load-testing-with-k6.md +59 -0
- package/skills/supabase-load-scale/references/scaling-patterns.md +65 -0
- package/skills/supabase-load-scale/references/table-partitioning.md +263 -0
- package/skills/supabase-local-dev-loop/SKILL.md +272 -73
- package/skills/supabase-local-dev-loop/references/errors.md +11 -0
- package/skills/supabase-local-dev-loop/references/examples.md +21 -0
- package/skills/supabase-local-dev-loop/references/implementation.md +60 -0
- package/skills/supabase-migration-deep-dive/SKILL.md +338 -177
- package/skills/supabase-migration-deep-dive/references/backfill-versioning-rollback.md +258 -0
- package/skills/supabase-migration-deep-dive/references/errors.md +11 -0
- package/skills/supabase-migration-deep-dive/references/examples.md +12 -0
- package/skills/supabase-migration-deep-dive/references/implementation-plan.md +80 -0
- package/skills/supabase-migration-deep-dive/references/pre-migration-assessment.md +39 -0
- package/skills/supabase-multi-env-setup/SKILL.md +393 -152
- package/skills/supabase-multi-env-setup/references/configuration-structure.md +59 -0
- package/skills/supabase-multi-env-setup/references/errors.md +11 -0
- package/skills/supabase-multi-env-setup/references/examples.md +11 -0
- package/skills/supabase-observability/SKILL.md +318 -196
- package/skills/supabase-observability/references/alert-configuration.md +40 -0
- package/skills/supabase-observability/references/errors.md +11 -0
- package/skills/supabase-observability/references/examples.md +13 -0
- package/skills/supabase-observability/references/metrics-collection.md +65 -0
- package/skills/supabase-performance-tuning/SKILL.md +304 -160
- package/skills/supabase-performance-tuning/references/caching-strategy.md +49 -0
- package/skills/supabase-performance-tuning/references/errors.md +11 -0
- package/skills/supabase-performance-tuning/references/examples.md +13 -0
- package/skills/supabase-policy-guardrails/SKILL.md +248 -221
- package/skills/supabase-policy-guardrails/references/ci-cost-security.md +484 -0
- package/skills/supabase-policy-guardrails/references/errors.md +11 -0
- package/skills/supabase-policy-guardrails/references/eslint-rules.md +46 -0
- package/skills/supabase-policy-guardrails/references/examples.md +10 -0
- package/skills/supabase-prod-checklist/SKILL.md +474 -84
- package/skills/supabase-prod-checklist/references/errors.md +63 -0
- package/skills/supabase-prod-checklist/references/examples.md +153 -0
- package/skills/supabase-prod-checklist/references/implementation.md +113 -0
- package/skills/supabase-rate-limits/SKILL.md +311 -98
- package/skills/supabase-rate-limits/references/errors.md +11 -0
- package/skills/supabase-rate-limits/references/examples.md +46 -0
- package/skills/supabase-rate-limits/references/implementation.md +66 -0
- package/skills/supabase-reference-architecture/SKILL.md +249 -182
- package/skills/supabase-reference-architecture/references/errors.md +29 -0
- package/skills/supabase-reference-architecture/references/examples.md +116 -0
- package/skills/supabase-reference-architecture/references/key-components.md +244 -0
- package/skills/supabase-reference-architecture/references/project-structure.md +109 -0
- package/skills/supabase-reliability-patterns/SKILL.md +229 -234
- package/skills/supabase-reliability-patterns/references/circuit-breaker.md +36 -0
- package/skills/supabase-reliability-patterns/references/dead-letter-queue.md +48 -0
- package/skills/supabase-reliability-patterns/references/errors.md +11 -0
- package/skills/supabase-reliability-patterns/references/examples.md +11 -0
- package/skills/supabase-reliability-patterns/references/idempotency-keys.md +36 -0
- package/skills/supabase-reliability-patterns/references/offline-degradation-health-dualwrite.md +489 -0
- package/skills/supabase-schema-from-requirements/SKILL.md +373 -34
- package/skills/supabase-sdk-patterns/SKILL.md +388 -99
- package/skills/supabase-sdk-patterns/references/errors.md +11 -0
- package/skills/supabase-sdk-patterns/references/examples.md +45 -0
- package/skills/supabase-sdk-patterns/references/implementation.md +67 -0
- package/skills/supabase-security-basics/SKILL.md +282 -102
- package/skills/supabase-security-basics/references/errors.md +10 -0
- package/skills/supabase-security-basics/references/examples.md +70 -0
- package/skills/supabase-security-basics/references/implementation.md +39 -0
- package/skills/supabase-upgrade-migration/SKILL.md +248 -66
- package/skills/supabase-upgrade-migration/references/errors.md +10 -0
- package/skills/supabase-upgrade-migration/references/examples.md +51 -0
- package/skills/supabase-upgrade-migration/references/implementation.md +29 -0
- package/skills/supabase-webhooks-events/SKILL.md +412 -138
- package/skills/supabase-webhooks-events/references/errors.md +55 -0
- package/skills/supabase-webhooks-events/references/event-handler-pattern.md +106 -0
- package/skills/supabase-webhooks-events/references/examples.md +133 -0
- package/skills/supabase-webhooks-events/references/signature-verification.md +165 -0
|
@@ -1,209 +1,320 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: supabase-deploy-integration
|
|
3
|
-
description:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
description: 'Deploy and manage Supabase projects in production. Covers database migrations,
|
|
4
|
+
|
|
5
|
+
Edge Functions deployment, secrets management, zero-downtime rollouts,
|
|
6
|
+
|
|
7
|
+
blue/green branching, rollback procedures, and post-deploy health checks.
|
|
8
|
+
|
|
9
|
+
Use when deploying Supabase to production, running migrations, deploying
|
|
10
|
+
|
|
11
|
+
Edge Functions, managing secrets, or implementing zero-downtime deployments.
|
|
12
|
+
|
|
13
|
+
Trigger: "deploy supabase", "supabase migration push", "deploy edge function",
|
|
14
|
+
|
|
15
|
+
"supabase rollback", "supabase blue green", "supabase health check".
|
|
16
|
+
|
|
17
|
+
'
|
|
18
|
+
allowed-tools: Read, Write, Edit, Bash(npx:supabase), Bash(supabase:*), Bash(curl:*)
|
|
10
19
|
version: 1.0.0
|
|
11
20
|
license: MIT
|
|
12
21
|
author: Jeremy Longshore <jeremy@intentsolutions.io>
|
|
22
|
+
tags:
|
|
23
|
+
- saas
|
|
24
|
+
- supabase
|
|
25
|
+
- deployment
|
|
26
|
+
- migrations
|
|
27
|
+
- edge-functions
|
|
28
|
+
- devops
|
|
29
|
+
compatibility: Designed for Claude Code, also compatible with Codex and OpenClaw
|
|
13
30
|
---
|
|
14
|
-
|
|
15
31
|
# Supabase Deploy Integration
|
|
16
32
|
|
|
17
33
|
## Overview
|
|
18
|
-
|
|
34
|
+
|
|
35
|
+
Deploy and manage Supabase projects in production with confidence. This skill covers the full deployment lifecycle: pushing database migrations, deploying Edge Functions, managing secrets, executing zero-downtime rollouts with blue/green database branching, rolling back failed migrations, and verifying deployment health. All commands use the Supabase CLI with `--project-ref` for explicit project targeting.
|
|
36
|
+
|
|
37
|
+
**SDK**: `@supabase/supabase-js` — [supabase.com/docs](https://supabase.com/docs)
|
|
19
38
|
|
|
20
39
|
## Prerequisites
|
|
21
|
-
- Supabase API keys for production environment
|
|
22
|
-
- Platform CLI installed (vercel, fly, or gcloud)
|
|
23
|
-
- Application code ready for deployment
|
|
24
|
-
- Environment variables documented
|
|
25
40
|
|
|
26
|
-
|
|
41
|
+
- Supabase CLI installed (`npm install -g supabase` or `npx supabase`)
|
|
42
|
+
- Supabase project linked (`npx supabase link --project-ref <your-ref>`)
|
|
43
|
+
- Database migrations in `supabase/migrations/` directory
|
|
44
|
+
- Edge Functions in `supabase/functions/` directory (if deploying functions)
|
|
45
|
+
- `SUPABASE_ACCESS_TOKEN` set for CI/non-interactive environments
|
|
27
46
|
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
# Add Supabase secrets to Vercel
|
|
31
|
-
vercel secrets add supabase_api_key sk_live_***
|
|
32
|
-
vercel secrets add supabase_webhook_secret whsec_***
|
|
47
|
+
## Instructions
|
|
33
48
|
|
|
34
|
-
|
|
35
|
-
|
|
49
|
+
### Step 1 — Push Database Migrations and Deploy Edge Functions
|
|
50
|
+
|
|
51
|
+
Apply pending database migrations to your production project, then deploy Edge Functions with their required secrets.
|
|
52
|
+
|
|
53
|
+
**Database migrations:**
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Apply all pending migrations to production
|
|
57
|
+
npx supabase db push --project-ref $PROJECT_REF
|
|
36
58
|
|
|
37
|
-
#
|
|
38
|
-
|
|
59
|
+
# Preview what will run without applying (dry run)
|
|
60
|
+
npx supabase db push --project-ref $PROJECT_REF --dry-run
|
|
39
61
|
|
|
40
|
-
#
|
|
41
|
-
|
|
62
|
+
# Check current migration status
|
|
63
|
+
npx supabase migration list --project-ref $PROJECT_REF
|
|
42
64
|
```
|
|
43
65
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
}
|
|
66
|
+
Each migration file in `supabase/migrations/` is applied in timestamp order. The CLI tracks which migrations have already been applied and only runs new ones.
|
|
67
|
+
|
|
68
|
+
**Edge Functions deployment:**
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Deploy a single Edge Function
|
|
72
|
+
npx supabase functions deploy process-webhook --project-ref $PROJECT_REF
|
|
73
|
+
|
|
74
|
+
# Deploy all Edge Functions at once
|
|
75
|
+
npx supabase functions deploy --project-ref $PROJECT_REF
|
|
56
76
|
```
|
|
57
77
|
|
|
58
|
-
|
|
78
|
+
**Secrets management — set environment variables for Edge Functions:**
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Set individual secrets
|
|
82
|
+
npx supabase secrets set STRIPE_KEY=sk_live_xxx --project-ref $PROJECT_REF
|
|
83
|
+
npx supabase secrets set WEBHOOK_SECRET=whsec_xxx --project-ref $PROJECT_REF
|
|
59
84
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
app = "my-supabase-app"
|
|
63
|
-
primary_region = "iad"
|
|
85
|
+
# Set multiple secrets at once
|
|
86
|
+
npx supabase secrets set API_KEY=value1 SIGNING_KEY=value2 --project-ref $PROJECT_REF
|
|
64
87
|
|
|
65
|
-
|
|
66
|
-
|
|
88
|
+
# List current secrets (names only, values hidden)
|
|
89
|
+
npx supabase secrets list --project-ref $PROJECT_REF
|
|
67
90
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
force_https = true
|
|
71
|
-
auto_stop_machines = true
|
|
72
|
-
auto_start_machines = true
|
|
91
|
+
# Remove a secret
|
|
92
|
+
npx supabase secrets unset OLD_KEY --project-ref $PROJECT_REF
|
|
73
93
|
```
|
|
74
94
|
|
|
75
|
-
###
|
|
95
|
+
### Step 2 — Zero-Downtime Deployments and Blue/Green Branching
|
|
96
|
+
|
|
97
|
+
Use Supabase database branching to test migrations against a production-like environment before cutting over.
|
|
98
|
+
|
|
99
|
+
**Blue/green deployment via database branching:**
|
|
100
|
+
|
|
76
101
|
```bash
|
|
77
|
-
#
|
|
78
|
-
|
|
79
|
-
|
|
102
|
+
# Create a preview branch (clones schema, not data)
|
|
103
|
+
npx supabase branches create staging-v2 --project-ref $PROJECT_REF
|
|
104
|
+
|
|
105
|
+
# The branch gets its own connection string and API URL
|
|
106
|
+
# Test your migrations against the branch first
|
|
107
|
+
npx supabase db push --project-ref $BRANCH_REF
|
|
80
108
|
|
|
81
|
-
#
|
|
82
|
-
|
|
109
|
+
# Verify the branch works with your application
|
|
110
|
+
# Point a staging instance at the branch's connection string
|
|
111
|
+
|
|
112
|
+
# When satisfied, merge branch changes into production
|
|
113
|
+
# Apply the same migrations to the main project
|
|
114
|
+
npx supabase db push --project-ref $PROJECT_REF
|
|
115
|
+
|
|
116
|
+
# Delete the branch after successful cutover
|
|
117
|
+
npx supabase branches delete staging-v2 --project-ref $PROJECT_REF
|
|
83
118
|
```
|
|
84
119
|
|
|
85
|
-
|
|
120
|
+
**Rolling deployment pattern for zero downtime:**
|
|
121
|
+
|
|
122
|
+
1. Deploy backward-compatible migration first (additive schema changes only)
|
|
123
|
+
2. Deploy application code that works with both old and new schema
|
|
124
|
+
3. Run data backfill if needed
|
|
125
|
+
4. Deploy cleanup migration (drop old columns/tables) after all instances updated
|
|
86
126
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
127
|
+
```sql
|
|
128
|
+
-- Migration 1: Add new column (backward compatible)
|
|
129
|
+
ALTER TABLE orders ADD COLUMN status_v2 text;
|
|
130
|
+
|
|
131
|
+
-- Migration 2: Backfill (run separately, can be done in batches)
|
|
132
|
+
UPDATE orders SET status_v2 = status WHERE status_v2 IS NULL;
|
|
133
|
+
|
|
134
|
+
-- Migration 3: Cleanup (only after all app instances use status_v2)
|
|
135
|
+
ALTER TABLE orders DROP COLUMN status;
|
|
136
|
+
ALTER TABLE orders RENAME COLUMN status_v2 TO status;
|
|
95
137
|
```
|
|
96
138
|
|
|
97
|
-
###
|
|
139
|
+
### Step 3 — Rollback, Health Checks, and Monitoring
|
|
140
|
+
|
|
141
|
+
When a migration fails or causes issues, roll it back. Then verify deployment health.
|
|
142
|
+
|
|
143
|
+
**Rollback a failed migration:**
|
|
144
|
+
|
|
98
145
|
```bash
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
PROJECT_ID="${GOOGLE_CLOUD_PROJECT}"
|
|
103
|
-
SERVICE_NAME="supabase-service"
|
|
104
|
-
REGION="us-central1"
|
|
105
|
-
|
|
106
|
-
# Build and push image
|
|
107
|
-
gcloud builds submit --tag gcr.io/$PROJECT_ID/$SERVICE_NAME
|
|
108
|
-
|
|
109
|
-
# Deploy to Cloud Run
|
|
110
|
-
gcloud run deploy $SERVICE_NAME \
|
|
111
|
-
--image gcr.io/$PROJECT_ID/$SERVICE_NAME \
|
|
112
|
-
--region $REGION \
|
|
113
|
-
--platform managed \
|
|
114
|
-
--allow-unauthenticated \
|
|
115
|
-
--set-secrets=SUPABASE_API_KEY=supabase-api-key:latest
|
|
116
|
-
```
|
|
146
|
+
# Mark a specific migration as reverted (removes it from the applied list)
|
|
147
|
+
npx supabase migration repair --status reverted <migration_version> --project-ref $PROJECT_REF
|
|
117
148
|
|
|
118
|
-
|
|
149
|
+
# Example: revert migration 20260322120000
|
|
150
|
+
npx supabase migration repair --status reverted 20260322120000 --project-ref $PROJECT_REF
|
|
119
151
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
environment: 'development' | 'staging' | 'production';
|
|
125
|
-
webhookSecret?: string;
|
|
126
|
-
}
|
|
152
|
+
# After marking as reverted, manually undo the schema changes
|
|
153
|
+
# Write a new "down" migration to reverse the changes
|
|
154
|
+
npx supabase migration new rollback_order_status
|
|
155
|
+
```
|
|
127
156
|
|
|
128
|
-
|
|
129
|
-
|
|
157
|
+
```sql
|
|
158
|
+
-- supabase/migrations/<timestamp>_rollback_order_status.sql
|
|
159
|
+
-- Reverse the changes from the failed migration
|
|
160
|
+
ALTER TABLE orders DROP COLUMN IF EXISTS status_v2;
|
|
161
|
+
```
|
|
130
162
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
webhookSecret: process.env.SUPABASE_WEBHOOK_SECRET,
|
|
135
|
-
};
|
|
136
|
-
}
|
|
163
|
+
```bash
|
|
164
|
+
# Push the rollback migration
|
|
165
|
+
npx supabase db push --project-ref $PROJECT_REF
|
|
137
166
|
```
|
|
138
167
|
|
|
139
|
-
|
|
168
|
+
**Post-deploy health check:**
|
|
140
169
|
|
|
141
170
|
```typescript
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
171
|
+
import { createClient } from '@supabase/supabase-js'
|
|
172
|
+
|
|
173
|
+
async function healthCheck() {
|
|
174
|
+
const supabase = createClient(
|
|
175
|
+
process.env.SUPABASE_URL!,
|
|
176
|
+
process.env.SUPABASE_ANON_KEY!
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
const checks = {
|
|
180
|
+
database: false,
|
|
181
|
+
auth: false,
|
|
182
|
+
storage: false,
|
|
183
|
+
functions: false,
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Database connectivity
|
|
187
|
+
const dbStart = Date.now()
|
|
188
|
+
const { error: dbErr } = await supabase.from('_health').select('count').limit(1)
|
|
189
|
+
checks.database = !dbErr || dbErr.code === 'PGRST116' // table not found is OK
|
|
190
|
+
const dbLatency = Date.now() - dbStart
|
|
191
|
+
|
|
192
|
+
// Auth service
|
|
193
|
+
const { error: authErr } = await supabase.auth.getSession()
|
|
194
|
+
checks.auth = !authErr
|
|
195
|
+
|
|
196
|
+
// Storage service
|
|
197
|
+
const { error: storageErr } = await supabase.storage.listBuckets()
|
|
198
|
+
checks.storage = !storageErr
|
|
199
|
+
|
|
200
|
+
// Edge Function ping (replace with your function name)
|
|
201
|
+
try {
|
|
202
|
+
const { error: fnErr } = await supabase.functions.invoke('health-ping')
|
|
203
|
+
checks.functions = !fnErr
|
|
204
|
+
} catch {
|
|
205
|
+
checks.functions = false
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const allHealthy = Object.values(checks).every(Boolean)
|
|
209
|
+
|
|
210
|
+
console.log({
|
|
211
|
+
status: allHealthy ? 'healthy' : 'degraded',
|
|
212
|
+
checks,
|
|
213
|
+
db_latency_ms: dbLatency,
|
|
151
214
|
timestamp: new Date().toISOString(),
|
|
152
|
-
})
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
return allHealthy
|
|
153
218
|
}
|
|
154
219
|
```
|
|
155
220
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
### Step 1: Choose Deployment Platform
|
|
159
|
-
Select the platform that best fits your infrastructure needs and follow the platform-specific guide below.
|
|
221
|
+
**Monitoring via Supabase Dashboard:**
|
|
160
222
|
|
|
161
|
-
|
|
162
|
-
|
|
223
|
+
- Navigate to **Dashboard > Reports** for database performance metrics
|
|
224
|
+
- Check **Dashboard > Logs > Postgres** for slow queries and errors
|
|
225
|
+
- Review **Dashboard > Logs > Edge Functions** for function invocation logs
|
|
226
|
+
- Set up **Dashboard > Database > Webhooks** for change notifications
|
|
227
|
+
- Monitor **Dashboard > Settings > Infrastructure** for resource utilization
|
|
163
228
|
|
|
164
|
-
|
|
165
|
-
Use the platform CLI to deploy your application with Supabase integration.
|
|
229
|
+
## Output
|
|
166
230
|
|
|
167
|
-
|
|
168
|
-
Test the health check endpoint to confirm Supabase connectivity.
|
|
231
|
+
After completing these steps, you will have:
|
|
169
232
|
|
|
170
|
-
|
|
171
|
-
-
|
|
172
|
-
-
|
|
173
|
-
-
|
|
174
|
-
-
|
|
233
|
+
- All pending database migrations applied to production via `supabase db push`
|
|
234
|
+
- Edge Functions deployed to Supabase's global edge network
|
|
235
|
+
- Secrets configured for Edge Functions without exposing values in code
|
|
236
|
+
- A zero-downtime deployment strategy using database branching or rolling migrations
|
|
237
|
+
- Rollback capability for any failed migration via `migration repair --status reverted`
|
|
238
|
+
- Health check endpoint verifying database, auth, storage, and function connectivity
|
|
239
|
+
- Monitoring configured through the Supabase Dashboard Reports
|
|
175
240
|
|
|
176
241
|
## Error Handling
|
|
177
|
-
|
|
242
|
+
|
|
243
|
+
| Error | Cause | Solution |
|
|
178
244
|
|-------|-------|----------|
|
|
179
|
-
|
|
|
180
|
-
|
|
|
181
|
-
|
|
|
182
|
-
|
|
|
245
|
+
| `migration already applied` | Re-running a migration that succeeded | Check `npx supabase migration list` — skip if already applied |
|
|
246
|
+
| `permission denied for schema` | Migration modifies a protected schema | Use `ALTER DEFAULT PRIVILEGES` or run via dashboard SQL editor |
|
|
247
|
+
| `functions deploy: not linked` | Project not linked locally | Run `npx supabase link --project-ref $PROJECT_REF` first |
|
|
248
|
+
| `secret already exists` | Setting a secret that exists | `supabase secrets set` overwrites by default — this is safe |
|
|
249
|
+
| `branch limit reached` | Too many active branches | Delete unused branches with `supabase branches delete` |
|
|
250
|
+
| `migration repair` has no effect | Wrong version number | Run `supabase migration list` to find the exact version string |
|
|
251
|
+
| `connection refused` on db push | IP not allowlisted | Add your IP in Dashboard > Settings > Database > Network Bans |
|
|
252
|
+
| Edge Function 500 after deploy | Missing secret or import error | Check `supabase functions logs <name>` for stack trace |
|
|
183
253
|
|
|
184
254
|
## Examples
|
|
185
255
|
|
|
186
|
-
|
|
256
|
+
**CI/CD pipeline — GitHub Actions:**
|
|
257
|
+
|
|
258
|
+
```yaml
|
|
259
|
+
# .github/workflows/deploy.yml
|
|
260
|
+
name: Deploy to Supabase
|
|
261
|
+
on:
|
|
262
|
+
push:
|
|
263
|
+
branches: [main]
|
|
264
|
+
|
|
265
|
+
jobs:
|
|
266
|
+
deploy:
|
|
267
|
+
runs-on: ubuntu-latest
|
|
268
|
+
steps:
|
|
269
|
+
- uses: actions/checkout@v4
|
|
270
|
+
- uses: supabase/setup-cli@v1
|
|
271
|
+
with:
|
|
272
|
+
version: latest
|
|
273
|
+
|
|
274
|
+
- name: Link project
|
|
275
|
+
run: npx supabase link --project-ref ${{ secrets.SUPABASE_PROJECT_REF }}
|
|
276
|
+
env:
|
|
277
|
+
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
|
|
278
|
+
|
|
279
|
+
- name: Push migrations
|
|
280
|
+
run: npx supabase db push --project-ref ${{ secrets.SUPABASE_PROJECT_REF }}
|
|
281
|
+
env:
|
|
282
|
+
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
|
|
283
|
+
|
|
284
|
+
- name: Deploy Edge Functions
|
|
285
|
+
run: npx supabase functions deploy --project-ref ${{ secrets.SUPABASE_PROJECT_REF }}
|
|
286
|
+
env:
|
|
287
|
+
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
**Quick rollback script:**
|
|
291
|
+
|
|
187
292
|
```bash
|
|
188
293
|
#!/bin/bash
|
|
189
|
-
#
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
;;
|
|
199
|
-
esac
|
|
294
|
+
# rollback.sh — Revert the last migration
|
|
295
|
+
set -euo pipefail
|
|
296
|
+
|
|
297
|
+
REF="${1:?Usage: rollback.sh <project-ref>}"
|
|
298
|
+
LAST=$(npx supabase migration list --project-ref "$REF" 2>/dev/null | tail -1 | awk '{print $1}')
|
|
299
|
+
|
|
300
|
+
echo "Reverting migration: $LAST"
|
|
301
|
+
npx supabase migration repair --status reverted "$LAST" --project-ref "$REF"
|
|
302
|
+
echo "Migration $LAST marked as reverted. Write and push a compensating migration next."
|
|
200
303
|
```
|
|
201
304
|
|
|
202
305
|
## Resources
|
|
203
|
-
|
|
204
|
-
- [
|
|
205
|
-
- [
|
|
206
|
-
- [Supabase
|
|
306
|
+
|
|
307
|
+
- [Database Migrations Guide](https://supabase.com/docs/guides/deployment/database-migrations)
|
|
308
|
+
- [Edge Functions Deployment](https://supabase.com/docs/guides/functions/deploy)
|
|
309
|
+
- [Supabase CLI Reference](https://supabase.com/docs/reference/cli)
|
|
310
|
+
- [Database Branching](https://supabase.com/docs/guides/deployment/branching)
|
|
311
|
+
- [Secrets Management](https://supabase.com/docs/guides/functions/secrets)
|
|
312
|
+
- Supabase Dashboard Reports
|
|
207
313
|
|
|
208
314
|
## Next Steps
|
|
209
|
-
|
|
315
|
+
|
|
316
|
+
- For schema design from requirements, see `supabase-schema-from-requirements`
|
|
317
|
+
- For RLS policy configuration, see `supabase-policy-guardrails`
|
|
318
|
+
- For webhook and event handling, see `supabase-webhooks-events`
|
|
319
|
+
- For production readiness checklist, see `supabase-prod-checklist`
|
|
320
|
+
- For multi-environment setup, see `supabase-multi-env-setup`
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Error Handling Reference
|
|
2
|
+
|
|
3
|
+
| Issue | Cause | Solution |
|
|
4
|
+
|-------|-------|----------|
|
|
5
|
+
| Secret not found | Missing configuration | Add secret via platform CLI |
|
|
6
|
+
| Deploy timeout | Large build | Increase build timeout |
|
|
7
|
+
| Health check fails | Wrong API key | Verify environment variable |
|
|
8
|
+
| Cold start issues | No warm-up | Configure minimum instances |
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
*[Tons of Skills](https://tonsofskills.com) by [Intent Solutions](https://intentsolutions.io) | [jeremylongshore.com](https://jeremylongshore.com)*
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## Examples
|
|
2
|
+
|
|
3
|
+
### Quick Deploy Script
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
#!/bin/bash
|
|
7
|
+
# Platform-agnostic deploy helper
|
|
8
|
+
case "$1" in
|
|
9
|
+
vercel)
|
|
10
|
+
vercel secrets add supabase_api_key "$SUPABASE_API_KEY"
|
|
11
|
+
vercel --prod
|
|
12
|
+
;;
|
|
13
|
+
fly)
|
|
14
|
+
fly secrets set SUPABASE_API_KEY="$SUPABASE_API_KEY"
|
|
15
|
+
fly deploy
|
|
16
|
+
;;
|
|
17
|
+
esac
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
*[Tons of Skills](https://tonsofskills.com) by [Intent Solutions](https://intentsolutions.io) | [jeremylongshore.com](https://jeremylongshore.com)*
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Google Cloud Run
|
|
2
|
+
|
|
3
|
+
## Google Cloud Run
|
|
4
|
+
|
|
5
|
+
### Dockerfile
|
|
6
|
+
|
|
7
|
+
```dockerfile
|
|
8
|
+
FROM node:20-slim
|
|
9
|
+
WORKDIR /app
|
|
10
|
+
COPY package*.json ./
|
|
11
|
+
RUN npm ci --only=production
|
|
12
|
+
COPY . .
|
|
13
|
+
CMD ["npm", "start"]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Deploy Script
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
#!/bin/bash
|
|
20
|
+
# deploy-cloud-run.sh
|
|
21
|
+
|
|
22
|
+
PROJECT_ID="${GOOGLE_CLOUD_PROJECT}"
|
|
23
|
+
SERVICE_NAME="supabase-service"
|
|
24
|
+
REGION="us-central1"
|
|
25
|
+
|
|
26
|
+
# Build and push image
|
|
27
|
+
gcloud builds submit --tag gcr.io/$PROJECT_ID/$SERVICE_NAME
|
|
28
|
+
|
|
29
|
+
# Deploy to Cloud Run
|
|
30
|
+
gcloud run deploy $SERVICE_NAME \
|
|
31
|
+
--image gcr.io/$PROJECT_ID/$SERVICE_NAME \
|
|
32
|
+
--region $REGION \
|
|
33
|
+
--platform managed \
|
|
34
|
+
--allow-unauthenticated \
|
|
35
|
+
--set-secrets=SUPABASE_API_KEY=supabase-api-key:latest
|
|
36
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Vercel Deployment
|
|
2
|
+
|
|
3
|
+
## Vercel Deployment
|
|
4
|
+
|
|
5
|
+
### Environment Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Add Supabase secrets to Vercel
|
|
9
|
+
vercel secrets add supabase_api_key sk_live_***
|
|
10
|
+
vercel secrets add supabase_webhook_secret whsec_***
|
|
11
|
+
|
|
12
|
+
# Link to project
|
|
13
|
+
vercel link
|
|
14
|
+
|
|
15
|
+
# Deploy preview
|
|
16
|
+
vercel
|
|
17
|
+
|
|
18
|
+
# Deploy production
|
|
19
|
+
vercel --prod
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### vercel.json Configuration
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"env": {
|
|
27
|
+
"SUPABASE_API_KEY": "@supabase_api_key"
|
|
28
|
+
},
|
|
29
|
+
"functions": {
|
|
30
|
+
"api/**/*.ts": {
|
|
31
|
+
"maxDuration": 30
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|