0.2.1 • Published 7 years ago

aviation-pg v0.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

aviation-pg.

Description

This project uses the aviation data provided by the aviation-json project.

It will create a database (using versioned migrations) and keep it up to date with the JSON files provided by aviation-json by running a single command make.

A PostgreSQL database named 'aviation' will be created and it will be rebuilt with the latest aviation information.

Keep in mind that the migrations will drop the tables and will re-generate them on every sync. This strategy is only temporally until we complete the aviation frontend app that this data backs up. Once we release v.1 of this module the migrations will not destroy existing tables. They will migrate :)

Instructions

Before running a command you must have PostgreSQL installed download it. If you are a mac user the Postgress.app will simplify it.

To start run the command make

Configuration:

The configuration is at the database.json file

{
 "default": "pg",
 "pg": {
    "driver": "pg",
    "user": "aviator",
    "host": "localhost",
    "database": "aviation"
 }
}

The Makefile gets the username and database from this location.

Initially the user created for the db has no password, if you wish to set a password, you need to do it manually, you need to establish the password at the database.json file and once you've created the db and the user, set the password with the following command:

psql -U aviator -d aviation -c '\\password'

Add the password to your config file:

{
    "password": "your_password"
}

if you set the password on the config file before creating the user and the db, the Make workflow will fail.

Main Make commands:

  • make will perform the following operations:

    • npm install
    • check for db, if doesn't exist, it will create it as well as the superuser
      • NOTE: creating a sql superuser will request your admin password
    • apply a patch to comment a warning on db-migrate.
      • [WARN] The function "insert" is deprecated.
    • perform the first up migration.
  • make migration-up:

    • Performs the up migrations.
  • make migration-down:

    • Performs the down migrations.
  • make db-clean:

    • drops the database.
    • drops the user.

Database structure.

Inside the aviation db creates the following tables:

  • airports
airport_idlatitudelongitudenamenicknameiataicao
Abu_Musa_Airport25°52′32″N055°01′58″EAbu Musa AirportAbumusa AirportAEUOIBA
  • airlines
airline_idlogoLinkiataicaocallsignwebsite
Vueling//upload....230px-Logo_Vueling.svg.pngVYVLGVUELINGhttp://www.vueling.com
  • airline_hubs
airline_idairport_id
VuelingBarcelona%E2%80%93El_Prat_Airport
VuelingLeonardo_da_Vinci%E2%80%93Fiumicino_Airport
  • airline_destinations
airline_idairport_id
Adria_AirwaysAmsterdam_Airport_Schiphol
Adria_AirwaysBerlin_Tegel_Airport
  • airport_airlines
airport_idairline_id
Amsterdam_Airport_SchipholAdria Airways
Amsterdam_Airport_SchipholAegean Airlines
  • cities

    todo: add cities.

city_id
Amsterdam (wiki path)
  • airport_cities (1:1)
airport_idcity_id
Amsterdam_Airport_Schiphol(/wiki/)Amsterdam
Berlin_Tegel_Airport(/wiki/)Berlin
  • airport_runways
airport_iddirectionftmsurface
Apalachicola_Regional_Airport6/245,2711,607Concrete
Apalachicola_Regional_Airport13/315,2511,601Concrete
Apalachicola_Regional_Airport18/365,2511,601Concrete
  • city_airports (1:m)
city_idairport_id
AmsterdamAmsterdam_Airport_Schiphol
BerlinBerlin_Tegel_Airport