Skip to content

feat(backend): add Knex database migration system#173

Merged
Fatimasanusi merged 4 commits into
Trust-Analysis:mainfrom
KarenZita01:feat/database-migrations
Jun 28, 2026
Merged

feat(backend): add Knex database migration system#173
Fatimasanusi merged 4 commits into
Trust-Analysis:mainfrom
KarenZita01:feat/database-migrations

Conversation

@KarenZita01

Copy link
Copy Markdown
Contributor

Summary

Closes #91

Implements a database migration system using Knex.js, ready for when a persistent database is introduced.

Checklist

  • Choose migration tool — Knex.js (native JS/ESM, no extra runtime, supports SQLite + PostgreSQL)
  • Create initial migration — create_assets_table with core columns and rollback
  • Add migration run commands to package.json
  • Document how to create and run migrations

Changes

File Description
backend/knexfile.js Knex config — SQLite for dev/test, PostgreSQL for production
backend/migrations/20260628000000_create_assets_table.js Initial migration: assets table
backend/docs/migrations.md Full usage documentation
backend/package.json Added migrate, migrate:rollback, migrate:make, migrate:status scripts; added knex, better-sqlite3, pg deps
backend/.env.example Added DATABASE_URL documentation

Migration commands

npm run migrate            # apply pending migrations
npm run migrate:rollback   # roll back last batch
npm run migrate:make -- <name>  # scaffold a new migration
npm run migrate:status     # list applied / pending

Migration state tracking

Knex automatically creates a knex_migrations table on first run to record which migrations have been applied and in which batch — enabling safe rollbacks.

Closes Trust-Analysis#91

- Add knexfile.js with SQLite (dev/test) and PostgreSQL (prod) config
- Add initial migration: 20260628000000_create_assets_table.js
- Add npm scripts: migrate, migrate:rollback, migrate:make, migrate:status
- Add knex, better-sqlite3, pg to dependencies
- Add docs/migrations.md with full usage guide
- Update .env.example with DATABASE_URL
@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@KarenZita01 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

E2E tests expect mock wallet behaviour (Connect Freighter button,
mock public key) but the workflow was building and running tests
without VITE_MOCK_WALLET set, causing all Playwright tests to fail.
…NTRACT_ID

new Contract('PLACEHOLDER') throws at module load time because
'PLACEHOLDER' is not a valid Stellar contract address. Moved the
Contract construction into a lazy getter so the app renders
correctly when the contract ID is not yet configured (e.g. in CI
E2E tests that use VITE_CONTRACT_ID=PLACEHOLDER).
@Fatimasanusi
Fatimasanusi merged commit a5647df into Trust-Analysis:main Jun 28, 2026
2 of 3 checks passed
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.

Add database migration system

2 participants