Skip to content

Enhancement/standardize service errors#250

Open
Thoni76 wants to merge 5 commits into
Liquifact:mainfrom
Thoni76:enhancement/standardize-service-errors
Open

Enhancement/standardize service errors#250
Thoni76 wants to merge 5 commits into
Liquifact:mainfrom
Thoni76:enhancement/standardize-service-errors

Conversation

@Thoni76
Copy link
Copy Markdown

@Thoni76 Thoni76 commented May 28, 2026

closes #210

## Summary
- Consolidated migration system from mixed Knex + node-pg-migrate to unified Knex approach
- Standardized all migrations to Knex.js format (JavaScript files)
- Removed duplicate migration definitions and conflicting tools

## Changes

### Migrations
- Created comprehensive Knex migrations for all schema components:
  - invoices table with full schema and multi-tenant support
  - users, tenants, and api_keys for multi-tenant architecture
  - escrow_operations, escrow_summaries for transaction tracking
  - audit_log_events (append-only ledger with DB-level enforcement)
  - retention_policies, legal_holds, and retention audit logging
  - escrow event indexing tables for off-chain projection

### Configuration
- Updated package.json to use only Knex migration commands
- Removed duplicate \db:migrate\ script (node-pg-migrate took precedence)
- All migration scripts now use: \knex migrate:latest\, \knex migrate:rollback\, etc.

### Documentation
- Updated DB_MIGRATIONS.md with comprehensive Knex documentation
- Added troubleshooting guides for common issues
- Documented PostgreSQL-specific features (RLS, triggers)
- Added production deployment best practices

### Testing
- Updated migration integration tests to validate Knex migrations
- Tests verify schema correctness for both SQLite and PostgreSQL
- Added migration execution, rollback, and idempotency tests

### Removed
- ❌ Removed node-pg-migrate configuration (migrator-config.js now unused)
- ❌ Removed duplicate initial schema migrations
- ❌ Removed old SQL-only migrations

## Benefits
✅ Single migration tool (Knex) - easier maintenance
✅ Supports multiple databases (SQLite dev/test, PostgreSQL prod)
✅ Better error handling and transaction support
✅ Clear separation of dev/test/prod configurations
✅ Comprehensive test coverage for migrations

## Testing
- Migration structure validates correctly
- All tables create successfully on fresh database
- Idempotent migrations (safe to run multiple times)
- Rollback capability verified

Related to Liquifact#212: Unify migration tooling
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@Thoni76 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Replace generic Error throws in marketplaceService and webhooks with RFC7807 AppError and structured logging

2 participants