Created
February 1, 2018 15:55
-
-
Save theoretick/112a01768b5ce4fade3457facb687ac9 to your computer and use it in GitHub Desktop.
Generating Entity Relationship Diagrams (ERD) with ruby Sequel and Graphiz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
# | |
# Usage: ./dot_to_png input.dot output.png | |
if [ ! -x $(command -v dot) ] | |
then | |
echo 1>&2 "dot missing in \$PATH" | |
echo 1>&2 "Couldn't find graphiz" | |
exit 2 | |
fi | |
dot -Tpng "$1.dot" > "$2.png" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require "sequel" | |
require 'sequel_schema_dot_generator' | |
DB = Sequel.connect("postgres://user:password@localhost:5432/my_database") | |
File.open("schema_dump_#{Time.now}.dot", "w+") do |file| | |
file.write( | |
SequelSchemaDotGenerator::Generator.new(db: DB).generate | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment