Remove pgGraphql from setup (#7716)

## Context
This PR removes pg_graphql from the setup. It also updates the local
setup documentation accordingly.

Note: We removed local setup scripts to align with redis installation,
the setup should be much simpler since we don't rely on pg_graphql
anymore.

## Test
tested locally with docker + mac (brew) setup
This commit is contained in:
Weiko
2024-10-15 16:59:44 +02:00
committed by GitHub
parent 1de739176c
commit 7e808cf529
54 changed files with 432 additions and 2160 deletions

View File

@ -1,6 +1,5 @@
ARG POSTGRES_VERSION=15
ARG SPILO_VERSION=3.2-p1
ARG PG_GRAPHQL_VERSION=1.5.6
ARG WRAPPERS_VERSION=0.2.0
# Build the mysql_fdw extension
@ -38,10 +37,9 @@ WORKDIR /build/openssl
RUN ./config && make && make install
# Extend the Spilo image with the pg_graphql and mysql_fdw extensions
# Extend the Spilo image with the mysql_fdw extensions
FROM ghcr.io/zalando/spilo-${POSTGRES_VERSION}:${SPILO_VERSION}
ARG POSTGRES_VERSION
ARG PG_GRAPHQL_VERSION
ARG WRAPPERS_VERSION
ARG TARGETARCH
@ -63,14 +61,6 @@ RUN curl -L "https://github.com/supabase/wrappers/releases/download/v${WRAPPERS_
COPY --from=build-libssl /usr/local/lib/libssl* /usr/local/lib/libcrypto* /usr/lib/
COPY --from=build-libssl /usr/local/lib/engines-1.1 /usr/lib/engines-1.1
# Copy pg_graphql
COPY ./packages/twenty-postgres/linux/${TARGETARCH}/${POSTGRES_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql--${PG_GRAPHQL_VERSION}.sql \
/usr/share/postgresql/${POSTGRES_VERSION}/extension
COPY ./packages/twenty-postgres/linux/${TARGETARCH}/${POSTGRES_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.control \
/usr/share/postgresql/${POSTGRES_VERSION}/extension
COPY ./packages/twenty-postgres/linux/${TARGETARCH}/${POSTGRES_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.so \
/usr/lib/postgresql/${POSTGRES_VERSION}/lib/pg_graphql.so
# Copy mysql_fdw
COPY --from=build-mysql_fdw /mysql_fdw/mysql_fdw.so \
/usr/lib/postgresql/${POSTGRES_VERSION}/lib/mysql_fdw.so

View File

@ -3,7 +3,6 @@ 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.6
ARG WRAPPERS_VERSION=0.2.0
ARG TARGETARCH
@ -26,14 +25,6 @@ RUN set -eux; \
RUN apt update && apt install build-essential git curl default-libmysqlclient-dev -y
# Install precompiled pg_graphql extensions
COPY ./packages/twenty-postgres/linux/${TARGETARCH}/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql--${PG_GRAPHQL_VERSION}.sql \
/opt/bitnami/postgresql/share/extension/
COPY ./packages/twenty-postgres/linux/${TARGETARCH}/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.control \
/opt/bitnami/postgresql/share/extension/
COPY ./packages/twenty-postgres/linux/${TARGETARCH}/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.so \
/opt/bitnami/postgresql/lib/
# Install precompiled supabase wrappers extensions
RUN curl -L "https://github.com/supabase/wrappers/releases/download/v${WRAPPERS_VERSION}/wrappers-v${WRAPPERS_VERSION}-pg${PG_MAIN_VERSION}-${TARGETARCH}-linux-gnu.deb" -o wrappers.deb
RUN dpkg --install wrappers.deb

View File

@ -1,12 +0,0 @@
provision-on-docker:
@docker compose -f docker/docker-compose.yml up
provision-on-macos-arm:
sh ./macos/arm/provision-postgres-macos-arm.sh
provision-on-macos-intel:
sh ./macos/intel/provision-postgres-macos-intel.sh
provision-on-linux:
sh ./linux/provision-postgres-linux.sh

View File

@ -1,17 +0,0 @@
version: "3.9"
services:
postgres:
container_name: twenty_postgres
image: twentycrm/twenty-postgres:latest
volumes:
- twenty_db_data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=default
ports:
- "5432:5432"
volumes:
twenty_db_data:
name: twenty_db_data

View File

@ -1,4 +0,0 @@
CREATE DATABASE "default";
CREATE DATABASE "test";
CREATE USER twenty PASSWORD 'twenty';
ALTER ROLE twenty superuser;

View File

@ -1,12 +0,0 @@
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.6
ARG WRAPPERS_VERSION=0.2.0
ARG TARGETARCH
USER root
CMD ["tail", "-f", "/dev/null"]

View File

@ -1,116 +0,0 @@
/*
This file is auto generated by pgrx.
The ordering of items is not stable, it is driven by a dependency graph.
*/
-- src/lib.rs:26
-- pg_graphql::_internal_resolve
CREATE FUNCTION graphql."_internal_resolve"(
"query" TEXT, /* &str */
"variables" jsonb DEFAULT '{}', /* core::option::Option<pgrx::datum::json::JsonB> */
"operationName" TEXT DEFAULT null, /* core::option::Option<alloc::string::String> */
"extensions" jsonb DEFAULT null /* core::option::Option<pgrx::datum::json::JsonB> */
) RETURNS jsonb /* pgrx::datum::json::JsonB */
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'resolve_wrapper';
-- src/lib.rs:21
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:19
-- 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
-- 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:20
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()
)
$$;

View File

@ -1,6 +0,0 @@
comment = 'pg_graphql: GraphQL support'
default_version = '1.4.2'
module_pathname = '$libdir/pg_graphql'
relocatable = false
superuser = true
schema = 'graphql'

View File

@ -1,116 +0,0 @@
/*
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<pgrx::datum::json::JsonB> */
"operationName" TEXT DEFAULT null, /* core::option::Option<alloc::string::String> */
"extensions" jsonb DEFAULT null /* core::option::Option<pgrx::datum::json::JsonB> */
) RETURNS jsonb /* pgrx::datum::json::JsonB */
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'resolve_wrapper';
-- 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: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()
)
$$;

View File

@ -1,6 +0,0 @@
comment = 'pg_graphql: GraphQL support'
default_version = '1.5.1'
module_pathname = '$libdir/pg_graphql'
relocatable = false
superuser = true
schema = 'graphql'

View File

@ -1,116 +0,0 @@
/*
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<pgrx::datum::json::JsonB> */
"operationName" TEXT DEFAULT null, /* core::option::Option<alloc::string::String> */
"extensions" jsonb DEFAULT null /* core::option::Option<pgrx::datum::json::JsonB> */
) 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();

