mirror of
https://github.com/lingble/twenty.git
synced 2025-11-01 21:27:58 +00:00
[Wip] Update CI CD (#2945)
* Update CI and CD scripts * Fix docker docs build * Fix CD * Fix CD * Update front build and add postgres intel pg_graphql files * Fix postgres install * Fix * Update docs
This commit is contained in:
116
packages/twenty-postgres/macos/intel/15/pg_graphql/1.3.0/pg_graphql--1.3.0.sql
vendored
Normal file
116
packages/twenty-postgres/macos/intel/15/pg_graphql/1.3.0/pg_graphql--1.3.0.sql
vendored
Normal file
@@ -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: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;
|
||||
$$;
|
||||
|
||||
6
packages/twenty-postgres/macos/intel/15/pg_graphql/1.3.0/pg_graphql.control
vendored
Normal file
6
packages/twenty-postgres/macos/intel/15/pg_graphql/1.3.0/pg_graphql.control
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
comment = 'pg_graphql: GraphQL support'
|
||||
default_version = '1.3.0'
|
||||
module_pathname = '$libdir/pg_graphql'
|
||||
relocatable = false
|
||||
superuser = true
|
||||
schema = 'graphql'
|
||||
BIN
packages/twenty-postgres/macos/intel/15/pg_graphql/1.3.0/pg_graphql.so
vendored
Normal file
BIN
packages/twenty-postgres/macos/intel/15/pg_graphql/1.3.0/pg_graphql.so
vendored
Normal file
Binary file not shown.
108
packages/twenty-postgres/macos/intel/build-postgres-macos-intel.sh
Executable file
108
packages/twenty-postgres/macos/intel/build-postgres-macos-intel.sh
Executable file
@@ -0,0 +1,108 @@
|
||||
#!/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.3.0
|
||||
CARGO_PGRX_VERSION=0.9.8
|
||||
|
||||
current_directory=$(pwd)
|
||||
|
||||
# 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"
|
||||
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."
|
||||
27
packages/twenty-postgres/macos/intel/provision-postgres-macos-intel.sh
Executable file
27
packages/twenty-postgres/macos/intel/provision-postgres-macos-intel.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
PG_MAIN_VERSION=15
|
||||
PG_GRAPHQL_VERSION=1.4.2
|
||||
|
||||
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 \
|
||||
/usr/local/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 \
|
||||
/usr/local/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 \
|
||||
/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
|
||||
Reference in New Issue
Block a user