Code Monkey home page Code Monkey logo

mdb's Introduction

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

mdb's People

Contributors

edoshor avatar bbfsdev avatar davgur avatar yurihechter avatar gshilin avatar ramigg avatar kolmanv avatar yanivel avatar yosefy avatar dmitrykhaymov avatar alexmbb avatar

Stargazers

Roman Hossain Shaon avatar ik5 avatar Basel Ajarmeh avatar Changsu Jiang avatar

Watchers

Matouš Jan Fialka avatar Igal Avraham avatar  avatar  avatar  avatar James Cloos avatar  avatar  avatar  avatar  avatar  avatar vulcangz avatar  avatar  avatar Basel Ajarmeh avatar

mdb's Issues

Reserved Windows chars in filenames

Some of the migration files contain the char ":", which is a reserved character on Windows filesystem.

This makes it impossible to clone the repository on windows.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.