Common migration functions.
Common migration functions.
(-migrate scope id-migration's)
A general migrate forward function. Don't use it directly. Accepts the scope map and a seq of pairs (id, migration). Runs the migrations one by one. Tracks the applied migrations in the database.
A general migrate forward function. Don't use it directly. Accepts the scope map and a seq of pairs (id, migration). Runs the migrations one by one. Tracks the applied migrations in the database.
(-rollback scope id-migration's)
A general rollback function. Don't use it directly. Accepts the scope map and a seq of pairs (id, migration). Rolls back the migrations one by one. Removes the records from the database.
A general rollback function. Don't use it directly. Accepts the scope map and a seq of pairs (id, migration). Rolls back the migrations one by one. Removes the records from the database.
(cleanup-slug slug)
Turn a slug fragment into a human-friendly text.
Turn a slug fragment into a human-friendly text.
(create-migration-files migrations-path)
(create-migration-files migrations-path {:keys [id slug]})
Create a couple of new migration files, prev and next.
When not set, the id is generated from the current UTC time.
Return a pair of File
objects, prev and next.
Create a couple of new migration files, prev and next. When not set, the id is generated from the current UTC time. Return a pair of `File` objects, prev and next.
(ensure-table conn migrations-table)
Having a db connection and the name of the migrations table, create a table if it doesn't exist.
Having a db connection and the name of the migrations table, create a table if it doesn't exist.
(generate-datetime-id)
Generate a Long number based on the current UTC datetime of a format YYYYmmddHHMMSS, e.g. 20240308154432.
Generate a Long number based on the current UTC datetime of a format YYYYmmddHHMMSS, e.g. 20240308154432.
(get-applied-migration-ids conn table)
Read all the applied migrations from the database and return a set of their ids.
Read all the applied migrations from the database and return a set of their ids.
(group-parsed-urls parsed-urls)
Having a seq of maps (parsed URLs), unify them by id.
Return a sorted map, an instance of clojure.lang.Sorted
.
Having a seq of maps (parsed URLs), unify them by id. Return a sorted map, an instance of `clojure.lang.Sorted`.
(letters n)
(letters n ch)
Repeat a certain string/character N times.
Repeat a certain string/character N times.
(log-connection-info config)
Report the connection information.
Report the connection information.
(make-file-name id text direction)
Compose a file name based on the id, an optional slug, and the direction type.
Compose a file name based on the id, an optional slug, and the direction type.
(make-scope config)
Having a raw config map, do the following:
Return a map of all these fields.
Having a raw config map, do the following: - apply config defautls - build migrations map - get applied migration IDs from the database - mark applied migrations; - detect the current migration; Return a map of all these fields.
(migrate-all config)
Migrate all the pending forward migrations.
Migrate all the pending forward migrations.
(migrate-one config)
Apply the next single migration.
Apply the next single migration.
(migrate-to config id-to)
Migrate forward to a certain migration by its ID.
Migrate forward to a certain migration by its ID.
(parse-url url)
Split a URL pointing to a migration file to various fields.
Split a URL pointing to a migration file to various fields.
(read-disk-migrations path)
Read all the migrations from a resource.
Read all the migrations from a resource.
(rollback-all config)
Rollback all the previous migrations.
Rollback all the previous migrations.
(rollback-one config)
Rollback the current migration.
Rollback the current migration.
(rollback-to config id-to)
Rollback to a certain migration by its ID.
Rollback to a certain migration by its ID.
(text->slug text)
Turn a 'Human Friendly Text ' into something like 'human-friendly-text' to be a part of a migration file.
Turn a 'Human Friendly Text ' into something like 'human-friendly-text' to be a part of a migration file.
(url->migrations url)
Fetch all the migrations from the top-level URL. Return a sorted map like (id => migration-map).
Fetch all the migrations from the top-level URL. Return a sorted map like (id => migration-map).
(validate-conflicts! migrations)
Try to find a situation when a migration with less ID was applied before another migration with a greater ID.
For example:
id applied 1 yes 2 yes 3 no 4 yes
Above, 3 is less then 4 but 4 has been applied whereas 3 has not. Usually it happens when two features get merged at the same time. To fix it, rename the migration 3 to 5 as follows:
id applied 1 yes 2 yes 4 yes 5 no
Try to find a situation when a migration with less ID was applied before another migration with a greater ID. For example: id applied 1 yes 2 yes 3 no 4 yes Above, 3 is less then 4 but 4 has been applied whereas 3 has not. Usually it happens when two features get merged at the same time. To fix it, rename the migration 3 to 5 as follows: id applied 1 yes 2 yes 4 yes 5 no
(validate-duplicates! parsed-urls)
Having a seq of parsed URLs, find those that have the same (id, direction) pair. If found, an exception is thrown.
Having a seq of parsed URLs, find those that have the same (id, direction) pair. If found, an exception is thrown.
(validate-migration-id! migrations id)
Check if the migration map has a certain id.
Check if the migration map has a certain id.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close