-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from datagrove/bugFix
Bug fix
- Loading branch information
Showing
2 changed files
with
44 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
); |