Skip to content

Latest commit

 

History

History
137 lines (85 loc) · 3.71 KB

README.md

File metadata and controls

137 lines (85 loc) · 3.71 KB

MDB - Metadata DB

Maintainability

Test Coverage

Overview

BB archive Metadata Database.

This system aims to be a single source of truth for all content produced by Bnei Baruch.

Developer Environment

We assume docker and golang are already installed on your system.

Tools

See rambler under Schema Migrations and sqlboiler ORM sections below.

Useful Commands

mdb config <path>

Generate default configuration in the given path. If path is omitted STDOUT is used instead. Note that default value to config file is config.toml in project root directory.

rambler -c migrations/rambler.json apply -a

Apply all DB migrations (See Schema migrations section for more information)

 mdb migration my-migration-name

Create new migration

Schema Migrations

We keep track of all changes to the MDB schema under migrations. These are pure postgres sql scripts. To create a new migration file with name run in project root directory:

mdb migration my-migration-name

This will create a migration file in migrations directory with name like: 2017-01-07_14:21:02_my-migration-name.sql

They play along well with rambler A simple and language-independent SQL schema migration tool. Download the rambler executable for your system from the release page. (on linux chmod +x)

Under migrations folder add a rambler.json config file. Simply copying rambler.sample.json should work fine but feel free to change that. Check out the docs for configuration options.

Important make sure never to commit such files to SCM.

On the command line:

rambler -c migrations/rambler.json apply -a

Generating Documentation

Documentation is based on tests and will be generated automatically with each make build. To generate static html documentation (docs.html) install:

npm install -g aglio

Then run:

make api

Implementation Notes

Dates and Times

All timestamps fields are expecting values in UTC only.

Languages

Languages are represented in the system as a two letters code adhering to the ISO_639-1 standard.

Special values:

  • Unknown - xx
  • Multiple languages - zz

Logging

We use logrus for logging.

All logs are written to STDOUT or STDERR. It's up to the running environment to pipe these into physical files and rotate those using logrotate(8).

Rollbar

If the rollbar-token config is found we'll use our own recovery middleware to send errors to Rollbar. If not, we'll use gin.Recovery() to print stacktrace to console. Using rollbar is meant for production environment.

In addition, you could log whatever error you want to rollbar directly, for example:

   if _, err := SomeErrorProneFunc(); err != nil {
       rollbar.Error("level", err,...)
   }

Check out the docs for more info on how to use the Rollbar client.

ORM

We use sqlboiler as an ORM.

In root folder add a sqlboiler.toml config file. Simply copying sqlboiler.sample.toml should work fine but feel free to change that. Check out the docs for configuration options.

To regenerate models run

make models

License

MIT