Skip to content

Commit

Permalink
Merge pull request #134 from datagrove/bugFix
Browse files Browse the repository at this point in the history
Bug fix
  • Loading branch information
r-southworth authored Aug 19, 2024
2 parents 80c7b64 + c4d56ba commit 4a64991
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
23 changes: 10 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions supabase/migrations/20240819181951_stripeWrapperKeys.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
CREATE SERVER stripe_server FOREIGN DATA WRAPPER stripe_wrapper OPTIONS (api_key_id 'placeholder');

CREATE PROCEDURE install_stripe_secret_reference() AS $$
DECLARE
vault_key_id TEXT;
BEGIN
SELECT key_id::TEXT FROM vault.secrets WHERE name='stripe' INTO vault_key_id;
IF vault_key_id IS NOT NULL THEN
EXECUTE 'ALTER SERVER stripe_server OPTIONS (SET api_key_id ' || quote_literal(vault_key_id) || ')';
END IF;
END
$$ LANGUAGE PLPGSQL;
COMMENT ON PROCEDURE install_stripe_secret_reference() IS 'Look up the Stripe key_id from the vault and set it in the server wrapper';

REVOKE ALL ON PROCEDURE install_stripe_secret_reference FROM PUBLIC,authenticated,anon;

CALL install_stripe_secret_reference();

create schema stripe;

create foreign table stripe.prices (
id text,
active bool,
currency text,
product text,
unit_amount bigint,
type text,
created timestamp,
attrs jsonb
)
server stripe_server
options (
object 'prices'
);

0 comments on commit 4a64991

Please sign in to comment.