Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 1.39 KB

readme.db_migrations.md

File metadata and controls

27 lines (20 loc) · 1.39 KB

Database Schema Migrations

To update the database schema to a new version, create schema migration files for postgres and sqlite as described here.

all migrations must run within a transaction, so migration files must be wrapped with BEGIN; and COMMIT; statements

The migration will be executed automatically on application startup or can be triggered independently using a CLI.

Database Abstraction Layer

Steps to generate functions for database access:

  1. add postgreSQL query to main/adapters/database/postgres/queries and SQLite query to main/adapters/database/sqlite/queries
  2. run cd main/adapters/database && go generate
  3. extend the Querier interface in main/adapters/database/querier.go with new function
  4. implement new wrapper for generated postgres function in main/adapters/database/db_postgres.go and new wrapper for generated sqlite function in main/adapters/database/db_sqlite.go