Skip to content

Commit dbb81d5

Browse files
committed
chore: restructure repo to better align with other postgres extensions
1 parent 889120a commit dbb81d5

File tree

7 files changed

+18
-88
lines changed

7 files changed

+18
-88
lines changed

Makefile

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# Directory paths
2-
SRC_DIR := src
3-
TEST_DIR := tests
4-
BUILD_DIR := dist
2+
SQL_DIR := sql
3+
TEST_DIR := test
54
PG_HOST := localhost
65
PG_PORT := 54322
76
PG_USER := postgres
87
PG_DB := postgres
98
PG_PASSWORD := postgres
109

10+
EXTENSION := keyhippo
11+
EXTVERSION := 1.2.4
12+
1113
# Default goal
1214
.DEFAULT_GOAL := help
1315

@@ -19,18 +21,19 @@ help:
1921
@echo " test - Run tests"
2022
@echo " pg_tap - Run pg_tap tests"
2123
@echo " cleanup - Remove files created during testing"
24+
@echo " benchmark - Run benchmark tests"
2225

2326
# Reset database
2427
.PHONY: reset-database
2528
reset-database:
2629
@echo "Resetting..."
27-
PGPASSWORD=$(PG_PASSWORD) psql -h $(PG_HOST) -p $(PG_PORT) -U $(PG_USER) -d $(PG_DB) -v ON_ERROR_STOP=1 -f $(TEST_DIR)/reset.sql
30+
PGPASSWORD=$(PG_PASSWORD) psql -h $(PG_HOST) -p $(PG_PORT) -U $(PG_USER) -d $(PG_DB) -v ON_ERROR_STOP=1 -f $(TEST_DIR)/utils/reset.sql
2831

2932
# Set up Supabase
3033
.PHONY: setup-supabase
3134
setup-supabase:
3235
@echo "Setting up Supabase..."
33-
@cd tests && \
36+
@cd $(TEST_DIR) && \
3437
supabase start && \
3538
eval $$(supabase status -o env) && \
3639
echo "SUPABASE_URL=$$API_URL" > .env.test && \
@@ -40,10 +43,15 @@ setup-supabase:
4043
@echo "CREATE EXTENSION IF NOT EXISTS pgjwt;" >> create_schema.sql
4144
@echo "CREATE SCHEMA IF NOT EXISTS keyhippo;" >> create_schema.sql
4245
PGPASSWORD=$(PG_PASSWORD) psql -h $(PG_HOST) -p $(PG_PORT) -U $(PG_USER) -d $(PG_DB) -v ON_ERROR_STOP=1 -f create_schema.sql
43-
@for file in $$(find extension/ -type f -name "keyhippo*--*.sql" | sort -V); do \
44-
echo "Applying migration: $$file" ; \
45-
PGPASSWORD=$(PG_PASSWORD) psql -h $(PG_HOST) -p $(PG_PORT) -U $(PG_USER) -d $(PG_DB) -v ON_ERROR_STOP=1 -f "$$file"; \
46-
done
46+
PGPASSWORD=$(PG_PASSWORD) psql -h $(PG_HOST) -p $(PG_PORT) -U $(PG_USER) -d $(PG_DB) -v ON_ERROR_STOP=1 -f $(SQL_DIR)/$(EXTENSION).sql
47+
@if ls $(SQL_DIR)/$(EXTENSION)--*--*.sql 1> /dev/null 2>&1; then \
48+
for file in $(SQL_DIR)/$(EXTENSION)--*--*.sql; do \
49+
echo "Applying migration: $$file" ; \
50+
PGPASSWORD=$(PG_PASSWORD) psql -h $(PG_HOST) -p $(PG_PORT) -U $(PG_USER) -d $(PG_DB) -v ON_ERROR_STOP=1 -f "$$file"; \
51+
done \
52+
else \
53+
echo "No upgrade migrations found. Skipping."; \
54+
fi
4755

4856
# Apply integration test migrations
4957
.PHONY: apply-integration-test-migrations
@@ -76,7 +84,7 @@ pg_tap:
7684
.PHONY: benchmark
7785
benchmark:
7886
@echo "Running benchmark..."
79-
PGPASSWORD=$(PG_PASSWORD) psql -h $(PG_HOST) -p $(PG_PORT) -U $(PG_USER) -d $(PG_DB) -v ON_ERROR_STOP=1 -f $(TEST_DIR)/bench.sql
87+
PGPASSWORD=$(PG_PASSWORD) psql -h $(PG_HOST) -p $(PG_PORT) -U $(PG_USER) -d $(PG_DB) -v ON_ERROR_STOP=1 -f $(TEST_DIR)/utils/bench.sql
8088

8189
# Clean up files created during testing
8290
.PHONY: cleanup

extension/README.md

Lines changed: 0 additions & 78 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)