View File

@ -1,6 +0,0 @@
comment = 'pg_graphql: GraphQL support'
default_version = '1.5.6'
module_pathname = '$libdir/pg_graphql'
relocatable = false
superuser = true
schema = 'graphql'

View File

@ -1,116 +0,0 @@
/*
This file is auto generated by pgrx.
The ordering of items is not stable, it is driven by a dependency graph.
*/
-- src/lib.rs:26
-- pg_graphql::_internal_resolve
CREATE FUNCTION graphql."_internal_resolve"(
"query" TEXT, /* &str */
"variables" jsonb DEFAULT '{}', /* core::option::Option<pgrx::datum::json::JsonB> */
"operationName" TEXT DEFAULT null, /* core::option::Option<alloc::string::String> */
"extensions" jsonb DEFAULT null /* core::option::Option<pgrx::datum::json::JsonB> */
) RETURNS jsonb /* pgrx::datum::json::JsonB */
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'resolve_wrapper';
-- src/lib.rs:19
-- 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
-- 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 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
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()
)
$$;

View File

@ -1,6 +0,0 @@
comment = 'pg_graphql: GraphQL support'
default_version = '1.4.2'
module_pathname = '$libdir/pg_graphql'
relocatable = false
superuser = true
schema = 'graphql'

View File

@ -1,116 +0,0 @@
/*
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<pgrx::datum::json::JsonB> */
"operationName" TEXT DEFAULT null, /* core::option::Option<alloc::string::String> */
"extensions" jsonb DEFAULT null /* core::option::Option<pgrx::datum::json::JsonB> */
) 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: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: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;
$$;

View File

@ -1,6 +0,0 @@
comment = 'pg_graphql: GraphQL support'
default_version = '1.5.1'
module_pathname = '$libdir/pg_graphql'
relocatable = false
superuser = true
schema = 'graphql'

View File

@ -1,116 +0,0 @@
/*
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<pgrx::datum::json::JsonB> */
"operationName" TEXT DEFAULT null, /* core::option::Option<alloc::string::String> */
"extensions" jsonb DEFAULT null /* core::option::Option<pgrx::datum::json::JsonB> */
) 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;
$$;

View File

@ -1,6 +0,0 @@
comment = 'pg_graphql: GraphQL support'
default_version = '1.5.6'
module_pathname = '$libdir/pg_graphql'
relocatable = false
superuser = true
schema = 'graphql'

View File

@ -1,121 +0,0 @@
#!/bin/bash
# Colors
RED=31
GREEN=32
BLUE=34
# Function to display colored output
echo_header () {
COLOR=$1
MESSAGE=$2
echo "\e[${COLOR}m\n=======================================================\e[0m"
echo "\e[${COLOR}m${MESSAGE}\e[0m"
echo "\e[${COLOR}m=======================================================\e[0m"
}
# Function to handle errors
handle_error () {
echo_header $RED "Error: $1"
exit 1
}
cat << "EOF"
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@#*+=================@@@@@%*+=========++*%@@@@@@@
@@@@#- .+@@%=. .+@@@@@
@@@- .*@@%- .#@@@
@@= .=+++++++++++*#@@@= -++++++++++- %@@
@@. %@@@@@@@@@@@@@@@+ =%@@@@@@@@@@@@= +@@
@@. .@@@@@@@@@@@@@@+. -%@@@@@@@@@@@@@@+ +@@
@@. .@@@@@@@@@@@@*. -#@@#:=@@@@@@@@@@@= +@@
@@ @@@@@@@@@@#: :#@@#: -@@@@@@@@@@@= +@@
@@#====#@@@@@@@@#- .*@@@= -@@@@@@@@@@@= +@@
@@@@@@@@@@@@@@%- .*@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@@@@%= +@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@@@+ =@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@+. -%@@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@*. -%@@@@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@#: :#@@@@@@@@@@@@@# -@@@@@@@@@@@+ +@@
@@@#: :#@@@@@@@@@@@@@@@# :@@@@@@@@@@@= +@@
@@= :+*+++++++++++*%@@@. :+++++++++- %@@
@@ :@@@%. .#@@@
@@- :@@@@@+: .+@@@@@
@@@#+===================+%@@@@@@@%*++=======++*%@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
EOF
echo_header $BLUE " DATABASE SETUP"
PG_MAIN_VERSION=15
PG_GRAPHQL_VERSION=1.5.6
CARGO_PGRX_VERSION=0.11.2
TARGETARCH=$(dpkg --print-architecture)
# Install PostgresSQL
echo_header $GREEN "Step [1/4]: Installing PostgreSQL..."
apt update -y || handle_error "Failed to update package list."
apt install -y curl || handle_error "Failed to install curl."
apt install -y sudo || handle_error "Failed to install sudo."
apt install build-essential -y || handle_error "Failed to install build-essential."
apt install pkg-config -y || handle_error "Failed to install pkg-config."
apt install libssl-dev -y || handle_error "Failed to install libssl-dev."
apt install libreadline-dev -y || handle_error "Failed to install libreadline-dev."
apt install zlib1g-dev -y || handle_error "Failed to install zlib1g-dev."
apt install unzip -y || handle_error "Failed to install unzip."
apt install libclang-dev -y || handle_error "Failed to install libclang-dev."
# Install pg_graphql extensions
current_directory=$(pwd)
script_directory="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
existing_rust_path=$(which rustc)
if [ -n "$existing_rust_path" ]; then
echo "Uninstalling existing Rust installation..."
rm -rf "$existing_rust_path"
fi
# To force a reinstall of cargo-pgrx, pass --force to the command below
curl https://sh.rustup.rs -sSf | sh
source "$HOME/.cargo/env" || . "$HOME/.cargo/env"
cargo install --locked cargo-pgrx@$CARGO_PGRX_VERSION --force || handle_error "Failed to install cargo"
cargo pgrx init --pg$PG_MAIN_VERSION download || handle_error "Failed to init postgresql"
# Create a temporary directory
temp_dir=$(mktemp -d)
cd "$temp_dir"
curl -LJO https://github.com/supabase/pg_graphql/archive/refs/tags/v$PG_GRAPHQL_VERSION.zip || handle_error "Failed to download pg_graphql package."
unzip pg_graphql-$PG_GRAPHQL_VERSION.zip
cd "pg_graphql-$PG_GRAPHQL_VERSION"
# Apply patches to pg_graphql files
echo "Applying patches to pg_graphql files..."
for patch_file in "/twenty/patches/pg_graphql/"*.patch; do
echo "Applying patch: $patch_file"
patch -p1 < "$patch_file"
done
echo_header $GREEN "Step [2/4]: Building PostgreSQL service..."
cargo pgrx install --release --pg-config /opt/bitnami/postgresql/bin/pg_config || handle_error "Failed to build postgresql"
# Clean up the temporary directory
echo "Cleaning up..."
cd "$current_directory"
rm -rf "$temp_dir"
# Start postgresql service
echo_header $GREEN "Step [3/4]: Starting PostgreSQL service..."
if sudo service postgresql start; then
echo "PostgreSQL service started successfully."
else
handle_error "Failed to start PostgreSQL service."
fi
# Run the init.sql to setup database
echo_header $GREEN "Step [4/4]: Setting up database..."
cp ./init.sql /tmp/init.sql
sudo -u postgres psql -f /tmp/init.sql || handle_error "Failed to execute init.sql script."

