Liking cljdoc? Tell your friends :D

pg.migration.core

Common migration functions.

Common migration functions.
raw docstring

-migrateclj

(-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.
raw docstring

-rollbackclj

(-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.
raw docstring

cleanup-slugclj

(cleanup-slug slug)

Turn a slug fragment into a human-friendly text.

Turn a slug fragment into a human-friendly text.
raw docstring

create-migration-filesclj

(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.
raw docstring

DATETIME_PATTERNclj


DEFAULTSclj


ensure-tableclj

(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.
raw docstring

error!cljmacro

(error! template & args)

generate-datetime-idclj

(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.
raw docstring

get-applied-migration-idsclj

(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.
raw docstring

group-parsed-urlsclj

(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`.
raw docstring

lettersclj

(letters n)
(letters n ch)

Repeat a certain string/character N times.

Repeat a certain string/character N times.
raw docstring

log-connection-infoclj

(log-connection-info config)

Report the connection information.

Report the connection information.
raw docstring

log-sqlclj

(log-sql url sql)

make-file-nameclj

(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.
raw docstring

make-scopeclj

(make-scope config)

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.

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.
raw docstring

migrate-allclj

(migrate-all config)

Migrate all the pending forward migrations.

Migrate all the pending forward migrations.
raw docstring

migrate-oneclj

(migrate-one config)

Apply the next single migration.

Apply the next single migration.
raw docstring

migrate-toclj

(migrate-to config id-to)

Migrate forward to a certain migration by its ID.

Migrate forward to a certain migration by its ID.
raw docstring

parse-urlclj

(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.
raw docstring

RE_FILEclj


read-disk-migrationsclj

(read-disk-migrations path)

Read all the migrations from a resource.

Read all the migrations from a resource.
raw docstring

rollback-allclj

(rollback-all config)

Rollback all the previous migrations.

Rollback all the previous migrations.
raw docstring

rollback-oneclj

(rollback-one config)

Rollback the current migration.

Rollback the current migration.
raw docstring

rollback-toclj

(rollback-to config id-to)

Rollback to a certain migration by its ID.

Rollback to a certain migration by its ID.
raw docstring

text->slugclj

(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.
raw docstring

url->migrationsclj

(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).
raw docstring

validate-conflicts!clj

(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

raw docstring

validate-duplicates!clj

(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.
raw docstring

validate-migration-id!clj

(validate-migration-id! migrations id)

Check if the migration map has a certain id.

Check if the migration map has a certain id.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close