Skip to content

refactor: init script run#1402

Open
alismx wants to merge 16 commits intomainfrom
feature/add-sql-init-entrypoint
Open

refactor: init script run#1402
alismx wants to merge 16 commits intomainfrom
feature/add-sql-init-entrypoint

Conversation

@alismx
Copy link
Copy Markdown
Collaborator

@alismx alismx commented Mar 31, 2026

No description provided.

alismx and others added 6 commits March 30, 2026 10:22
- Created docker-entrypoint.sh that runs PostgreSQL migrations on startup
- Updated Dockerfile to copy SQL scripts and entrypoint script
- Set entrypoint to run migrations before starting Next.js server
- Replace shell-based entrypoint with Node.js migration script
- Use pg and mssql npm packages for database connections
- Remove need to install psql/sqlcmd in Docker image
- Simplify Dockerfile by staying on Alpine base image
- Add DATABASE_URL validation before PostgreSQL connection attempts
- Add SQL Server environment variable validation (SQL_SERVER_HOST, USER, PASSWORD)
- Add 10-second connection timeouts for both databases
- Fix mssql.close() to pool.close() for proper connection cleanup
- Replace error message string matching with SQL Server error numbers (2714, 15151)
- Add timeout wrapper (300s) in docker-entrypoint.sh to prevent infinite hangs
- Update CONFIG_NAME detection to be more specific (_PG_, _SQLSERVER_)
- Change fallback from silent skip to explicit failure when CONFIG_NAME is invalid
- Remove unused execSync import

Closes #1400 review feedback
- Delete scripts/run-migrations.js and move to sql/run-init.js
- Simplify CONFIG_NAME matching (remove regex complexity)
- Reduce timeout from 300s to 60s for faster failure detection
- Update path resolution in run-init.js (use ./sql relative to __dirname)
- Rename "migrations" to "init" throughout entrypoint and script messages

This consolidates database initialization logic into the sql/ directory
and streamlines the init script with simpler configuration matching.
@alismx alismx requested a review from a team as a code owner March 31, 2026 17:51
@alismx alismx requested review from austin-hall-skylight and vochaparro2 and removed request for a team March 31, 2026 17:51
pre-commit-ci bot and others added 4 commits March 31, 2026 17:52
- Fix path bug: sql files at ../postgres not ./sql/postgres (PR #1402 review)
- Inline validation functions for simpler control flow
- Simplify SQL Server database fallback (remove fragile URL parsing)
- Remove redundant error number checks (string matching sufficient)
- Simplify entrypoint: use $? directly, fix timeout message to 60 seconds

These changes were made based on PR review feedback to improve correctness
and maintainability while keeping the code simple and clear.
…ibbs-ecr-viewer into feature/add-sql-init-entrypoint

Resolve merge conflicts by keeping fixed version:

- Fix path resolution bug (use '../postgres' not './sql/postgres')
- Inline validation functions for simpler code
- Simplify SQL Server database fallback logic
- Remove redundant error number checks
- Fix timeout message accuracy in entrypoint

This maintains the fixes from PR #1402 review while incorporating
remote changes.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.93%. Comparing base (057a468) to head (c3ac540).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1402      +/-   ##
==========================================
- Coverage   86.29%   82.93%   -3.37%     
==========================================
  Files         258      174      -84     
  Lines       11488     6645    -4843     
  Branches     1284     1279       -5     
==========================================
- Hits         9914     5511    -4403     
+ Misses       1567     1130     -437     
+ Partials        7        4       -3     
Flag Coverage Δ
ecr-viewer 82.41% <ø> (-9.59%) ⬇️
ingestion ?
message-parser ?
orchestration 85.29% <ø> (ø)
trigger-code-reference ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alismx alismx changed the title refactor: Replace migrations with init script refactor: init script run Mar 31, 2026
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.

4 participants