From 567769ff1b72b740dfc8fb514c26852951f856e8 Mon Sep 17 00:00:00 2001 From: jonny <32085184+jonnyjohnson1@users.noreply.github.com> Date: Tue, 5 Nov 2024 17:34:48 -0600 Subject: [PATCH] fix: Fixing the postgres init sequence (WIP) --- .env_dev | 2 +- .env_template | 15 --- default.nix | 27 +++++- flake.nix | 35 ++----- justfile | 1 + tests/database/postgres_init_test.py | 97 +++++++++++++++++++ topos/chat_api/server.py | 2 + .../database/conversation_cache_manager.py | 2 +- 8 files changed, 136 insertions(+), 45 deletions(-) delete mode 100644 .env_template create mode 100644 tests/database/postgres_init_test.py diff --git a/.env_dev b/.env_dev index 9aa8394..e919969 100644 --- a/.env_dev +++ b/.env_dev @@ -8,7 +8,7 @@ OPEN_AI_API_KEY="sk-openai.com123" ONE_API_API_KEY="sk-oneapi.local123" SUPABASE_URL= SUPABASE_KEY= -POSTGRES_DB=test_topos_db +POSTGRES_DB=test_topos_db_1 POSTGRES_USER=jonny POSTGRES_PASSWORD=1234589034 POSTGRES_HOST=127.0.0.1 diff --git a/.env_template b/.env_template deleted file mode 100644 index 6caf27a..0000000 --- a/.env_template +++ /dev/null @@ -1,15 +0,0 @@ -NEO4J_URI="bolt://localhost:7687" -NEO4J_USER="neo4j" -NEO4J_PASSWORD="password" -NEO4J_TEST_DATABASE="neo4j" -NEO4J_SHOWROOM_DATABASE="neo4j" -JWT_SECRET="terces_tj" -OPEN_AI_API_KEY="sk-openai.com123" -ONE_API_API_KEY="sk-oneapi.local123" -SUPABASE_URL= -SUPABASE_KEY= -POSTGRES_DB=test_topos_db -POSTGRES_USER=username -POSTGRES_PASSWORD=your_password_here -POSTGRES_HOST=127.0.0.1 -POSTGRES_PORT=5432 diff --git a/default.nix b/default.nix index 123ff1f..1b5788f 100644 --- a/default.nix +++ b/default.nix @@ -41,8 +41,10 @@ in pkgs.mkShell { sleep 2 # Set up the test database, role, and tables + echo "Setting up the test database..." + # psql -U $POSTGRES_USER -c "CREATE DATABASE $POSTGRES_DB;" || echo "Database $POSTGRES_DB already exists." + psql -d $POSTGRES_DB <