Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Dump from MS Access Database

Nathan Struhs edited this page May 20, 2019 · 3 revisions

The Northwestern Bat Hub currently maintains a Microsoft Access database containing all of the data to be moved to Batabase. Since the Access database is continually receiving new data we need a solution in which we can continually spin up new Batabase databases from a db dump from the Access database.

Copying the MS Access DB to Postgres

The tool we used to create the dump from the Access database is Bullzip.

Once you have obtained the dump you can create a local Postgres database:

  1. Drop database if currently exists
    • psql -d postgres -c "DROP DATABASE batabase_development"
  2. Create fresh db
    • createdb batabase_development
  3. Execute dump on new database
    • psql -d batabase_development -f dump.sql

🎉You now have a Postgres copy of the MS Access database.

The update-db script

The Batabase db has significant differences to the original Access db. Tables and columns have been removed or renamed either at the client's request or to reflect Ruby on Rails conventions. The changes the client requested can be viewed in this doc https://public.3.basecamp.com/p/jsp4CgHjNvkToqkJBVyebwpE in Basecamp.

To ensure we can update the db reliably every time we have created a SQL script to execute against your local database. The script is located at <root>/lib/update-db.sql. From the root of the project you can run:

psql -d batabase_development -f lib/update-db.sql

Seeding data

Not all of the data is available within the Access database and needs to be added to the database manually. We have created rake tasks in lib/tasks/seed.rake to do so. These tasks either add hardcoded values or parse CSV's to add the data. Additionally, we create users so we do not have to sign up with the application every time we re-seed the db. Feel free to add you own email and password to the create users task.

Rake tasks can be executed by:

bundle exec rake seed:<your-task>

Putting it all together

To make it easy on ourselves we have placed this entire process to in single script. From the root of the project execute:

sh script/createdb.sh