Skip to content

Conversation

@ArchILLtect
Copy link
Owner

This pull request migrates the project’s database from MySQL to PostgreSQL, with Neon as the production database provider. The changes update the codebase, configuration files, and documentation to support PostgreSQL throughout development, testing, and deployment. Schema scripts and seed data are also adapted for PostgreSQL syntax and conventions.

Database migration to PostgreSQL:

  • Updated all database connection logic, JDBC URLs, and Hibernate dialects in SessionFactoryProvider.java, hibernate.cfg.xml, and test configuration files to use PostgreSQL instead of MySQL. [1] [2] [3] [4]
  • Replaced MySQL JDBC driver dependency with PostgreSQL in pom.xml. [1] [2]
  • Converted schema and seed scripts in cleandb.sql and data.sql to PostgreSQL syntax, including identity columns, enum handling, and unique constraints. [1] [2] [3]

Documentation and deployment updates:

  • Revised README.md and docs/deployment.md to describe PostgreSQL usage for dev/test/prod, with Neon as the serverless production database. Includes new instructions for configuring environment variables and JDBC URLs. [1] [2] [3] [4] [5]
  • Added guidance for migration from AWS RDS MySQL to Neon PostgreSQL, including schema conversion steps.

Testing and troubleshooting improvements:

  • Updated test database properties and error messages to reflect PostgreSQL usage. [1] [2]
  • Enhanced troubleshooting documentation for PostgreSQL and Neon-specific issues, including SSL requirements and schema management.

Copilot AI and others added 8 commits February 13, 2026 02:13
Co-authored-by: ArchILLtect <140122527+ArchILLtect@users.noreply.github.com>
Co-authored-by: ArchILLtect <140122527+ArchILLtect@users.noreply.github.com>
Co-authored-by: ArchILLtect <140122527+ArchILLtect@users.noreply.github.com>
Co-authored-by: ArchILLtect <140122527+ArchILLtect@users.noreply.github.com>
…tication vulnerability

Co-authored-by: ArchILLtect <140122527+ArchILLtect@users.noreply.github.com>
…to-neon

ci/tooling: migrate database from AWS RDS MySQL to Neon Postgres
@ArchILLtect ArchILLtect added this to the Post-MVP milestone Feb 13, 2026
@ArchILLtect ArchILLtect self-assigned this Feb 13, 2026
Copilot AI review requested due to automatic review settings February 13, 2026 03:38
@ArchILLtect ArchILLtect added area:deployment AWS Elastic Beanstalk, environments, and runtime configs. api:external Work related to external/public API selection, integration, and resilience. priority:P1-high High importance; schedule next. post-mvp Use for all issues/PRs that do not belong to the MVP release. Will be implement post-MVP. migration Schema/data migrations and related tasks (e.g., Flyway/Liquibase scripts, rollout coordination). labels Feb 13, 2026
@ArchILLtect ArchILLtect merged commit 8f61f0b into main Feb 13, 2026
6 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request migrates the project's database infrastructure from MySQL to PostgreSQL, using Neon as the serverless production database provider. The migration updates all database connection configurations, SQL schemas, dependency declarations, and documentation to support PostgreSQL throughout the development, testing, and deployment lifecycle.

Changes:

  • Replaced MySQL JDBC driver with PostgreSQL driver (version 42.7.7) and updated all Hibernate configurations to use PostgreSQL dialect and connection URLs
  • Converted SQL schema scripts from MySQL syntax to PostgreSQL syntax, replacing AUTO_INCREMENT with GENERATED ALWAYS AS IDENTITY, ENUM with VARCHAR + CHECK constraints, and MySQL-specific timestamp updates with standard defaults
  • Updated deployment documentation to describe Neon PostgreSQL setup, environment variables, and SSL requirements; revised README to reflect PostgreSQL as the database for all environments

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/test/resources/test-db.properties.example Added PostgreSQL connection template for local testing with proper driver, dialect, and SSL configuration
src/test/resources/cleandb.sql Converted test schema from MySQL to PostgreSQL syntax (identity columns, constraints, enum handling)
src/test/java/me/nickhanson/codeforge/testutil/Database.java Updated error message to be database-agnostic
src/main/resources/hibernate.cfg.xml Changed JDBC driver, dialect, and connection URL from MySQL to PostgreSQL with SSL enabled
src/main/resources/data.sql Added missing user_id column to INSERT statements for submissions and drill items
src/main/java/me/nickhanson/codeforge/persistence/SessionFactoryProvider.java Updated default port, JDBC URL format, and driver class to PostgreSQL; changed dialect default
pom.xml Replaced MySQL connector dependency with PostgreSQL JDBC driver
docs/deployment.md Revised deployment guide to describe Neon PostgreSQL setup, removed RDS-specific instructions, added migration guidance
README.md Updated database technology description from MySQL to PostgreSQL/Neon

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -90,48 +84,41 @@ For production (AWS RDS), override datasource and JPA properties with environmen

Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section references "Spring" properties and "application.yml", but this project uses Hibernate directly without Spring (as documented at the top of the file). Remove or update this section to reflect Hibernate-specific configuration instead of Spring configuration.

