kegbuna / jcpd_sc_db

Schema and Migration for CodeForJC JCPD Service Call database

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CodeForJC JCPD Service Call Database

Technologies

  • Node
  • Sequelize
  • PostgresSQL

Get Started

Before attempting to migrate records

  • Any CSVs obtained from the Jersey City Data Portal should have their columns changed to a snake_case format:
[
  "event_number",
  "district",
  "time_received",
  "shift",
  "time_dispatched",
  "time_arrived",
  "callcode",
  "call_code_description",
  "call_type",
  "priority",
  "unit_id",
  "is_primary",
  "address",
  "city",
  "latitude",
  "longitude",
  "geo_count",
  "geo_error"
]

Create a DB configuration file

In the config directory, place a file named db.json. Example:

    {
      "host": "localhost",
      "dialect": "postgres",
      "database": "postgres",
      "port": 5432,
      "user": "postgres",
      "password": "<password>"
    }

This will enable the main file to provide the DBWriter class with configuration

Create a CSV Reader configuration file

In the config directory, place a file named reader.json. Example:

    {
      "csvPath": "./migrator/data/jcpd_calls.csv",
      "fileEncoding": "utf8",
      "chunkSize": 100,
      "logLevel": "debug"
    }

csvPath should point to the location of the exported CSV file.

chunkSize indicates how many records are to be retrieved at a time. At the end of the file it just returns what is left.

Execute the script

To start it up, run node index.js in the migrator directory.

About

Schema and Migration for CodeForJC JCPD Service Call database


Languages

Language:JavaScript 100.0%