-
Notifications
You must be signed in to change notification settings - Fork 0
Switch database from H2 to PostgreSQL #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c327e28
b3dbceb
c9a9ea2
2dbc373
77e23cc
a261cc6
d5df117
e1a08b6
49a8c26
1d530f8
af27041
9ed704a
d83d477
fb716bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <component name="ProjectRunConfigurationManager"> | ||
| <configuration default="false" name="Docker Compose Up" type="ShConfigurationType" factoryName="Shell Script"> | ||
| <option name="SCRIPT_TEXT" value="docker compose up -d" /> | ||
| <option name="INDEPENDENT_SCRIPT_PATH" value="true" /> | ||
| <option name="SCRIPT_PATH" value="" /> | ||
| <option name="SCRIPT_OPTIONS" value="" /> | ||
| <option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" /> | ||
| <option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" /> | ||
| <method v="2" /> | ||
| </configuration> | ||
| </component> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| <component name="ProjectRunConfigurationManager"> | ||
| <configuration default="false" name="Spring Development" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot"> | ||
| <option name="ACTIVE_PROFILES" value="dev" /> | ||
| <option name="ACTIVE_PROFILES" value="local" /> | ||
| <module name="contacts" /> | ||
| <option name="SPRING_BOOT_MAIN_CLASS" value="codes.yam.contacts.ContactsApplication" /> | ||
| <method v="2"> | ||
| <option name="Make" enabled="true" /> | ||
| <option name="ToolBeforeRunTask" enabled="true" actionId="Tool_External Tools_Docker Compose Up + Wait" /> | ||
| </method> | ||
| </configuration> | ||
| </component> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| services: | ||
| db: | ||
| image: postgres:17 | ||
| environment: | ||
| POSTGRES_DB: contacts | ||
| POSTGRES_USER: contacts | ||
| POSTGRES_PASSWORD: contacts | ||
| ports: | ||
| - "5432:5432" | ||
| volumes: | ||
| - postgres_data:/var/lib/postgresql/data | ||
| healthcheck: | ||
| test: ["CMD-SHELL", "pg_isready -U contacts -d contacts"] | ||
| interval: 5s | ||
| timeout: 5s | ||
| retries: 10 | ||
|
|
||
| volumes: | ||
| postgres_data: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/sh | ||
| MAX_RETRIES=30 | ||
| docker compose up -d | ||
| i=0 | ||
| until docker compose exec -T db pg_isready -q; do | ||
| i=$((i + 1)) | ||
| if [ "$i" -ge "$MAX_RETRIES" ]; then | ||
| echo "Postgres did not become ready after $MAX_RETRIES seconds" >&2 | ||
| exit 1 | ||
| fi | ||
| sleep 1 | ||
| done | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| CREATE TABLE contact ( | ||
| id UUID PRIMARY KEY, | ||
| slug VARCHAR(255), | ||
| first VARCHAR(255), | ||
| last VARCHAR(255), | ||
| email VARCHAR(255), | ||
| phone VARCHAR(255) | ||
| ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| INSERT INTO contact (id, slug, first, last, email, phone) VALUES | ||
| ('550e8400-e29b-41d4-a716-446655440000', 'john-doe', 'John', 'Doe', 'john@example.com', '555-1234'), | ||
| ('550e8400-e29b-41d4-a716-446655440001', 'jane-doe', 'Jane', 'Doe', 'jane@example.com', '555-5678'), | ||
| ('550e8400-e29b-41d4-a716-446655440002', 'alice-smith', 'Alice', 'Smith', 'alice.smith@example.com', '555-1001'), | ||
| ('550e8400-e29b-41d4-a716-446655440003', 'bob-johnson', 'Bob', 'Johnson', 'bob.johnson@example.com', '555-1002'), | ||
| ('550e8400-e29b-41d4-a716-446655440004', 'carol-williams', 'Carol', 'Williams', 'carol.williams@example.com', '555-1003'), | ||
| ('550e8400-e29b-41d4-a716-446655440005', 'david-brown', 'David', 'Brown', 'david.brown@example.com', '555-1004'), | ||
| ('550e8400-e29b-41d4-a716-446655440006', 'eve-jones', 'Eve', 'Jones', 'eve.jones@example.com', '555-1005'), | ||
| ('550e8400-e29b-41d4-a716-446655440007', 'frank-garcia', 'Frank', 'Garcia', 'frank.garcia@example.com', '555-1006'), | ||
| ('550e8400-e29b-41d4-a716-446655440008', 'grace-miller', 'Grace', 'Miller', 'grace.miller@example.com', '555-1007'), | ||
| ('550e8400-e29b-41d4-a716-446655440009', 'henry-davis', 'Henry', 'Davis', 'henry.davis@example.com', '555-1008'), | ||
| ('550e8400-e29b-41d4-a716-44665544000a', 'iris-martinez', 'Iris', 'Martinez', 'iris.martinez@example.com', '555-1009'), | ||
| ('550e8400-e29b-41d4-a716-44665544000b', 'jack-wilson', 'Jack', 'Wilson', 'jack.wilson@example.com', '555-1010'), | ||
| ('550e8400-e29b-41d4-a716-44665544000c', 'karen-anderson', 'Karen', 'Anderson', 'karen.anderson@example.com', '555-1011'), | ||
| ('550e8400-e29b-41d4-a716-44665544000d', 'leo-thomas', 'Leo', 'Thomas', 'leo.thomas@example.com', '555-1012'), | ||
| ('550e8400-e29b-41d4-a716-44665544000e', 'mia-taylor', 'Mia', 'Taylor', 'mia.taylor@example.com', '555-1013'), | ||
| ('550e8400-e29b-41d4-a716-44665544000f', 'noah-hernandez', 'Noah', 'Hernandez', 'noah.hernandez@example.com', '555-1014'), | ||
| ('550e8400-e29b-41d4-a716-446655440010', 'olivia-moore', 'Olivia', 'Moore', 'olivia.moore@example.com', '555-1015'), | ||
| ('550e8400-e29b-41d4-a716-446655440011', 'paul-jackson', 'Paul', 'Jackson', 'paul.jackson@example.com', '555-1016'), | ||
| ('550e8400-e29b-41d4-a716-446655440012', 'quinn-martin', 'Quinn', 'Martin', 'quinn.martin@example.com', '555-1017'), | ||
| ('550e8400-e29b-41d4-a716-446655440013', 'rachel-lee', 'Rachel', 'Lee', 'rachel.lee@example.com', '555-1018'), | ||
| ('550e8400-e29b-41d4-a716-446655440014', 'sam-perez', 'Sam', 'Perez', 'sam.perez@example.com', '555-1019'), | ||
| ('550e8400-e29b-41d4-a716-446655440015', 'tina-white', 'Tina', 'White', 'tina.white@example.com', '555-1020'), | ||
| ('550e8400-e29b-41d4-a716-446655440016', 'ursula-harris', 'Ursula', 'Harris', 'ursula.harris@example.com', '555-1021'), | ||
| ('550e8400-e29b-41d4-a716-446655440017', 'victor-clark', 'Victor', 'Clark', 'victor.clark@example.com', '555-1022'), | ||
| ('550e8400-e29b-41d4-a716-446655440018', 'wendy-lewis', 'Wendy', 'Lewis', 'wendy.lewis@example.com', '555-1023'), | ||
| ('550e8400-e29b-41d4-a716-446655440019', 'xavier-robinson', 'Xavier', 'Robinson', 'xavier.robinson@example.com', '555-1024'), | ||
| ('550e8400-e29b-41d4-a716-44665544001a', 'yara-walker', 'Yara', 'Walker', 'yara.walker@example.com', '555-1025'), | ||
| ('550e8400-e29b-41d4-a716-44665544001b', 'zane-hall', 'Zane', 'Hall', 'zane.hall@example.com', '555-1026'), | ||
| ('550e8400-e29b-41d4-a716-44665544001c', 'amber-allen', 'Amber', 'Allen', 'amber.allen@example.com', '555-1027'), | ||
| ('550e8400-e29b-41d4-a716-44665544001d', 'brian-young', 'Brian', 'Young', 'brian.young@example.com', '555-1028'); | ||
|
Comment on lines
+1
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seed migration won’t execute from With no Use one of these fixes:
🤖 Prompt for AI Agents🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== data.sql (if present) =="
if [ -f src/main/resources/data.sql ]; then
sed -n '1,220p' src/main/resources/data.sql
else
echo "src/main/resources/data.sql not found"
fi
echo
echo "== Flyway/SQL init related config =="
rg -n -C2 'flyway|sql:|init:|defer-datasource-initialization|datasource' \
src/main/resources/application.yaml src/test/resources/application.yaml 2>/dev/null || trueRepository: yamcodes/contacts Length of output: 4659 🏁 Script executed: cat -n src/main/resources/application.yamlRepository: yamcodes/contacts Length of output: 494 🏁 Script executed: # Check for any other Flyway-related configurations
fd -e yaml -e properties | xargs rg -l 'flyway' 2>/dev/null || trueRepository: yamcodes/contacts Length of output: 96 🏁 Script executed: # Check if there's a bootstrap.properties or other config files
fd -e properties -e yml -o -e yaml | head -20Repository: yamcodes/contacts Length of output: 177 🏁 Script executed: fd 'application.*\.(yaml|yml|properties)' src/main/resources/ src/test/resources/Repository: yamcodes/contacts Length of output: 132 🏁 Script executed: # Check if there's a pom.xml or build.gradle to understand profiles
find . -maxdepth 2 -name 'pom.xml' -o -name 'build.gradle' | xargs ls -la 2>/dev/null || echo "No pom.xml or build.gradle found in root"Repository: yamcodes/contacts Length of output: 119 🏁 Script executed: # Check if sql.init.mode is configured anywhere in the codebase
rg 'sql\.init\.mode|sql:' src/ --type yaml --type properties 2>/dev/null || echo "Not found"Repository: yamcodes/contacts Length of output: 70 🏁 Script executed: rg -A5 -B2 'flyway' pom.xmlRepository: yamcodes/contacts Length of output: 668 🏁 Script executed: # List all SQL migration files
fd -e sql src/main/resources/db/Repository: yamcodes/contacts Length of output: 454 🏁 Script executed: # Check if there's a V1 migration
cat -n src/main/resources/db/migration/V1__*.sql 2>/dev/null || echo "No V1 migration found"Repository: yamcodes/contacts Length of output: 309 🏁 Script executed: fd . src/main/resources/db/Repository: yamcodes/contacts Length of output: 206 🏁 Script executed: # Look for any configuration about Flyway locations
rg 'flyway\.locations|spring\.flyway' src/main/resources/ src/test/resources/Repository: yamcodes/contacts Length of output: 43 Move V2__seed.sql to standard Flyway location and verify single seeding path after fix. The seed migration V2__seed.sql is in 🤖 Prompt for AI Agents |
||
Uh oh!
There was an error while loading. Please reload this page.