(->array-type type)
Returns supported by Postgres array type
Returns supported by Postgres array type
(->constraints-drop-ddl entity columns)
Converts table fields to the list of HoneySQL drop clauses
Converts table fields to the list of HoneySQL drop clauses
(->set-ddl entity columns)
Converts table fields to the list of HoneySQL alter clauses
Converts table fields to the list of HoneySQL alter clauses
(alter-table-ddl table changes)
Returns HoneySQL formatted map representing alter SQL clause
Returns HoneySQL formatted map representing alter SQL clause
(apply-migrations! {:keys [database entities]})
Generates and applies migrations related to entities on database All migrations run in a single transaction
Generates and applies migrations related to entities on database All migrations run in a single transaction
(column->constraints-map {:keys [nullable pk-name fkcolumn-name pktable-name
column-def non-unique delete-rule type-name]})
Convert table field map to field constraints map
Convert table field map to field constraints map
(column->modifiers entity col-name column)
Converts field to HoneySQL vector definition
Converts field to HoneySQL vector definition
(create-enum-ddl enum values)
Returns HoneySQL formatted map representing create enum SQL clause
Returns HoneySQL formatted map representing create enum SQL clause
(create-table entity table migrations)
Adds two SQL commands to create DB table and to delete this table
Adds two SQL commands to create DB table and to delete this table
(create-table-ddl table columns)
Returns HoneySQL formatted map representing create SQL clause
Returns HoneySQL formatted map representing create SQL clause
(drop-enum-ddl enum)
Returns HoneySQL formatted map representing drop enum SQL clause
Returns HoneySQL formatted map representing drop enum SQL clause
(drop-migrations! database rollback-migrations)
Rollback all changes made by apply-migrations! call
Rollback all changes made by apply-migrations! call
(drop-table-ddl table)
Returns HoneySQL formatted map representing drop SQL clause
Returns HoneySQL formatted map representing drop SQL clause
(entity->columns-ddl entity)
Converts entity spec to a list of HoneySQL vectors representing individual fields e.g. [[:id :uuid [:not nil] [:primary-key]] ...]
Converts entity spec to a list of HoneySQL vectors representing individual fields e.g. [[:id :uuid [:not nil] [:primary-key]] ...]
(entity->migration database migrations entity)
Given an entity will check if some updates were introduced If so will return a set of SQL migrations string
Given an entity will check if some updates were introduced If so will return a set of SQL migrations string
(extract-db-columns database table)
Returns all table fields metadata
Returns all table fields metadata
(extract-default-val column-def)
Parse column definition and return a default value
Parse column definition and return a default value
(get-all-migrations database entities)
Returns a two-dimensional vector of migration strings for all changed entities. For each entity will be two items 'SQL to apply changes' followed with 'SQL to drop changes'
Returns a two-dimensional vector of migration strings for all changed entities. For each entity will be two items 'SQL to apply changes' followed with 'SQL to drop changes'
(get-db-columns database table)
Fetches the table fields definition and convert them to simplified Clojure maps
Fetches the table fields definition and convert them to simplified Clojure maps
(get-entity-columns entity)
Given an entity will return a simplified representation of its fields as Clojure map e.g. {:id {:type uuid? :optional false :primary-key true} :name {:type string? :optional true}}
Given an entity will return a simplified representation of its fields as Clojure map e.g. {:id {:type uuid? :optional false :primary-key true} :name {:type string? :optional true}}
(get-entity-migrations-map database entities)
Returns a map of shape {:entity/name {:up 'SQL to apply changes' :down 'SQL to drop changes'}}
Returns a map of shape {:entity/name {:up 'SQL to apply changes' :down 'SQL to drop changes'}}
(get-ref-type entity-key)
Given an entity name will find a primary key field and return its type. e.g. :my/user -> :uuid Type could be complex e.g. [:string 250]
Given an entity name will find a primary key field and return its type. e.g. :my/user -> :uuid Type could be complex e.g. [:string 250]
(has-changes? db-columns entity-columns)
Given the simplified existing and updated fields definition will return true if there's a difference between them, otherwise false
Given the simplified existing and updated fields definition will return true if there's a difference between them, otherwise false
(interpolate template replacement)
Takes a template string with ${} placeholders and a hashmap with replacement values. Returns interpolated string
Takes a template string with ${} placeholders and a hashmap with replacement values. Returns interpolated string
(prep-changes entity db-columns entity-columns)
Given the simplified existing and updated fields definition will return a set of HoneySQL clauses to eliminate the difference
Given the simplified existing and updated fields definition will return a set of HoneySQL clauses to eliminate the difference
(prep-migrations database entities)
Generates migrations for all entities in the system (forward and backward)
Generates migrations for all entities in the system (forward and backward)
(schema->column-modifiers entity field-key field-schema)
Given an entity schema will return a vector of SQL field constraints, shaped as HoneySQL clauses e.g. [[:not nil] [:primary-key]]
Given an entity schema will return a vector of SQL field constraints, shaped as HoneySQL clauses e.g. [[:not nil] [:primary-key]]
(schema->column-type {:keys [type props]})
Given a field type and optional properties will return a unified (simplified) type representation. Few implementation notes: interval with fields - only DAY, HOUR, MINUTE and SECOND supported due to conversion from Duration class time with timezone doesn't really work - zone part is missed somewhere in between DB and PGDriver
Given a field type and optional properties will return a unified (simplified) type representation. Few implementation notes: interval with fields - only DAY, HOUR, MINUTE and SECOND supported due to conversion from Duration class time with timezone doesn't really work - zone part is missed somewhere in between DB and PGDriver
(schema->constraints-map entry-schema)
Converts entity field spec to a map of fields constraints used primarily for diffing states e.g. {:optional false :primary-key true}
Converts entity field spec to a map of fields constraints used primarily for diffing states e.g. {:optional false :primary-key true}
(sort-by-dependencies entities)
According to dependencies between entities will sort them in the topological order
According to dependencies between entities will sort them in the topological order
(store-migrations! {:keys [database entities clock path-pattern path-params]
:or {clock (Clock/systemUTC)}})
Writes entities migrations code into files in .edn format
Writes entities migrations code into files in .edn format
(table-exist? database table)
Checks if table exists in database
Checks if table exists in database
(unzip coll)
Reverse operation to interleave function e.g. [1 2 3 4] -> ([1 3] [2 4])
Reverse operation to interleave function e.g. [1 2 3 4] -> ([1 3] [2 4])
(update-table database entity table migrations)
Adds two SQL commands to update fields and to roll back all updates
Adds two SQL commands to update fields and to roll back all updates
(validate-schema! {:keys [database entities]})
Compares DB schema with entities specs. Returns true if there's no changes false otherwise
Compares DB schema with entities specs. Returns true if there's no changes false otherwise
Regex that matches string template variables
Regex that matches string template variables
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close