-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inference-gateway FDW to queue instance (#860)
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
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,30 @@ | ||
CREATE EXTENSION IF NOT EXISTS postgres_fdw; | ||
CREATE EXTENSION IF NOT EXISTS pg_cron; | ||
|
||
CREATE SERVER IF NOT EXISTS cp_queue_server | ||
FOREIGN DATA WRAPPER postgres_fdw | ||
OPTIONS (host 'localhost', port '5432', dbname 'postgres'); | ||
|
||
CREATE USER MAPPING IF NOT EXISTS FOR postgres | ||
SERVER cp_queue_server | ||
OPTIONS (user 'postgres', password 'postgres'); | ||
|
||
CREATE FOREIGN TABLE IF NOT EXISTS fdw_paid_organizations ( | ||
organization_id text NOT NULL, | ||
has_cc boolean not null default false, | ||
last_updated_at timestamp with time zone not null default now() | ||
) | ||
SERVER cp_queue_server | ||
OPTIONS (schema_name 'billing', table_name 'paid_organizations'); | ||
|
||
SELECT cron.schedule('refresh-validations', '* * * * *', $$ | ||
BEGIN; | ||
TRUNCATE inference.org_validation; | ||
INSERT INTO inference.org_validation | ||
SELECT | ||
organization_id as org_id, | ||
has_cc as valid, | ||
now() as last_updated_at | ||
FROM fdw_paid_organizations; | ||
COMMIT; | ||
$$); |
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