(->add-ddl all-columns cols-to-add)
(->constraints-drop-ddl columns)
Converts table fields to the list of HoneySQL drop clauses
Converts table fields to the list of HoneySQL drop clauses
(->drop-ddl cols-to-delete)
(->set-ddl 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]})
Convert table field map to field constraints map
Convert table field map to field constraints map
(column->modifiers column)
Converts field to HonetSQL vector definition
Converts field to HonetSQL vector definition
(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-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
(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)
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 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 entry-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
Given a field type and optional properties will return a unified (simplified) type representation
(schema->constraints-map entry-schema)
Converts entity field spec to a map of fields constraints e.g. {:optional false :primary-key? true}
Converts entity field spec to a map of fields constraints 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 rollback all updates
Adds two SQL commands to update fields and to rollback 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