Skip to content

Conversation

@jumski
Copy link
Contributor

@jumski jumski commented Dec 4, 2025

Add pgflow.is_local() function to detect local development environment

This PR adds a new SQL function pgflow.is_local() that detects whether the application is running in a local Supabase CLI environment by checking if the JWT secret matches the known hardcoded local value.

The function:

  • Returns true only when the JWT secret exactly matches the Supabase CLI's default value
  • Returns false in all other cases (production environments, custom JWT secrets)
  • Is designed to be production-safe with a default of false
  • Uses coalesce to handle missing configuration values

Added comprehensive tests to verify the function works correctly in different scenarios:

  • When JWT secret matches the local Supabase value
  • When JWT secret is empty/missing (simulates hosted environments)
  • When JWT secret has a different custom value

This utility will help implement environment-specific behaviors without requiring explicit configuration.

@changeset-bot
Copy link

changeset-bot bot commented Dec 4, 2025

⚠️ No Changeset found

Latest commit: 5166c57

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@nx-cloud
Copy link

nx-cloud bot commented Dec 4, 2025

View your CI Pipeline Execution ↗ for commit 5166c57

Command Status Duration Result
nx run edge-worker:test:integration ✅ Succeeded 3m 42s View ↗
nx affected -t verify-exports --base=origin/mai... ✅ Succeeded 4s View ↗
nx affected -t build --configuration=production... ✅ Succeeded 31s View ↗
nx affected -t lint typecheck test --parallel -... ✅ Succeeded 2m 19s View ↗
nx run client:e2e ✅ Succeeded 1m 9s View ↗
nx run edge-worker:e2e ✅ Succeeded 44s View ↗
nx run cli:e2e ✅ Succeeded 4s View ↗
nx run core:pgtap ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-06 09:59:05 UTC

@jumski jumski changed the base branch from main to graphite-base/502 December 5, 2025 07:17
@jumski jumski changed the base branch from graphite-base/502 to main December 5, 2025 07:17
@jumski jumski changed the base branch from main to graphite-base/502 December 5, 2025 07:17
@jumski jumski force-pushed the 12-04-add_pgflow_is_local_function branch from e2e0542 to 62bac21 Compare December 5, 2025 07:17
@jumski jumski changed the base branch from graphite-base/502 to 12-05-refactor_atlas_baseline_to_use_fresh_hosted_supabase_schema December 5, 2025 07:17
@jumski jumski changed the base branch from 12-05-refactor_atlas_baseline_to_use_fresh_hosted_supabase_schema to graphite-base/502 December 5, 2025 08:52
@jumski jumski force-pushed the graphite-base/502 branch from c5e9928 to 9561a5c Compare December 5, 2025 09:24
@jumski jumski force-pushed the 12-04-add_pgflow_is_local_function branch from 62bac21 to 66f7089 Compare December 5, 2025 09:24
@jumski jumski changed the base branch from graphite-base/502 to 12-05-refactor_atlas_baseline_to_use_fresh_hosted_supabase_schema December 5, 2025 09:24
@jumski jumski force-pushed the 12-04-add_pgflow_is_local_function branch from 66f7089 to 948f79e Compare December 5, 2025 10:04
@jumski jumski force-pushed the 12-05-refactor_atlas_baseline_to_use_fresh_hosted_supabase_schema branch from 9561a5c to 08e5f14 Compare December 5, 2025 10:04
@jumski jumski force-pushed the 12-04-add_pgflow_is_local_function branch from 948f79e to dcf6478 Compare December 5, 2025 13:05
@jumski jumski force-pushed the 12-05-refactor_atlas_baseline_to_use_fresh_hosted_supabase_schema branch from 08e5f14 to 6797882 Compare December 5, 2025 13:05
- Introduced SQL function pgflow.is_local to check if running in local Supabase CLI by matching
JWT secret
- Updated database type definitions to include is_local method
- Added migration script to create the is_local function in the database
- Included tests to verify is_local behavior with matching, missing, and different JWT secrets
- Updated migration tracking files to include the new is_local function
@jumski jumski force-pushed the 12-05-refactor_atlas_baseline_to_use_fresh_hosted_supabase_schema branch from 6797882 to 9ee0fa1 Compare December 5, 2025 22:53
@jumski jumski force-pushed the 12-04-add_pgflow_is_local_function branch from dcf6478 to 5166c57 Compare December 5, 2025 22:53
@github-actions
Copy link
Contributor

github-actions bot commented Dec 6, 2025

🔍 Preview Deployment: Website

Deployment successful!

🔗 Preview URL: https://pr-502.pgflow.pages.dev

📝 Details:

  • Branch: 12-04-add_pgflow_is_local_function
  • Commit: 11160b665d789464f5edf7f044b10d7c18eaa015
  • View Logs

_Last updated: _

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants