Skip to content

Commit a89c206

Browse files
authored
Merge pull request #4 from launchql/upgrade/sync-files
Add back sql files and content
2 parents a19c4e7 + 3383335 commit a89c206

42 files changed

Lines changed: 383 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- Deploy schemas/public/domains/origin to pg
2+
3+
-- requires: schemas/public/schema
4+
5+
BEGIN;
6+
7+
CREATE DOMAIN origin AS text CHECK (VALUE = substring(VALUE from '^(https?://[^/]*)') );
8+
COMMENT ON DOMAIN origin IS E'@name launchqlInternalTypeOrigin';
9+
10+
COMMIT;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- Revert schemas/public/domains/origin from pg
2+
3+
BEGIN;
4+
5+
DROP TYPE public.origin;
6+
7+
COMMIT;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- Verify schemas/public/domains/origin on pg
2+
3+
BEGIN;
4+
5+
SELECT verify_type ('public.origin');
6+
7+
ROLLBACK;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Deploy extension/defaults to pg
2+
3+
BEGIN;
4+
5+
-- hstore
6+
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public to public;
7+
8+
COMMIT;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Revert extension/defaults from pg
2+
3+
BEGIN;
4+
5+
COMMIT;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Verify extension/defaults on pg
2+
3+
BEGIN;
4+
5+
ROLLBACK;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- Deploy schemas/ctx/procedures/ip_address to pg
2+
3+
-- requires: schemas/ctx/schema
4+
5+
BEGIN;
6+
7+
CREATE FUNCTION ctx.ip_address()
8+
RETURNS inet
9+
AS $$
10+
SELECT nullif(current_setting('jwt.claims.ip_address', true), '')::inet;
11+
$$
12+
LANGUAGE 'sql' STABLE;
13+
14+
COMMIT;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- Deploy schemas/ctx/procedures/origin to pg
2+
3+
-- requires: schemas/ctx/schema
4+
5+
BEGIN;
6+
7+
CREATE FUNCTION ctx.origin()
8+
RETURNS origin
9+
AS $$
10+
SELECT nullif(current_setting('jwt.claims.origin', true), '')::origin;
11+
$$
12+
LANGUAGE 'sql' STABLE;
13+
14+
COMMIT;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- Deploy schemas/ctx/procedures/security_definer to pg
2+
3+
-- requires: schemas/ctx/schema
4+
5+
BEGIN;
6+
7+
DO $LQLMIGRATION$
8+
DECLARE
9+
BEGIN
10+
EXECUTE format('CREATE FUNCTION ctx.security_definer() returns text as $FUNC$
11+
SELECT ''%s'';
12+
$FUNC$
13+
LANGUAGE ''sql'';', current_user);
14+
EXECUTE format('CREATE FUNCTION ctx.is_security_definer() returns bool as $FUNC$
15+
SELECT ''%s'' = current_user;
16+
$FUNC$
17+
LANGUAGE ''sql'';', current_user);
18+
END;
19+
$LQLMIGRATION$;
20+
GRANT EXECUTE ON FUNCTION ctx.security_definer() TO PUBLIC;
21+
GRANT EXECUTE ON FUNCTION ctx.is_security_definer() TO PUBLIC;
22+
23+
COMMIT;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- Deploy schemas/ctx/procedures/user_agent to pg
2+
3+
-- requires: schemas/ctx/schema
4+
5+
BEGIN;
6+
7+
CREATE FUNCTION ctx.user_agent()
8+
RETURNS text
9+
AS $$
10+
SELECT nullif(current_setting('jwt.claims.user_agent', true), '');
11+
$$
12+
LANGUAGE 'sql' STABLE;
13+
14+
COMMIT;

0 commit comments

Comments
 (0)