Skip to content

feat: add multi-database support with generic environment variables#96

Closed
DevStarlight wants to merge 1 commit into
hyperfy-xyz:devfrom
numengames:feat/postgresql-support
Closed

feat: add multi-database support with generic environment variables#96
DevStarlight wants to merge 1 commit into
hyperfy-xyz:devfrom
numengames:feat/postgresql-support

Conversation

@DevStarlight

Copy link
Copy Markdown
Contributor

Description

This PR refactors the database configuration system to support multiple database engines with a more flexible and generic approach. The changes replace PostgreSQL-specific environment variables (POSTGRES_) with generic database variables (DB_) and add support for MySQL alongside the existing PostgreSQL and SQLite options.

Key Changes:

  • Replaced POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB with generic DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME
  • Added DB_TYPE environment variable to specify database engine (pg for PostgreSQL, mysql2 for MySQL)
  • Added MySQL configuration support with appropriate charset and timezone settings
  • Configured pg and mysql2 as optional dependencies to keep bundle size minimal
  • Maintained backward compatibility with SQLite as the default fallback option

This improves the server infrastructure flexibility allowing developers to choose their preferred database without being locked into PostgreSQL.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Component enhancement

How Has This Been Tested?

Please describe your tests:

  • Component functionality tests
  • Integration tests with other Hyperfy components
  • World integration testing
  • Cross-browser testing

Test Configuration:

  • Hyperfy Version: 0.13.0
  • Test world setup: Local development environment with SQLite fallback
  • Browser(s): Chromium
  • Node.js version: v22.13.1

Checklist:

  • My code follows Hyperfy's component architecture
  • I have performed a self-review
  • I have documented the component's usage
  • I have tested the component in multiple scenarios
  • My changes maintain compatibility with existing worlds
  • I have updated the component documentation if needed

- Replace POSTGRES_* env vars with generic DB_* naming convention
- Add support for MySQL alongside PostgreSQL and SQLite
- Add DB_TYPE environment variable to specify database engine
- Configure optional dependencies for pg and mysql2 drivers
- Maintain backward compatibility with SQLite as fallback
@DevStarlight DevStarlight changed the base branch from main to dev June 4, 2025 11:45
@DevStarlight

DevStarlight commented Jun 4, 2025

Copy link
Copy Markdown
Contributor Author

Should I include any specific doc somewhere? If so, please tell me where should be the best place

@DevStarlight

Copy link
Copy Markdown
Contributor Author

closing PR since I combined this one and #99 in #100

@DevStarlight DevStarlight mentioned this pull request Jun 9, 2025
15 tasks
@DevStarlight DevStarlight deleted the feat/postgresql-support branch June 9, 2025 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant