View Source Needle.Migration (Bonfire v0.9.11-social-beta.6)

Helpers for writing Pointer-aware migrations.

Summary

Functions

Creates a mixin table - one with a UID primary key and no trigger

Creates a pointable table along with its trigger.

Creates a random table - one with a UUID v4 primary key.

Drops a mixin table.

Drops a pointable table

Drops a random table.

When migrating up: initialises the pointers database. When migrating down: deinitialises the pointers database.

Given :up: initialises the pointers database. Given :down: deinitialises the pointers database.

See Needle.UID.Migration.init_pointers_ulid_extra/0.

Creates a strong, weak or unbreakable pointer depending on type.

A reference to a pointer for use with add/3. A strong pointer will be deleted when the thing it's pointing to is deleted.

A reference to a pointer for use with add/3. An unbreakable pointer will prevent the thing it's pointing to from being deleted.

A reference to a pointer for use with add/3. A weak pointer will be set null when the thing it's pointing to is deleted.

Types

pointer_type()

@type pointer_type() :: :strong | :weak | :unbreakable

Functions

add_is_not_deleted(table)

create_mixin_table(name, opts \\ [], body)

(macro)
@spec create_mixin_table(name :: atom() | binary(), opts :: list(), body :: term()) ::
  nil

Creates a mixin table - one with a UID primary key and no trigger

create_pointable_table(a, b)

(macro)
@spec create_pointable_table(schema :: atom(), body :: term()) :: term()

Creates a pointable table along with its trigger.

create_pointable_table(a, b, c)

(macro)
@spec create_pointable_table(
  schema :: atom(),
  opts :: Keyword.t(),
  body :: term()
) :: term()
@spec create_pointable_table(source :: binary(), id :: binary(), body :: term()) ::
  term()

create_pointable_table(a, b, c, d)

(macro)
@spec create_pointable_table(
  source :: binary(),
  id :: binary(),
  opts :: Keyword.t(),
  body :: term()
) :: term()

create_random_table(name, opts \\ [], body)

(macro)

Creates a random table - one with a UUID v4 primary key.

create_virtual(schema)

create_virtual(source, id)

create_virtual_trigger_function()

drop_mixin_table(name)

@spec drop_mixin_table(name :: atom() | binary()) :: nil

Drops a mixin table.

drop_pointable_table(schema)

@spec drop_pointable_table(schema :: atom()) :: nil

Drops a pointable table

drop_pointable_table(name, id)

@spec drop_pointable_table(name :: binary(), id :: binary()) :: nil

drop_random_table(name)

@spec drop_random_table(name :: atom() | binary()) :: nil

Drops a random table.

drop_table(name)

drop_virtual(schema)

drop_virtual(name, id)

init_pointers()

@spec init_pointers() :: nil

When migrating up: initialises the pointers database. When migrating down: deinitialises the pointers database.

init_pointers(atom)

@spec init_pointers(direction :: :up | :down) :: nil

Given :up: initialises the pointers database. Given :down: deinitialises the pointers database.

init_pointers_ulid_extra()

See Needle.UID.Migration.init_pointers_ulid_extra/0.

migrate_virtual(schema)

migrate_virtual(name, schema)

migrate_virtual(atom, name, id)

pointer(table \\ Pointer, type)

@spec pointer(module :: atom(), type :: pointer_type()) :: term()

Creates a strong, weak or unbreakable pointer depending on type.

strong_pointer(table \\ Pointer)

A reference to a pointer for use with add/3. A strong pointer will be deleted when the thing it's pointing to is deleted.

unbreakable_pointer(table \\ Pointer)

A reference to a pointer for use with add/3. An unbreakable pointer will prevent the thing it's pointing to from being deleted.

weak_pointer(table \\ Pointer)

A reference to a pointer for use with add/3. A weak pointer will be set null when the thing it's pointing to is deleted.