Synthesize CREATE/ALTER DDL from the current state of a live database. PostgreSQL stores only the parsed representation of DDL statements. This namespace reverse-engineers the effective DDL from the system catalogs.
Synthesize CREATE/ALTER DDL from the current state of a live database. PostgreSQL stores only the parsed representation of DDL statements. This namespace reverse-engineers the effective DDL from the system catalogs.
(ddl-for-function db schema fn)Return the CREATE OR REPLACE FUNCTION/PROCEDURE statement for a function (or procedure) in a schema. Matches by function name; for overloaded functions this returns the first match. TODO
Return the CREATE OR REPLACE FUNCTION/PROCEDURE statement for a function (or procedure) in a schema. Matches by function name; for overloaded functions this returns the first match. TODO
(ddl-for-objects db
&
{:keys [include-system-objects? schemas]
:or {include-system-objects? false}})Generate per-object DDL for every table and view in a database.
Returns a vector of maps, one per object, sorted by schema then name:
{:schema "public" :name "users" :kind :table :ddl "CREATE TABLE ..."}
Tables include their constraints, indexes, triggers and comments; views include their SELECT definition and any comments. A table whose columns cannot be decompiled (for example a PostGIS geometry column when the extension's shared library is unavailable) is returned with an :error message instead of :ddl, so one broken object does not fail the report.
Options: :include-system-objects? emit pg_catalog/information_schema objects (default false) :schemas restrict output to a vector of schema names
Generate per-object DDL for every table and view in a database.
Returns a vector of maps, one per object, sorted by schema then name:
{:schema "public" :name "users" :kind :table :ddl "CREATE TABLE ..."}
Tables include their constraints, indexes, triggers and comments; views
include their SELECT definition and any comments. A table whose columns
cannot be decompiled (for example a PostGIS geometry column when the
extension's shared library is unavailable) is returned with an :error
message instead of :ddl, so one broken object does not fail the report.
Options:
:include-system-objects? emit pg_catalog/information_schema objects (default false)
:schemas restrict output to a vector of schema names(ddl-for-table db schema table)Return the CREATE TABLE statement for a table in a schema.
Return the CREATE TABLE statement for a table in a schema.
(ddl-for-view db schema view)Return the CREATE [MATERIALIZED] VIEW statement for a view in a schema.
Return the CREATE [MATERIALIZED] VIEW statement for a view in a schema.
(generate-ddl db
&
{:keys [include-system-objects? schemas]
:or {include-system-objects? false}})Generate a full-database DDL script as a single string, composed in dependency order (tables -> constraints -> indexes -> views -> functions -> triggers -> rules -> comments).
Options: :include-system-objects? emit pg_catalog/information_schema objects (default false) :schemas restrict output to a vector of schema names
Generate a full-database DDL script as a single string, composed in dependency order (tables -> constraints -> indexes -> views -> functions -> triggers -> rules -> comments). Options: :include-system-objects? emit pg_catalog/information_schema objects (default false) :schemas restrict output to a vector of schema names
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |