Complete win script setup

This commit is contained in:
Charles Bochet
2023-10-14 22:40:05 +02:00
parent fa9303f545
commit 986082d7a7
5 changed files with 20 additions and 24 deletions

View File

@ -1,22 +1,10 @@
-- Create table "default" for local setup without docker
SELECT 'CREATE DATABASE "default"'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'default')\gexec
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'default');
SELECT 'CREATE DATABASE "test"'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'test');
-- Create user "twenty" for local setup without docker
SELECT 'CREATE USER twenty PASSWORD ''twenty'''
WHERE NOT EXISTS (SELECT FROM pg_user WHERE usename = 'twenty')\gexec
WHERE NOT EXISTS (SELECT FROM pg_user WHERE usename = 'twenty');
-- Inflect names for pg_graphql
COMMENT ON SCHEMA "public" IS '@graphql({"inflect_names": true})';
-- Connect to the "default" database
\c "default";
-- Create extension uuid-ossp
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- Create the tests database for e2e testing
CREATE DATABASE "test";
-- Connect to the "test" database for e2e testing
\c "test";
ALTER ROLE twenty superuser;

View File

@ -53,9 +53,9 @@ 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 postgresql-$PG_MAIN_VERSION postgresql-contrib || handle_error "Failed to install PostgreSQL."
apt install -y curl || handle_error "Failed to install curl."
sudo apt update -y || handle_error "Failed to update package list."
sudo apt install -y postgresql-$PG_MAIN_VERSION postgresql-contrib || handle_error "Failed to install PostgreSQL."su
sudo apt install -y curl || handle_error "Failed to install curl."
# Install pg_graphql extensions
echo_header $GREEN "Step [2/4]: Installing GraphQL for PostgreSQL..."
@ -73,4 +73,5 @@ fi
# Run the init.sql to setup database
echo_header $GREEN "Step [4/4]: Setting up database..."
sudo -u postgres psql -f ../postgres/init.sql || handle_error "Failed to execute init.sql script."
cp ./infra/dev/postgres/init.sql /tmp/init.sql
sudo -u postgres psql -f /tmp/init.sql || handle_error "Failed to execute init.sql script."