Copilot uses AI. Check for mistakes.

CREATE TABLE submissions (
id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using GENERATED ALWAYS AS IDENTITY prevents explicit ID insertion, which is correct for these tables. However, if you ever need to insert rows with specific IDs (e.g., for testing or data migration), consider using GENERATED BY DEFAULT AS IDENTITY instead. The current approach is more secure but less flexible.

Suggested change
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,

Copilot uses AI. Check for mistakes.
Comment on lines +131 to +134
- PostgreSQL (Neon for production, local for dev/tests)
- Test DB reset via `DbReset` + `cleandb.sql`
- Seed data managed in `src/test/resources/cleandb.sql` (predictable schema)
- **AWS RDS** — Cloud-hosted DB for deployment
- **Neon (Postgres)** — Cloud-hosted serverless DB for deployment
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README still contains multiple references to MySQL that need to be updated to PostgreSQL, including:

  • "Tests use a local MySQL test database" (line 272)
  • "Create a local MySQL test database" section heading (line 274)
  • "Ensure MySQL is running locally" (line 279)
  • Example connection properties showing MySQL driver and dialect (lines 293-297)

These sections should be updated to reflect the PostgreSQL migration.

Copilot uses AI. Check for mistakes.
Comment on lines +66 to +67
url = "jdbc:postgresql://" + host + ":" + port + "/" + db
+ "?ssl=true&sslmode=require";
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default JDBC URL uses ssl=true&sslmode=require, which will fail when connecting to a local PostgreSQL instance for development. Local PostgreSQL typically doesn't have SSL configured. Consider detecting localhost connections and disabling SSL for them (e.g., ssl=false when host is "localhost"), while keeping SSL enabled for production. The test-db.properties.example correctly uses ssl=false for local development.

Suggested change
url = "jdbc:postgresql://" + host + ":" + port + "/" + db
+ "?ssl=true&sslmode=require";
boolean isLocalhost = "localhost".equalsIgnoreCase(host) || "127.0.0.1".equals(host);
String sslParams = isLocalhost ? "?ssl=false" : "?ssl=true&sslmode=require";
url = "jdbc:postgresql://" + host + ":" + port + "/" + db + sslParams;

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +13
jdbc:postgresql://${DB_HOST}:5432/${DB_NAME}
?ssl=true
&amp;sslmode=require
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default JDBC URL includes ssl=true&sslmode=require, but this will fail for local development connections to PostgreSQL. The test-db.properties.example correctly uses ssl=false for local development. Consider making SSL conditional based on the environment (e.g., ssl=false for localhost, ssl=true&sslmode=require for production).

Suggested change
jdbc:postgresql://${DB_HOST}:5432/${DB_NAME}
?ssl=true
&amp;sslmode=require
jdbc:postgresql://${DB_HOST}:5432/${DB_NAME}${DB_SSL_OPTIONS}

Copilot uses AI. Check for mistakes.
@@ -18,23 +18,18 @@ This project runs as a WAR on Tomcat 9 (Jakarta Servlet API). The persistence la
### Dev/Test (default)
- `src/main/resources/hibernate.cfg.xml` points to H2 and sets `hbm2ddl.auto=update`.
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation still mentions "H2 in-memory DB" for Dev/Test, but the changes migrate to PostgreSQL for all environments. Update this to reflect the new PostgreSQL-based setup for local development and testing.

Suggested change
- `src/main/resources/hibernate.cfg.xml` points to H2 and sets `hbm2ddl.auto=update`.
- `src/main/resources/hibernate.cfg.xml` is configured for a local PostgreSQL instance (or Docker) and sets `hbm2ddl.auto=update`.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api:external Work related to external/public API selection, integration, and resilience. area:deployment AWS Elastic Beanstalk, environments, and runtime configs. migration Schema/data migrations and related tasks (e.g., Flyway/Liquibase scripts, rollout coordination). post-mvp Use for all issues/PRs that do not belong to the MVP release. Will be implement post-MVP. priority:P1-high High importance; schedule next.

Projects

Development

Successfully merging this pull request may close these issues.

2 participants