View File

@ -1,24 +0,0 @@
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
```
Do the same for <PLATFORM> in ['amd64', 'arm64'] ('amd64' builds faster)
```
cd packages/twenty-postgres
docker buildx build --platform linux/<PLATFORM> --load -t twenty-bitnami-postgres-<PLATFORM> linux
docker run --name twenty-bitnami-<PLATFORM> -v ~/Desktop/twenty/packages/twenty-postgres:/twenty <IMAGE_TAG>
```
In another terminal
```
docker exec -it <CONTAINER_TAG> sh
sh twenty/linux/build-postgres-linux.sh
cp opt/bitnami/postgresql/lib/pg_graphql.so twenty/linux/<PLATFORM>/15/pg_graphql/<PG_GRAPHQL_VERSION>
cp opt/bitnami/postgresql/share/extension/pg_graphql.control twenty/linux/<PLATFORM>/15/pg_graphql/<PG_GRAPHQL_VERSION>
cp opt/bitnami/postgresql/share/extension/pg_graphql--<PG_GRAPHQL_VERSION>.sql twenty/linux/<PLATFORM>/15/pg_graphql/<PG_GRAPHQL_VERSION>
```

View File

@ -1,125 +0,0 @@
#!/bin/sh
# Colors
RED=31
GREEN=32
BLUE=34
# Function to display colored output
echo_header () {
COLOR=$1
MESSAGE=$2
echo "\e[${COLOR}m\n=======================================================\e[0m"
echo "\e[${COLOR}m${MESSAGE}\e[0m"
echo "\e[${COLOR}m=======================================================\e[0m"
}
# Function to handle errors
handle_error () {
echo_header $RED "Error: $1"
exit 1
}
read -p "This script uses sudo to install PostgreSQL, curl, and configure the system. Do you want to run this script? [y/N] " AGREEMENT
if ! echo "$AGREEMENT" | grep -iq "^y"; then
exit 1
fi
cat << "EOF"
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@#*+=================@@@@@%*+=========++*%@@@@@@@
@@@@#- .+@@%=. .+@@@@@
@@@- .*@@%- .#@@@
@@= .=+++++++++++*#@@@= -++++++++++- %@@
@@. %@@@@@@@@@@@@@@@+ =%@@@@@@@@@@@@= +@@
@@. .@@@@@@@@@@@@@@+. -%@@@@@@@@@@@@@@+ +@@
@@. .@@@@@@@@@@@@*. -#@@#:=@@@@@@@@@@@= +@@
@@ @@@@@@@@@@#: :#@@#: -@@@@@@@@@@@= +@@
@@#====#@@@@@@@@#- .*@@@= -@@@@@@@@@@@= +@@
@@@@@@@@@@@@@@%- .*@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@@@@%= +@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@@@+ =@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@+. -%@@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@*. -%@@@@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@#: :#@@@@@@@@@@@@@# -@@@@@@@@@@@+ +@@
@@@#: :#@@@@@@@@@@@@@@@# :@@@@@@@@@@@= +@@
@@= :+*+++++++++++*%@@@. :+++++++++- %@@
@@ :@@@%. .#@@@
@@- :@@@@@+: .+@@@@@
@@@#+===================+%@@@@@@@%*++=======++*%@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
EOF
echo_header $BLUE " DATABASE SETUP"
PG_MAIN_VERSION=15
PG_GRAPHQL_VERSION=1.5.6
if command -v dpkg &> /dev/null; then
TARGETARCH=$(dpkg --print-architecture)
else
TARGETARCH=$(uname -m)
fi
# Detect package manager and set up PostgreSQL and curl
if command -v dpkg &> /dev/null; then
PACKAGE_MANAGER="dpkg"
elif command -v pacman &> /dev/null; then
PACKAGE_MANAGER="pacman"
else
handle_error "Unsupported package manager. This script only supports dpkg and pacman."
fi
# Installation for Debian/Ubuntu
if [ "$PACKAGE_MANAGER" = "dpkg" ]; then
echo_header $GREEN "Step [1/4]: Installing PostgreSQL on Debian/Ubuntu..."
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
sudo apt update -y || handle_error "Failed to update package list."
sudo apt install -y postgresql-$PG_MAIN_VERSION postgresql-contrib-$PG_MAIN_VERSION curl || handle_error "Failed to install PostgreSQL or curl."
echo_header $GREEN "Step [2/4]: Installing GraphQL for PostgreSQL on Debian/Ubuntu..."
curl -L https://github.com/supabase/pg_graphql/releases/download/v$PG_GRAPHQL_VERSION/pg_graphql-v$PG_GRAPHQL_VERSION-pg$PG_MAIN_VERSION-$TARGETARCH-linux-gnu.deb -o pg_graphql.deb || handle_error "Failed to download pg_graphql package."
sudo dpkg --install pg_graphql.deb || handle_error "Failed to install pg_graphql package."
rm pg_graphql.deb
echo_header $GREEN "Step [3/4]: Starting PostgreSQL service..."
if sudo service postgresql start; then
echo "PostgreSQL service started successfully."
else
handle_error "Failed to start PostgreSQL service."
fi
# Installation for Arch
elif [ "$PACKAGE_MANAGER" = "pacman" ]; then
echo_header $GREEN "Step [1/4]: Installing PostgreSQL on Arch..."
sudo pacman -Syu --noconfirm || handle_error "Failed to update package list."
sudo pacman -S postgresql postgresql-libs curl --noconfirm || handle_error "Failed to install PostgreSQL or curl."
echo_header $GREEN "Step [2/4]: Installing GraphQL for PostgreSQL on Arch..."
if ! yay -S --noconfirm pg_graphql && ! paru -S --noconfirm pg_graphql; then
handle_error "Failed to install pg_graphql package from AUR."
fi
echo_header $GREEN "Step [3/4]: Initializing and starting PostgreSQL service..."
if sudo -u postgres sh -c 'test "$(ls -A /var/lib/postgres/data 2>/dev/null)"'; then
echo "PostgreSQL data directory already contains data. Skipping initdb."
else
sudo -iu postgres initdb --locale en_US.UTF-8 -D /var/lib/postgres/data || handle_error "Failed to initialize PostgreSQL database."
fi
if [ "$(ps -p 1 -o comm=)" = "systemd" ]; then
sudo systemctl enable postgresql
sudo systemctl start postgresql || handle_error "Failed to start PostgreSQL service."
else
sudo mkdir -p /run/postgresql
sudo chown postgres:postgres /run/postgresql
sudo -iu postgres pg_ctl -D /var/lib/postgres/data -l /var/lib/postgres/logfile start || handle_error "Failed to start PostgreSQL service."
fi
fi
# Run the init.sql to setup database
echo_header $GREEN "Step [4/4]: Setting up database..."
cp ./init.sql /tmp/init.sql
sudo -u postgres psql -f /tmp/init.sql || handle_error "Failed to execute init.sql script."

View File

@ -1,116 +0,0 @@
/*
This file is auto generated by pgrx.
The ordering of items is not stable, it is driven by a dependency graph.
*/
-- src/lib.rs:26
-- pg_graphql::_internal_resolve
CREATE FUNCTION graphql."_internal_resolve"(
"query" TEXT, /* &str */
"variables" jsonb DEFAULT '{}', /* core::option::Option<pgrx::datum::json::JsonB> */
"operationName" TEXT DEFAULT null, /* core::option::Option<alloc::string::String> */
"extensions" jsonb DEFAULT null /* core::option::Option<pgrx::datum::json::JsonB> */
) RETURNS jsonb /* pgrx::datum::json::JsonB */
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'resolve_wrapper';
-- src/lib.rs:19
-- 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:20
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
-- 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 or replace function graphql.exception(message text)
returns text
language plpgsql
as $$
begin
raise exception using errcode='22000', message=message;
end;
$$;

View File

@ -1,6 +0,0 @@
comment = 'pg_graphql: GraphQL support'
default_version = '1.4.2'
module_pathname = '$libdir/pg_graphql'
relocatable = false
superuser = true
schema = 'graphql'

View File

@ -1,116 +0,0 @@
/*
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<pgrx::datum::json::JsonB> */
"operationName" TEXT DEFAULT null, /* core::option::Option<alloc::string::String> */
"extensions" jsonb DEFAULT null /* core::option::Option<pgrx::datum::json::JsonB> */
) 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: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: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();

View File

@ -1,6 +0,0 @@
comment = 'pg_graphql: GraphQL support'
default_version = '1.5.1'
module_pathname = '$libdir/pg_graphql'
relocatable = false
superuser = true
schema = 'graphql'

View File

@ -1,116 +0,0 @@
/*
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<pgrx::datum::json::JsonB> */
"operationName" TEXT DEFAULT null, /* core::option::Option<alloc::string::String> */
"extensions" jsonb DEFAULT null /* core::option::Option<pgrx::datum::json::JsonB> */
) 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;
$$;

View File

@ -1,6 +0,0 @@
comment = 'pg_graphql: GraphQL support'
default_version = '1.5.6'
module_pathname = '$libdir/pg_graphql'
relocatable = false
superuser = true
schema = 'graphql'

View File

@ -1,117 +0,0 @@
#!/bin/bash
# Colors
RED=31
GREEN=32
BLUE=34
# Function to display colored output
function echo_header {
COLOR=$1
MESSAGE=$2
echo -e "\e[${COLOR}m\n=======================================================\e[0m"
echo -e "\e[${COLOR}m${MESSAGE}\e[0m"
echo -e "\e[${COLOR}m=======================================================\e[0m"
}
# Function to handle errors
function handle_error {
echo_header $RED "Error: $1"
exit 1
}
cat << "EOF"
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@#*+=================@@@@@%*+=========++*%@@@@@@@
@@@@#- .+@@%=. .+@@@@@
@@@- .*@@%- .#@@@
@@= .=+++++++++++*#@@@= -++++++++++- %@@
@@. %@@@@@@@@@@@@@@@+ =%@@@@@@@@@@@@= +@@
@@. .@@@@@@@@@@@@@@+. -%@@@@@@@@@@@@@@+ +@@
@@. .@@@@@@@@@@@@*. -#@@#:=@@@@@@@@@@@= +@@
@@ @@@@@@@@@@#: :#@@#: -@@@@@@@@@@@= +@@
@@#====#@@@@@@@@#- .*@@@= -@@@@@@@@@@@= +@@
@@@@@@@@@@@@@@%- .*@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@@@@%= +@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@@@+ =@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@+. -%@@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@*. -%@@@@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@#: :#@@@@@@@@@@@@@# -@@@@@@@@@@@+ +@@
@@@#: :#@@@@@@@@@@@@@@@# :@@@@@@@@@@@= +@@
@@= :+*+++++++++++*%@@@. :+++++++++- %@@
@@ :@@@%. .#@@@
@@- :@@@@@+: .+@@@@@
@@@#+===================+%@@@@@@@%*++=======++*%@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
EOF
echo_header $BLUE " DATABASE SETUP"
PG_MAIN_VERSION=15
PG_GRAPHQL_VERSION=1.5.6
CARGO_PGRX_VERSION=0.11.2
current_directory=$(pwd)
script_directory="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
# Install PostgresSQL
echo_header $GREEN "Step [1/4]: Installing PostgreSQL..."
brew reinstall postgresql@$PG_MAIN_VERSION
# Install pg_graphql extensions
echo_header $GREEN "Step [2/4]: Installing GraphQL for PostgreSQL..."
# Uninstall existing Rust installation if found
existing_rust_path=$(which rustc)
if [ -n "$existing_rust_path" ]; then
echo "Uninstalling existing Rust installation..."
rm -rf "$existing_rust_path"
fi
# To force a reinstall of cargo-pgrx, pass --force to the command below
curl https://sh.rustup.rs -sSf | sh
source "$HOME/.cargo/env"
cargo install --locked cargo-pgrx@$CARGO_PGRX_VERSION --force
cargo pgrx init --pg$PG_MAIN_VERSION download
# Create a temporary directory
temp_dir=$(mktemp -d)
cd "$temp_dir"
curl -LJO https://github.com/supabase/pg_graphql/archive/refs/tags/v$PG_GRAPHQL_VERSION.zip || handle_error "Failed to download pg_graphql package."
unzip pg_graphql-$PG_GRAPHQL_VERSION.zip
[[ ":$PATH:" != *":/opt/homebrew/opt/postgresql@$PG_MAIN_VERSION/bin:"* ]] && PATH="/opt/homebrew/opt/postgresql@$PG_MAIN_VERSION/bin:${PATH}"
cd "pg_graphql-$PG_GRAPHQL_VERSION"
# Apply patches to pg_graphql files
echo "Applying patches to pg_graphql files..."
for patch_file in "$script_directory/../../patches/pg_graphql/"*.patch; do
echo "Applying patch: $patch_file"
patch -p1 < "$patch_file"
done
cargo pgrx install --release --pg-config /opt/homebrew/opt/postgresql@$PG_MAIN_VERSION/bin/pg_config
# Clean up the temporary directory
echo "Cleaning up..."
cd "$current_directory"
rm -rf "$temp_dir"
# Start postgresql service
echo_header $GREEN "Step [3/4]: Starting PostgreSQL service..."
if brew services start postgresql@$PG_MAIN_VERSION; then
echo "PostgreSQL service started successfully."
else
handle_error "Failed to start PostgreSQL service."
fi
# Run the init.sql to setup database
echo_header $GREEN "Step [4/4]: Setting up database..."
cp ./postgres/init.sql /tmp/init.sql
psql -f /tmp/init.sql -d postgres|| handle_error "Failed to execute init.sql script."

View File

@ -1,27 +0,0 @@
#!/bin/bash
PG_MAIN_VERSION=15
PG_GRAPHQL_VERSION=1.5.6
current_directory=$(pwd)
echo "Step [1/4]: Installing PostgreSQL..."
brew reinstall postgresql@$PG_MAIN_VERSION
echo "Step [2/4]: Installing GraphQL for PostgreSQL..."
cp ./macos/arm/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql--${PG_GRAPHQL_VERSION}.sql \
/opt/homebrew/opt/postgresql@${PG_MAIN_VERSION}/share/postgresql@${PG_MAIN_VERSION}/extension
cp ./macos/arm/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.control \
/opt/homebrew/opt/postgresql@${PG_MAIN_VERSION}/share/postgresql@${PG_MAIN_VERSION}/extension
cp ./macos/arm/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.so \
/opt/homebrew/opt/postgresql@${PG_MAIN_VERSION}/lib/postgresql
export PATH="/opt/homebrew/opt/postgresql@${PG_MAIN_VERSION}/bin:$PATH"
echo "Step [3/4]: Starting PostgreSQL service..."
brew services restart postgresql@15
echo "Step [4/4]: Setting up database..."
cp ./init.sql /tmp/init.sql
sleep 5
psql -f /tmp/init.sql -d postgres

View File

@ -1,116 +0,0 @@
/*
This file is auto generated by pgrx.
The ordering of items is not stable, it is driven by a dependency graph.
*/
-- src/lib.rs:26
-- pg_graphql::_internal_resolve
CREATE FUNCTION graphql."_internal_resolve"(
"query" TEXT, /* &str */
"variables" jsonb DEFAULT '{}', /* core::option::Option<pgrx::datum::json::JsonB> */
"operationName" TEXT DEFAULT null, /* core::option::Option<alloc::string::String> */
"extensions" jsonb DEFAULT null /* core::option::Option<pgrx::datum::json::JsonB> */
) RETURNS jsonb /* pgrx::datum::json::JsonB */
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'resolve_wrapper';
-- src/lib.rs:19
-- 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:20
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
-- 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 or replace function graphql.exception(message text)
returns text
language plpgsql
as $$
begin
raise exception using errcode='22000', message=message;
end;
$$;

View File

@ -1,6 +0,0 @@
comment = 'pg_graphql: GraphQL support'
default_version = '1.3.0'
module_pathname = '$libdir/pg_graphql'
relocatable = false
superuser = true
schema = 'graphql'

View File

@ -1,116 +0,0 @@
/*
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<pgrx::datum::json::JsonB> */
"operationName" TEXT DEFAULT null, /* core::option::Option<alloc::string::String> */
"extensions" jsonb DEFAULT null /* core::option::Option<pgrx::datum::json::JsonB> */
) RETURNS jsonb /* pgrx::datum::json::JsonB */
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'resolve_wrapper';
-- 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: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: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();

View File

@ -1,6 +0,0 @@
comment = 'pg_graphql: GraphQL support'
default_version = '1.5.1'
module_pathname = '$libdir/pg_graphql'
relocatable = false
superuser = true
schema = 'graphql'

View File

@ -1,116 +0,0 @@
/*
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<pgrx::datum::json::JsonB> */
"operationName" TEXT DEFAULT null, /* core::option::Option<alloc::string::String> */
"extensions" jsonb DEFAULT null /* core::option::Option<pgrx::datum::json::JsonB> */
) 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;
$$;

View File

@ -1,6 +0,0 @@
comment = 'pg_graphql: GraphQL support'
default_version = '1.5.6'
module_pathname = '$libdir/pg_graphql'
relocatable = false
superuser = true
schema = 'graphql'

View File

@ -1,117 +0,0 @@
#!/bin/bash
# Colors
RED=31
GREEN=32
BLUE=34
# Function to display colored output
function echo_header {
COLOR=$1
MESSAGE=$2
echo -e "\e[${COLOR}m\n=======================================================\e[0m"
echo -e "\e[${COLOR}m${MESSAGE}\e[0m"
echo -e "\e[${COLOR}m=======================================================\e[0m"
}
# Function to handle errors
function handle_error {
echo_header $RED "Error: $1"
exit 1
}
cat << "EOF"
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@#*+=================@@@@@%*+=========++*%@@@@@@@
@@@@#- .+@@%=. .+@@@@@
@@@- .*@@%- .#@@@
@@= .=+++++++++++*#@@@= -++++++++++- %@@
@@. %@@@@@@@@@@@@@@@+ =%@@@@@@@@@@@@= +@@
@@. .@@@@@@@@@@@@@@+. -%@@@@@@@@@@@@@@+ +@@
@@. .@@@@@@@@@@@@*. -#@@#:=@@@@@@@@@@@= +@@
@@ @@@@@@@@@@#: :#@@#: -@@@@@@@@@@@= +@@
@@#====#@@@@@@@@#- .*@@@= -@@@@@@@@@@@= +@@
@@@@@@@@@@@@@@%- .*@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@@@@%= +@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@@@+ =@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@+. -%@@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@*. -%@@@@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@#: :#@@@@@@@@@@@@@# -@@@@@@@@@@@+ +@@
@@@#: :#@@@@@@@@@@@@@@@# :@@@@@@@@@@@= +@@
@@= :+*+++++++++++*%@@@. :+++++++++- %@@
@@ :@@@%. .#@@@
@@- :@@@@@+: .+@@@@@
@@@#+===================+%@@@@@@@%*++=======++*%@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
EOF
echo_header $BLUE " DATABASE SETUP"
PG_MAIN_VERSION=15
PG_GRAPHQL_VERSION=1.5.6
CARGO_PGRX_VERSION=0.11.2
current_directory=$(pwd)
script_directory="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
# Install PostgresSQL
echo_header $GREEN "Step [1/4]: Installing PostgreSQL..."
brew reinstall postgresql@$PG_MAIN_VERSION
# Install pg_graphql extensions
echo_header $GREEN "Step [2/4]: Installing GraphQL for PostgreSQL..."
# Uninstall existing Rust installation if found
existing_rust_path=$(which rustc)
if [ -n "$existing_rust_path" ]; then
echo "Uninstalling existing Rust installation..."
rm -rf "$existing_rust_path"
fi
# To force a reinstall of cargo-pgrx, pass --force to the command below
curl https://sh.rustup.rs -sSf | sh
source "$HOME/.cargo/env"
cargo install --locked cargo-pgrx@$CARGO_PGRX_VERSION --force
cargo pgrx init --pg$PG_MAIN_VERSION download
# Create a temporary directory
temp_dir=$(mktemp -d)
cd "$temp_dir"
curl -LJO https://github.com/supabase/pg_graphql/archive/refs/tags/v$PG_GRAPHQL_VERSION.zip || handle_error "Failed to download pg_graphql package."
unzip pg_graphql-$PG_GRAPHQL_VERSION.zip
[[ ":$PATH:" != *":/usr/local/opt/postgresql@$PG_MAIN_VERSION/bin:"* ]] && PATH="/usr/local/opt/postgresql@$PG_MAIN_VERSION/bin:${PATH}"
cd "pg_graphql-$PG_GRAPHQL_VERSION"
# Apply patches to pg_graphql files
echo "Applying patches to pg_graphql files..."
for patch_file in "$script_directory/../../patches/pg_graphql/"*.patch; do
echo "Applying patch: $patch_file"
patch -p1 < "$patch_file"
done
cargo pgrx install --release --pg-config /usr/local/opt/postgresql@$PG_MAIN_VERSION/bin/pg_config
# Clean up the temporary directory
echo "Cleaning up..."
cd "$current_directory"
rm -rf "$temp_dir"
# Start postgresql service
echo_header $GREEN "Step [3/4]: Starting PostgreSQL service..."
if brew services start postgresql@$PG_MAIN_VERSION; then
echo "PostgreSQL service started successfully."
else
handle_error "Failed to start PostgreSQL service."
fi
# Run the init.sql to setup database
echo_header $GREEN "Step [4/4]: Setting up database..."
cp ./postgres/init.sql /tmp/init.sql
psql -f /tmp/init.sql -d postgres|| handle_error "Failed to execute init.sql script."

View File

@ -1,27 +0,0 @@
#!/bin/bash
PG_MAIN_VERSION=15
PG_GRAPHQL_VERSION=1.5.6
current_directory=$(pwd)
echo "Step [1/4]: Installing PostgreSQL..."
brew reinstall postgresql@$PG_MAIN_VERSION
echo "Step [2/4]: Installing GraphQL for PostgreSQL..."
cp ./macos/intel/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql--${PG_GRAPHQL_VERSION}.sql \
/usr/local/opt/postgresql@${PG_MAIN_VERSION}/share/postgresql@${PG_MAIN_VERSION}/extension
cp ./macos/intel/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.control \
/usr/local/opt/postgresql@${PG_MAIN_VERSION}/share/postgresql@${PG_MAIN_VERSION}/extension
cp ./macos/intel/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.so \
/usr/local/opt/postgresql@${PG_MAIN_VERSION}/lib/postgresql
export PATH="/usr/local/opt/postgresql@${PG_MAIN_VERSION}/bin:$PATH"
echo "Step [3/4]: Starting PostgreSQL service..."
brew services restart postgresql@15
echo "Step [4/4]: Setting up database..."
cp ./init.sql /tmp/init.sql
sleep 5
psql -f /tmp/init.sql -d postgres

View File

@ -1,28 +0,0 @@
diff --git a/sql/load_sql_context.sql b/sql/load_sql_context.sql
index 565e4e3..40cd99e 100644
--- a/sql/load_sql_context.sql
+++ b/sql/load_sql_context.sql
@@ -95,6 +95,8 @@ select
pg_type pt
left join pg_class tabs
on pt.typrelid = tabs.oid
+ join search_path_oids spo
+ on pt.typnamespace = spo.schema_oid or pt.typnamespace = 'pg_catalog'::regnamespace::oid
),
jsonb_build_object()
),
@@ -111,6 +113,8 @@ select
pg_type pt
join pg_class tabs
on pt.typrelid = tabs.oid
+ join search_path_oids spo
+ on pt.typnamespace = spo.schema_oid or pt.typnamespace = 'pg_catalog'::regnamespace::oid
where
pt.typcategory = 'C'
and tabs.relkind = 'c'
@@ -420,4 +424,4 @@ select
jsonb_build_array()
)
- )
+ );

View File

@ -19,10 +19,6 @@ rawDataSource
'CREATE SCHEMA IF NOT EXISTS "core"',
'create schema "core"',
);
await performQuery(
'CREATE EXTENSION IF NOT EXISTS "pg_graphql"',
'create extension pg_graphql',
);
await performQuery(
'CREATE EXTENSION IF NOT EXISTS "uuid-ossp"',
@ -66,34 +62,6 @@ rawDataSource
true,
);
}
await performQuery(
`COMMENT ON SCHEMA "core" IS '@graphql({"inflect_names": true})';`,
'inflect names for graphql',
);
await performQuery(
`
DROP FUNCTION IF EXISTS graphql;
CREATE FUNCTION graphql(
"operationName" text default null,
query text default null,
variables jsonb default null,
extensions jsonb default null
)
returns jsonb
language sql
as $$
select graphql.resolve(
query := query,
variables := coalesce(variables, '{}'),
"operationName" := "operationName",
extensions := extensions
);
$$;
`,
'create function graphql',
);
})
.catch((err) => {
console.error('Error during Data Source initialization:', err);

View File

@ -93,49 +93,70 @@ cd twenty
You should run all commands in the following steps from the root of the project.
## Step 3: Set up a PostgreSQL Database
We rely on [pg_graphql](https://github.com/supabase/pg_graphql) and recommend you use the scripts below to provision a database with the right extensions.
You can access the database at [localhost:5432](localhost:5432), with user `twenty` and password `twenty` .
<ArticleTabs label1="Linux" label2="Mac OS" label3="Windows (WSL)">
<ArticleTab>
<b>Option 1:</b> To provision your database locally:
Use the following link to install Postgresql on your Linux machine: [Postgresql Installation](https://www.postgresql.org/download/linux/)
```bash
make postgres-on-linux
psql postgres -c "CREATE DATABASE \"default\";" -c "CREATE DATABASE test;" -c "CREATE USER twenty PASSWORD 'twenty';" -c "ALTER ROLE twenty superuser;"
```
<b>Option 2:</b> If you have docker installed:
```bash
make postgres-on-docker
docker run \
--name twenty_postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=default \
-v twenty_db_data:/var/lib/postgresql/data \
-p 5432:5432 \
twentycrm/twenty-postgres:latest
```
</ArticleTab>
<ArticleTab>
<b>Option 1:</b> To provision your database locally with `brew`:
```bash
make postgres-on-macos-intel #for intel architecture
make postgres-on-macos-arm #for M1/M2/M3 architecture
```bash
brew install postgresql@16
export PATH="/opt/homebrew/opt/postgresql@16/bin:$PATH"
psql postgres -c "CREATE DATABASE \"default\";" -c "CREATE DATABASE test;" -c "CREATE USER twenty PASSWORD 'twenty';" -c "ALTER ROLE twenty superuser;"
```
<b>Option 2:</b> If you have docker installed:
```bash
make postgres-on-docker
docker run \
--name twenty_postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=default \
-v twenty_db_data:/var/lib/postgresql/data \
-p 5432:5432 \
twentycrm/twenty-postgres:latest
```
</ArticleTab>
<ArticleTab>
All the following steps are to be run in the WSL terminal (within your virtual machine)
<b>Option 1:</b> To provision your database locally:
<b>Option 1:</b> To provision your Postgresql locally:
Use the following link to install Postgresql on your Linux virtual machine: [Postgresql Installation](https://www.postgresql.org/download/linux/)
```bash
make postgres-on-linux
psql postgres -c "CREATE DATABASE \"default\";" -c "CREATE DATABASE test;" -c "CREATE USER twenty PASSWORD 'twenty';" -c "ALTER ROLE twenty superuser;"
```
Note: you might need to run `sudo apt-get install build-essential` before running the above command if you don't have the build tools installed.
<b>Option 2:</b> If you have docker installed:
Running Docker on WSL adds an extra layer of complexity.
Only use this option if you are comfortable with the extra steps involved, including turning on [Docker Desktop WSL2](https://docs.docker.com/desktop/wsl).
```bash
make postgres-on-docker
docker run \
--name twenty_postgres \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=default \
-v twenty_db_data:/var/lib/postgresql/data \
-p 5432:5432 \
twentycrm/twenty-postgres:latest
```
</ArticleTab>
</ArticleTabs>
@ -154,7 +175,7 @@ Twenty requires a redis cache to provide the best performances
```
</ArticleTab>
<ArticleTab>
<b>Option 1:</b>To provision your Redis locally with `brew`:
<b>Option 1:</b> To provision your Redis locally with `brew`:
```bash
brew install redis
```

View File

@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS "githubReleases" (
"tagName" text PRIMARY KEY NOT NULL,
"publishedAt" date NOT NULL
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "githubStars" (
"timestamp" timestamp DEFAULT now() NOT NULL,
"numberOfStars" integer
);

View File

@ -0,0 +1,388 @@
{
"id": "b3a89784-eb82-49d8-b081-31c49e6906dc",
"prevId": "a7895a79-44a3-4fad-b750-f89d8c04d85c",
"version": "5",
"dialect": "pg",
"tables": {
"githubReleases": {
"name": "githubReleases",
"schema": "",
"columns": {
"tagName": {
"name": "tagName",
"type": "text",
"primaryKey": true,
"notNull": true
},
"publishedAt": {
"name": "publishedAt",
"type": "date",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"githubStars": {
"name": "githubStars",
"schema": "",
"columns": {
"timestamp": {
"name": "timestamp",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
},
"numberOfStars": {
"name": "numberOfStars",
"type": "integer",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"issueLabels": {
"name": "issueLabels",
"schema": "",
"columns": {
"issueId": {
"name": "issueId",
"type": "text",
"primaryKey": false,
"notNull": false
},
"labelId": {
"name": "labelId",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"issueLabels_issueId_issues_id_fk": {
"name": "issueLabels_issueId_issues_id_fk",
"tableFrom": "issueLabels",
"tableTo": "issues",
"columnsFrom": [
"issueId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"issueLabels_labelId_labels_id_fk": {
"name": "issueLabels_labelId_labels_id_fk",
"tableFrom": "issueLabels",
"tableTo": "labels",
"columnsFrom": [
"labelId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"issues": {
"name": "issues",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"externalId": {
"name": "externalId",
"type": "text",
"primaryKey": false,
"notNull": false
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": false
},
"body": {
"name": "body",
"type": "text",
"primaryKey": false,
"notNull": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": false
},
"createdAt": {
"name": "createdAt",
"type": "text",
"primaryKey": false,
"notNull": false
},
"updatedAt": {
"name": "updatedAt",
"type": "text",
"primaryKey": false,
"notNull": false
},
"closedAt": {
"name": "closedAt",
"type": "text",
"primaryKey": false,
"notNull": false
},
"authorId": {
"name": "authorId",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"issues_authorId_users_id_fk": {
"name": "issues_authorId_users_id_fk",
"tableFrom": "issues",
"tableTo": "users",
"columnsFrom": [
"authorId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"labels": {
"name": "labels",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"externalId": {
"name": "externalId",
"type": "text",
"primaryKey": false,
"notNull": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": false
},
"color": {
"name": "color",
"type": "text",
"primaryKey": false,
"notNull": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"pullRequestLabels": {
"name": "pullRequestLabels",
"schema": "",
"columns": {
"pullRequestExternalId": {
"name": "pullRequestExternalId",
"type": "text",
"primaryKey": false,
"notNull": false
},
"labelId": {
"name": "labelId",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"pullRequestLabels_pullRequestExternalId_pullRequests_id_fk": {
"name": "pullRequestLabels_pullRequestExternalId_pullRequests_id_fk",
"tableFrom": "pullRequestLabels",
"tableTo": "pullRequests",
"columnsFrom": [
"pullRequestExternalId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"pullRequestLabels_labelId_labels_id_fk": {
"name": "pullRequestLabels_labelId_labels_id_fk",
"tableFrom": "pullRequestLabels",
"tableTo": "labels",
"columnsFrom": [
"labelId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"pullRequests": {
"name": "pullRequests",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"title": {
"name": "title",
"type": "text",
"primaryKey": false,
"notNull": false
},
"body": {
"name": "body",
"type": "text",
"primaryKey": false,
"notNull": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": false
},
"createdAt": {
"name": "createdAt",
"type": "text",
"primaryKey": false,
"notNull": false
},
"updatedAt": {
"name": "updatedAt",
"type": "text",
"primaryKey": false,
"notNull": false
},
"closedAt": {
"name": "closedAt",
"type": "text",
"primaryKey": false,
"notNull": false
},
"mergedAt": {
"name": "mergedAt",
"type": "text",
"primaryKey": false,
"notNull": false
},
"authorId": {
"name": "authorId",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"pullRequests_authorId_users_id_fk": {
"name": "pullRequests_authorId_users_id_fk",
"tableFrom": "pullRequests",
"tableTo": "users",
"columnsFrom": [
"authorId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"users": {
"name": "users",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true
},
"avatarUrl": {
"name": "avatarUrl",
"type": "text",
"primaryKey": false,
"notNull": false
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": false
},
"isEmployee": {
"name": "isEmployee",
"type": "text",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"schemas": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}