Skip to content

Instantly share code, notes, and snippets.

View hjkatz's full-sized avatar

Harrison Katz hjkatz

View GitHub Profile
@hjkatz
hjkatz / lucidchart.sql
Created March 15, 2017 12:36
LucidChart Reverse Engineer PostgreSQL Query
\copy (
SELECT 'postgresql' AS dbms,
current_database() AS table_catalog,
n.nspname::VARCHAR AS table_schema,
c.relname::VARCHAR AS table_name,
a.attname::VARCHAR AS column_name,
a.attnum::INTEGER AS ordinal_position,
CASE WHEN t.typname::VARCHAR ~ 'int'
THEN 'integer'
WHEN t.typname::VARCHAR = 'timestamp'
GetOptions(
'<>' => \&parse_arg,
'targets-file=s' => \$targets_file,
'scripts-file=s' => \$scripts_file,
'helpers-file=s' => \$helpers_file,
'log-file=s' => \$global_log_file,
'd|validate' => \$is_validate_mode,
'n|dry-run' => \$is_dry_run_mode,
's|strict' => \$is_strict_mode,
'v|verbose' => \$is_verbose_mode,
grammar URL
{
token TOP
{
<schema> '://'
[<ip> | <hostname> ]
[ ':' <port>]?
'/' <path>?
}