Skip to content

Instantly share code, notes, and snippets.

@unnawut
Last active May 16, 2018 19:06
Show Gist options
  • Save unnawut/0fcff22d6d191d830dc3350fcc4c8753 to your computer and use it in GitHub Desktop.
Save unnawut/0fcff22d6d191d830dc3350fcc4c8753 to your computer and use it in GitHub Desktop.
Getting an SQL schema dump from OmiseGO eWallet server
# This is an UNOFFICIAL script, unsupported by OmiseGO.
# Many thanks to js/suprtux1 for this awesome and simple docker-compose.yml file!
version: '2.1'
services:
ewallet:
image: omisego/ewallet:latest
depends_on:
db:
condition: service_healthy
environment:
- DATABASE_URL=postgresql://postgres:password@db:5432/ewallet
- LOCAL_LEDGER_DATABASE_URL=postgresql://postgres:password@db:5432/local_ledger
- MIX_ENV=dev
- ENV=dev
ports:
- 4000:4000
db:
image: postgres:9
restart: always
environment:
POSTGRES_PASSWORD: password
ports:
- 5432:5432
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 30s
retries: 3
#!/bin/sh
#
# This UNOFFICIAL script is a quick way to dump the latest database schemas of the OmiseGO eWallet server.
# Learn more at https://github.com/omisego/ewallet
#
# Use this script along with the `docker-compose.yml` file also attached in this gist.
#
# Thanks to openyourmind on OmiseGO's RocketChat for the question and suggestion.
# Spin up the required docker images.
docker-compose up -d
# Installs pg_dump.
docker-compose exec ewallet apt-get install postgresql-client -y
# Create the required databases, migrate to the latest version, dump the schema out.
docker-compose exec ewallet mix do ecto.create, ecto.migrate, ecto.dump
# Copy the SQL dumps into the host machine.
docker cp $(docker-compose ps -q ewallet):/app/apps/ewallet_db/priv/repo/structure.sql ewallet_db.sql
docker cp $(docker-compose ps -q ewallet):/app/apps/local_ledger_db/priv/repo/structure.sql local_ledger_db.sql
# Clean up the created docker containers.
docker-compose down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment