timelink.migrations package

timelink.migrations.autogenerate(db_url, message)[source]

Autogenerate migration script.

timelink.migrations.column_exists(table_name, column_name, alembic_op)[source]

Check if a column exists

Parameters:
  • table_name – name of table

  • column_name – name of column

  • alembic_op – alembic operations object in use

Example:

timelink.migrations.current(db_url, verbose=False)[source]

Get the current revision of the database.

timelink.migrations.downgrade(db_url, revision)[source]

Downgrade the database to the given revision.

timelink.migrations.get_versions(base='base', head='heads')[source]

Get the list of versions of the database.

Parameters:
  • base (str) – The base revision to start from.

  • head (str) – The head revision to stop at.

timelink.migrations.heads(db_url)[source]

Show heads of database

timelink.migrations.history(verbose=False)[source]

Show the migration history.

timelink.migrations.revision(db_url, message, autogenerate=False)[source]

Create a new revision.

timelink.migrations.set_db_url(db_url)[source]

Set the database URL in the alembic configuration.

This should be done before running any alembic commands in a specific database

timelink.migrations.stamp(db_url, revision: str)[source]

Stamp current revision to a given revision Use “heads” to mark the database as up-to-date

timelink.migrations.upgrade(db_url, revision='heads')[source]

Upgrade the database to a given revision (default most recent).

Submodules

timelink.migrations.alembic_extensions module

class timelink.migrations.alembic_extensions.CreateViewOp(target)[source]
class timelink.migrations.alembic_extensions.DropViewOp(target)[source]
class timelink.migrations.alembic_extensions.ReplaceableObject(name, sqltext)[source]

A class for creating replaceable database objects.

“We first need to create a simple object that represents the “CREATE View” / “DROP View” aspect of what it is we’re building. We can just as well put strings inside dictionaries, which would also work. Nevertheless, I will illustrate how this object helps organize the code below.”

class timelink.migrations.alembic_extensions.ReversibleOp(target)[source]
classmethod invoke_for_target(operations, target)[source]

This method is proxied on the Operations class, via the Operations.drop_view() method.

classmethod replace(operations, target, replaces=None, replace_with=None)[source]

This method is proxied on the Operations class, via the Operations.replace_view() method.