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

cleanup-slugclj

(cleanup-slug slug)

Turn a slug fragment into a human-friendly text.

Turn a slug fragment into a human-friendly text.
sourceraw 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.
sourceraw docstring

DATETIME_PATTERNclj

source

DEFAULTSclj

source

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

error!cljmacro

(error! template & args)
source

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.
sourceraw 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.
sourceraw 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`.
sourceraw docstring

lettersclj

(letters n)
(letters n ch)

Repeat a certain string/character N times.

Repeat a certain string/character N times.
sourceraw docstring

log-connection-infoclj

(log-connection-info config)

Report the connection information.

Report the connection information.
sourceraw docstring

log-sqlclj

(log-sql url sql)
source

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

migrate-allclj

(migrate-all config)

Migrate all the pending forward migrations.

Migrate all the pending forward migrations.
sourceraw docstring

migrate-oneclj

(migrate-one config)

Apply the next single migration.

Apply the next single migration.
sourceraw 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.
sourceraw docstring

parse-nameclj

(parse-name file-name)
source

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

RE_FILEclj

source

read-disk-migrationsclj

(read-disk-migrations path)

Read all the migrations from a resource.

Read all the migrations from a resource.
sourceraw docstring

rollback-allclj

(rollback-all config)

Rollback all the previous migrations.

Rollback all the previous migrations.
sourceraw docstring

rollback-oneclj

(rollback-one config)

Rollback the current migration.

Rollback the current migration.
sourceraw docstring

rollback-toclj

(rollback-to config id-to)

Rollback to a certain migration by its ID.

Rollback to a certain migration by its ID.
sourceraw 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.
sourceraw 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).
sourceraw 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

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

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

× close