diff --git a/packages/twenty-docker/twenty-postgres-spilo/Dockerfile b/packages/twenty-docker/twenty-postgres-spilo/Dockerfile index 3cb4b1504..21e107c47 100644 --- a/packages/twenty-docker/twenty-postgres-spilo/Dockerfile +++ b/packages/twenty-docker/twenty-postgres-spilo/Dockerfile @@ -1,6 +1,6 @@ ARG POSTGRES_VERSION=15 ARG SPILO_VERSION=3.2-p1 -ARG PG_GRAPHQL_VERSION=1.5.1 +ARG PG_GRAPHQL_VERSION=1.5.6 ARG WRAPPERS_VERSION=0.2.0 # Build the mysql_fdw extension diff --git a/packages/twenty-docker/twenty-postgres/Dockerfile b/packages/twenty-docker/twenty-postgres/Dockerfile index 91cf357a4..5647a6cd3 100644 --- a/packages/twenty-docker/twenty-postgres/Dockerfile +++ b/packages/twenty-docker/twenty-postgres/Dockerfile @@ -3,7 +3,7 @@ ARG IMAGE_TAG='15.5.0-debian-11-r15' FROM bitnami/postgresql:${IMAGE_TAG} ARG PG_MAIN_VERSION=15 -ARG PG_GRAPHQL_VERSION=1.5.1 +ARG PG_GRAPHQL_VERSION=1.5.6 ARG WRAPPERS_VERSION=0.2.0 ARG TARGETARCH diff --git a/packages/twenty-postgres/linux/Dockerfile b/packages/twenty-postgres/linux/Dockerfile index c8996796c..871f87dff 100644 --- a/packages/twenty-postgres/linux/Dockerfile +++ b/packages/twenty-postgres/linux/Dockerfile @@ -3,7 +3,7 @@ ARG IMAGE_TAG='15.5.0-debian-11-r15' FROM bitnami/postgresql:${IMAGE_TAG} ARG PG_MAIN_VERSION=15 -ARG PG_GRAPHQL_VERSION=1.5.1 +ARG PG_GRAPHQL_VERSION=1.5.6 ARG WRAPPERS_VERSION=0.2.0 ARG TARGETARCH diff --git a/packages/twenty-postgres/linux/amd64/15/pg_graphql/1.5.6/pg_graphql--1.5.6.sql b/packages/twenty-postgres/linux/amd64/15/pg_graphql/1.5.6/pg_graphql--1.5.6.sql new file mode 100644 index 000000000..b5489e7cd --- /dev/null +++ b/packages/twenty-postgres/linux/amd64/15/pg_graphql/1.5.6/pg_graphql--1.5.6.sql @@ -0,0 +1,116 @@ +/* +This file is auto generated by pgrx. + +The ordering of items is not stable, it is driven by a dependency graph. +*/ + +-- src/lib.rs:27 +-- pg_graphql::_internal_resolve +CREATE FUNCTION graphql."_internal_resolve"( + "query" TEXT, /* &str */ + "variables" jsonb DEFAULT '{}', /* core::option::Option */ + "operationName" TEXT DEFAULT null, /* core::option::Option */ + "extensions" jsonb DEFAULT null /* core::option::Option */ +) RETURNS jsonb /* pgrx::datum::json::JsonB */ + +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'resolve_wrapper'; + +-- src/lib.rs:22 +create or replace function graphql.exception(message text) + returns text + language plpgsql +as $$ +begin + raise exception using errcode='22000', message=message; +end; +$$; + + +-- src/lib.rs:23 +-- requires: +-- resolve + +create or replace function graphql.resolve( + "query" text, + "variables" jsonb default '{}', + "operationName" text default null, + "extensions" jsonb default null +) + returns jsonb + language plpgsql +as $$ +declare + res jsonb; + message_text text; +begin + begin + select graphql._internal_resolve("query" := "query", + "variables" := "variables", + "operationName" := "operationName", + "extensions" := "extensions") into res; + return res; + exception + when others then + get stacked diagnostics message_text = message_text; + return + jsonb_build_object('data', null, + 'errors', jsonb_build_array(jsonb_build_object('message', message_text))); + end; +end; +$$; + + +-- src/lib.rs:21 +create function graphql.comment_directive(comment_ text) + returns jsonb + language sql + immutable +as $$ + /* + comment on column public.account.name is '@graphql.name: myField' + */ + select + coalesce( + ( + regexp_match( + comment_, + '@graphql\((.+?)\)' + ) + )[1]::jsonb, + jsonb_build_object() + ) +$$; + + +-- src/lib.rs:20 +-- Is updated every time the schema changes +create sequence if not exists graphql.seq_schema_version as int cycle; + +create or replace function graphql.increment_schema_version() + returns event_trigger + security definer + language plpgsql +as $$ +begin + perform nextval('graphql.seq_schema_version'); +end; +$$; + +create or replace function graphql.get_schema_version() + returns int + security definer + language sql +as $$ + select last_value from graphql.seq_schema_version; +$$; + +-- On DDL event, increment the schema version number +create event trigger graphql_watch_ddl + on ddl_command_end + execute procedure graphql.increment_schema_version(); + +create event trigger graphql_watch_drop + on sql_drop + execute procedure graphql.increment_schema_version(); + diff --git a/packages/twenty-postgres/linux/amd64/15/pg_graphql/1.5.6/pg_graphql.control b/packages/twenty-postgres/linux/amd64/15/pg_graphql/1.5.6/pg_graphql.control new file mode 100644 index 000000000..56c20ea62 --- /dev/null +++ b/packages/twenty-postgres/linux/amd64/15/pg_graphql/1.5.6/pg_graphql.control @@ -0,0 +1,6 @@ +comment = 'pg_graphql: GraphQL support' +default_version = '1.5.6' +module_pathname = '$libdir/pg_graphql' +relocatable = false +superuser = true +schema = 'graphql' diff --git a/packages/twenty-postgres/linux/amd64/15/pg_graphql/1.5.6/pg_graphql.so b/packages/twenty-postgres/linux/amd64/15/pg_graphql/1.5.6/pg_graphql.so new file mode 100755 index 000000000..9d1667369 Binary files /dev/null and b/packages/twenty-postgres/linux/amd64/15/pg_graphql/1.5.6/pg_graphql.so differ diff --git a/packages/twenty-postgres/linux/arm64/15/pg_graphql/1.5.6/pg_graphql--1.5.6.sql b/packages/twenty-postgres/linux/arm64/15/pg_graphql/1.5.6/pg_graphql--1.5.6.sql new file mode 100644 index 000000000..35a393c22 --- /dev/null +++ b/packages/twenty-postgres/linux/arm64/15/pg_graphql/1.5.6/pg_graphql--1.5.6.sql @@ -0,0 +1,116 @@ +/* +This file is auto generated by pgrx. + +The ordering of items is not stable, it is driven by a dependency graph. +*/ + +-- src/lib.rs:27 +-- pg_graphql::_internal_resolve +CREATE FUNCTION graphql."_internal_resolve"( + "query" TEXT, /* &str */ + "variables" jsonb DEFAULT '{}', /* core::option::Option */ + "operationName" TEXT DEFAULT null, /* core::option::Option */ + "extensions" jsonb DEFAULT null /* core::option::Option */ +) RETURNS jsonb /* pgrx::datum::json::JsonB */ + +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'resolve_wrapper'; + +-- src/lib.rs:21 +create function graphql.comment_directive(comment_ text) + returns jsonb + language sql + immutable +as $$ + /* + comment on column public.account.name is '@graphql.name: myField' + */ + select + coalesce( + ( + regexp_match( + comment_, + '@graphql\((.+?)\)' + ) + )[1]::jsonb, + jsonb_build_object() + ) +$$; + + +-- src/lib.rs:22 +create or replace function graphql.exception(message text) + returns text + language plpgsql +as $$ +begin + raise exception using errcode='22000', message=message; +end; +$$; + + +-- src/lib.rs:20 +-- Is updated every time the schema changes +create sequence if not exists graphql.seq_schema_version as int cycle; + +create or replace function graphql.increment_schema_version() + returns event_trigger + security definer + language plpgsql +as $$ +begin + perform nextval('graphql.seq_schema_version'); +end; +$$; + +create or replace function graphql.get_schema_version() + returns int + security definer + language sql +as $$ + select last_value from graphql.seq_schema_version; +$$; + +-- On DDL event, increment the schema version number +create event trigger graphql_watch_ddl + on ddl_command_end + execute procedure graphql.increment_schema_version(); + +create event trigger graphql_watch_drop + on sql_drop + execute procedure graphql.increment_schema_version(); + + +-- src/lib.rs:23 +-- requires: +-- resolve + +create or replace function graphql.resolve( + "query" text, + "variables" jsonb default '{}', + "operationName" text default null, + "extensions" jsonb default null +) + returns jsonb + language plpgsql +as $$ +declare + res jsonb; + message_text text; +begin + begin + select graphql._internal_resolve("query" := "query", + "variables" := "variables", + "operationName" := "operationName", + "extensions" := "extensions") into res; + return res; + exception + when others then + get stacked diagnostics message_text = message_text; + return + jsonb_build_object('data', null, + 'errors', jsonb_build_array(jsonb_build_object('message', message_text))); + end; +end; +$$; + diff --git a/packages/twenty-postgres/linux/arm64/15/pg_graphql/1.5.6/pg_graphql.control b/packages/twenty-postgres/linux/arm64/15/pg_graphql/1.5.6/pg_graphql.control new file mode 100644 index 000000000..56c20ea62 --- /dev/null +++ b/packages/twenty-postgres/linux/arm64/15/pg_graphql/1.5.6/pg_graphql.control @@ -0,0 +1,6 @@ +comment = 'pg_graphql: GraphQL support' +default_version = '1.5.6' +module_pathname = '$libdir/pg_graphql' +relocatable = false +superuser = true +schema = 'graphql' diff --git a/packages/twenty-postgres/linux/arm64/15/pg_graphql/1.5.6/pg_graphql.so b/packages/twenty-postgres/linux/arm64/15/pg_graphql/1.5.6/pg_graphql.so new file mode 100755 index 000000000..462b79453 Binary files /dev/null and b/packages/twenty-postgres/linux/arm64/15/pg_graphql/1.5.6/pg_graphql.so differ diff --git a/packages/twenty-postgres/linux/build-postgres-linux.sh b/packages/twenty-postgres/linux/build-postgres-linux.sh index 11744e774..4b6e3b218 100755 --- a/packages/twenty-postgres/linux/build-postgres-linux.sh +++ b/packages/twenty-postgres/linux/build-postgres-linux.sh @@ -48,7 +48,7 @@ EOF echo_header $BLUE " DATABASE SETUP" PG_MAIN_VERSION=15 -PG_GRAPHQL_VERSION=1.5.1 +PG_GRAPHQL_VERSION=1.5.6 CARGO_PGRX_VERSION=0.11.2 TARGETARCH=$(dpkg --print-architecture) diff --git a/packages/twenty-postgres/linux/build_postgres.md b/packages/twenty-postgres/linux/build_postgres.md index 20e7084ae..b727e05fd 100644 --- a/packages/twenty-postgres/linux/build_postgres.md +++ b/packages/twenty-postgres/linux/build_postgres.md @@ -2,21 +2,23 @@ This doc explains how to build postgresql for Twenty Build .control, .so and .pg_graphql--version.sql -> docker buildx create --name mybuilder -> docker buildx use mybuilder +``` +docker buildx create --name mybuilder +docker buildx use mybuilder +``` Do the same for in ['amd64', 'arm64'] ('amd64' builds faster) -> cd packages/twenty-postgres -> docker buildx build --platform linux/ --load -t twenty-bitnami-postgres- linux -> docker run --name twenty-bitnami- -v ~/Desktop/twenty/packages/twenty-postgres:/twenty +``` +cd packages/twenty-postgres +docker buildx build --platform linux/ --load -t twenty-bitnami-postgres- linux +docker run --name twenty-bitnami- -v ~/Desktop/twenty/packages/twenty-postgres:/twenty +``` In another terminal -> docker exec -it sh -> sh twenty/linux/build-postgres-linux.sh -> cp opt/bitnami/postgresql/lib/pg_graphql.so twenty/linux//15/pg_graphql/ -> cp opt/bitnami/postgresql/share/extension/pg_graphql.control twenty/linux//15/pg_graphql/ -> cp opt/bitnami/postgresql/share/extension/pg_graphql--.sql twenty/linux//15/pg_graphql/ - -Then -> prod-server-build -> prod-server-run +``` +docker exec -it sh +sh twenty/linux/build-postgres-linux.sh +cp opt/bitnami/postgresql/lib/pg_graphql.so twenty/linux//15/pg_graphql/ +cp opt/bitnami/postgresql/share/extension/pg_graphql.control twenty/linux//15/pg_graphql/ +cp opt/bitnami/postgresql/share/extension/pg_graphql--.sql twenty/linux//15/pg_graphql/ +``` diff --git a/packages/twenty-postgres/linux/provision-postgres-linux.sh b/packages/twenty-postgres/linux/provision-postgres-linux.sh index 651224284..620d3e887 100755 --- a/packages/twenty-postgres/linux/provision-postgres-linux.sh +++ b/packages/twenty-postgres/linux/provision-postgres-linux.sh @@ -48,7 +48,7 @@ EOF echo_header $BLUE " DATABASE SETUP" PG_MAIN_VERSION=15 -PG_GRAPHQL_VERSION=1.5.1 +PG_GRAPHQL_VERSION=1.5.6 TARGETARCH=$(dpkg --print-architecture) # Install PostgresSQL diff --git a/packages/twenty-postgres/macos/arm/15/pg_graphql/1.5.6/pg_graphql--1.5.6.sql b/packages/twenty-postgres/macos/arm/15/pg_graphql/1.5.6/pg_graphql--1.5.6.sql new file mode 100644 index 000000000..f7687883c --- /dev/null +++ b/packages/twenty-postgres/macos/arm/15/pg_graphql/1.5.6/pg_graphql--1.5.6.sql @@ -0,0 +1,116 @@ +/* +This file is auto generated by pgrx. + +The ordering of items is not stable, it is driven by a dependency graph. +*/ + +-- src/lib.rs:27 +-- pg_graphql::_internal_resolve +CREATE FUNCTION graphql."_internal_resolve"( + "query" TEXT, /* &str */ + "variables" jsonb DEFAULT '{}', /* core::option::Option */ + "operationName" TEXT DEFAULT null, /* core::option::Option */ + "extensions" jsonb DEFAULT null /* core::option::Option */ +) RETURNS jsonb /* pgrx::datum::json::JsonB */ + +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'resolve_wrapper'; + +-- src/lib.rs:22 +create or replace function graphql.exception(message text) + returns text + language plpgsql +as $$ +begin + raise exception using errcode='22000', message=message; +end; +$$; + + +-- src/lib.rs:20 +-- Is updated every time the schema changes +create sequence if not exists graphql.seq_schema_version as int cycle; + +create or replace function graphql.increment_schema_version() + returns event_trigger + security definer + language plpgsql +as $$ +begin + perform nextval('graphql.seq_schema_version'); +end; +$$; + +create or replace function graphql.get_schema_version() + returns int + security definer + language sql +as $$ + select last_value from graphql.seq_schema_version; +$$; + +-- On DDL event, increment the schema version number +create event trigger graphql_watch_ddl + on ddl_command_end + execute procedure graphql.increment_schema_version(); + +create event trigger graphql_watch_drop + on sql_drop + execute procedure graphql.increment_schema_version(); + + +-- src/lib.rs:21 +create function graphql.comment_directive(comment_ text) + returns jsonb + language sql + immutable +as $$ + /* + comment on column public.account.name is '@graphql.name: myField' + */ + select + coalesce( + ( + regexp_match( + comment_, + '@graphql\((.+?)\)' + ) + )[1]::jsonb, + jsonb_build_object() + ) +$$; + + +-- src/lib.rs:23 +-- requires: +-- resolve + +create or replace function graphql.resolve( + "query" text, + "variables" jsonb default '{}', + "operationName" text default null, + "extensions" jsonb default null +) + returns jsonb + language plpgsql +as $$ +declare + res jsonb; + message_text text; +begin + begin + select graphql._internal_resolve("query" := "query", + "variables" := "variables", + "operationName" := "operationName", + "extensions" := "extensions") into res; + return res; + exception + when others then + get stacked diagnostics message_text = message_text; + return + jsonb_build_object('data', null, + 'errors', jsonb_build_array(jsonb_build_object('message', message_text))); + end; +end; +$$; + diff --git a/packages/twenty-postgres/macos/arm/15/pg_graphql/1.5.6/pg_graphql.control b/packages/twenty-postgres/macos/arm/15/pg_graphql/1.5.6/pg_graphql.control new file mode 100644 index 000000000..56c20ea62 --- /dev/null +++ b/packages/twenty-postgres/macos/arm/15/pg_graphql/1.5.6/pg_graphql.control @@ -0,0 +1,6 @@ +comment = 'pg_graphql: GraphQL support' +default_version = '1.5.6' +module_pathname = '$libdir/pg_graphql' +relocatable = false +superuser = true +schema = 'graphql' diff --git a/packages/twenty-postgres/macos/arm/15/pg_graphql/1.5.6/pg_graphql.so b/packages/twenty-postgres/macos/arm/15/pg_graphql/1.5.6/pg_graphql.so new file mode 100755 index 000000000..c87cdbd4c Binary files /dev/null and b/packages/twenty-postgres/macos/arm/15/pg_graphql/1.5.6/pg_graphql.so differ diff --git a/packages/twenty-postgres/macos/arm/build-postgres-macos-arm.sh b/packages/twenty-postgres/macos/arm/build-postgres-macos-arm.sh index a2738797f..3decabfd7 100755 --- a/packages/twenty-postgres/macos/arm/build-postgres-macos-arm.sh +++ b/packages/twenty-postgres/macos/arm/build-postgres-macos-arm.sh @@ -48,7 +48,7 @@ EOF echo_header $BLUE " DATABASE SETUP" PG_MAIN_VERSION=15 -PG_GRAPHQL_VERSION=1.5.1 +PG_GRAPHQL_VERSION=1.5.6 CARGO_PGRX_VERSION=0.11.2 current_directory=$(pwd) diff --git a/packages/twenty-postgres/macos/arm/provision-postgres-macos-arm.sh b/packages/twenty-postgres/macos/arm/provision-postgres-macos-arm.sh index 24e987608..201a4abb2 100755 --- a/packages/twenty-postgres/macos/arm/provision-postgres-macos-arm.sh +++ b/packages/twenty-postgres/macos/arm/provision-postgres-macos-arm.sh @@ -1,7 +1,7 @@ #!/bin/bash PG_MAIN_VERSION=15 -PG_GRAPHQL_VERSION=1.5.1 +PG_GRAPHQL_VERSION=1.5.6 current_directory=$(pwd) diff --git a/packages/twenty-postgres/macos/intel/15/pg_graphql/1.5.6/pg_graphql--1.5.6.sql b/packages/twenty-postgres/macos/intel/15/pg_graphql/1.5.6/pg_graphql--1.5.6.sql new file mode 100644 index 000000000..a24d69a1a --- /dev/null +++ b/packages/twenty-postgres/macos/intel/15/pg_graphql/1.5.6/pg_graphql--1.5.6.sql @@ -0,0 +1,116 @@ +/* +This file is auto generated by pgrx. + +The ordering of items is not stable, it is driven by a dependency graph. +*/ + +-- src/lib.rs:27 +-- pg_graphql::_internal_resolve +CREATE FUNCTION graphql."_internal_resolve"( + "query" TEXT, /* &str */ + "variables" jsonb DEFAULT '{}', /* core::option::Option */ + "operationName" TEXT DEFAULT null, /* core::option::Option */ + "extensions" jsonb DEFAULT null /* core::option::Option */ +) RETURNS jsonb /* pgrx::datum::json::JsonB */ + +LANGUAGE c /* Rust */ +AS 'MODULE_PATHNAME', 'resolve_wrapper'; + +-- src/lib.rs:20 +-- Is updated every time the schema changes +create sequence if not exists graphql.seq_schema_version as int cycle; + +create or replace function graphql.increment_schema_version() + returns event_trigger + security definer + language plpgsql +as $$ +begin + perform nextval('graphql.seq_schema_version'); +end; +$$; + +create or replace function graphql.get_schema_version() + returns int + security definer + language sql +as $$ + select last_value from graphql.seq_schema_version; +$$; + +-- On DDL event, increment the schema version number +create event trigger graphql_watch_ddl + on ddl_command_end + execute procedure graphql.increment_schema_version(); + +create event trigger graphql_watch_drop + on sql_drop + execute procedure graphql.increment_schema_version(); + + +-- src/lib.rs:22 +create or replace function graphql.exception(message text) + returns text + language plpgsql +as $$ +begin + raise exception using errcode='22000', message=message; +end; +$$; + + +-- src/lib.rs:21 +create function graphql.comment_directive(comment_ text) + returns jsonb + language sql + immutable +as $$ + /* + comment on column public.account.name is '@graphql.name: myField' + */ + select + coalesce( + ( + regexp_match( + comment_, + '@graphql\((.+?)\)' + ) + )[1]::jsonb, + jsonb_build_object() + ) +$$; + + +-- src/lib.rs:23 +-- requires: +-- resolve + +create or replace function graphql.resolve( + "query" text, + "variables" jsonb default '{}', + "operationName" text default null, + "extensions" jsonb default null +) + returns jsonb + language plpgsql +as $$ +declare + res jsonb; + message_text text; +begin + begin + select graphql._internal_resolve("query" := "query", + "variables" := "variables", + "operationName" := "operationName", + "extensions" := "extensions") into res; + return res; + exception + when others then + get stacked diagnostics message_text = message_text; + return + jsonb_build_object('data', null, + 'errors', jsonb_build_array(jsonb_build_object('message', message_text))); + end; +end; +$$; + diff --git a/packages/twenty-postgres/macos/intel/15/pg_graphql/1.5.6/pg_graphql.control b/packages/twenty-postgres/macos/intel/15/pg_graphql/1.5.6/pg_graphql.control new file mode 100644 index 000000000..56c20ea62 --- /dev/null +++ b/packages/twenty-postgres/macos/intel/15/pg_graphql/1.5.6/pg_graphql.control @@ -0,0 +1,6 @@ +comment = 'pg_graphql: GraphQL support' +default_version = '1.5.6' +module_pathname = '$libdir/pg_graphql' +relocatable = false +superuser = true +schema = 'graphql' diff --git a/packages/twenty-postgres/macos/intel/15/pg_graphql/1.5.6/pg_graphql.so b/packages/twenty-postgres/macos/intel/15/pg_graphql/1.5.6/pg_graphql.so new file mode 100644 index 000000000..c6f712ec0 Binary files /dev/null and b/packages/twenty-postgres/macos/intel/15/pg_graphql/1.5.6/pg_graphql.so differ diff --git a/packages/twenty-postgres/macos/intel/build-postgres-macos-intel.sh b/packages/twenty-postgres/macos/intel/build-postgres-macos-intel.sh index a5636eac0..944f64d72 100755 --- a/packages/twenty-postgres/macos/intel/build-postgres-macos-intel.sh +++ b/packages/twenty-postgres/macos/intel/build-postgres-macos-intel.sh @@ -48,7 +48,7 @@ EOF echo_header $BLUE " DATABASE SETUP" PG_MAIN_VERSION=15 -PG_GRAPHQL_VERSION=1.5.1 +PG_GRAPHQL_VERSION=1.5.6 CARGO_PGRX_VERSION=0.11.2 current_directory=$(pwd) diff --git a/packages/twenty-postgres/macos/intel/provision-postgres-macos-intel.sh b/packages/twenty-postgres/macos/intel/provision-postgres-macos-intel.sh index c6a49fa43..72091af18 100755 --- a/packages/twenty-postgres/macos/intel/provision-postgres-macos-intel.sh +++ b/packages/twenty-postgres/macos/intel/provision-postgres-macos-intel.sh @@ -1,7 +1,7 @@ #!/bin/bash PG_MAIN_VERSION=15 -PG_GRAPHQL_VERSION=1.5.1 +PG_GRAPHQL_VERSION=1.5.6 current_directory=$(pwd)