View Source Needle.Migration (Bonfire v0.9.10-classic-beta.169)

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

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

Functions

Link to this function

add_is_not_deleted(table)

View Source
Link to this macro

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

View Source (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

Link to this macro

create_pointable_table(a, b)

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

Creates a pointable table along with its trigger.

Link to this macro

create_pointable_table(a, b, c)

View Source (macro)
@spec create_pointable_table(
  schema :: atom(),
  opts :: Keyword.t(),
  body :: term()
) :: term()
@spec create_pointable_table(source :: binary(), id :: binary(), body :: term()) ::
  term()
Link to this macro

create_pointable_table(a, b, c, d)

View Source (macro)
@spec create_pointable_table(
  source :: binary(),
  id :: binary(),
  opts :: Keyword.t(),
  body :: term()
) :: term()
Link to this macro

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

View Source (macro)

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

Link to this function

create_virtual(source, id)

View Source
Link to this function

create_virtual_trigger_function()

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

Drops a mixin table.

Link to this function

drop_pointable_table(schema)

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

Drops a pointable table

Link to this function

drop_pointable_table(name, id)

View Source
@spec drop_pointable_table(name :: binary(), id :: binary()) :: nil
@spec drop_random_table(name :: atom() | binary()) :: nil

Drops a random table.

@spec init_pointers() :: nil

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

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

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

Link to this function

init_pointers_ulid_extra()

View Source

See Needle.UID.Migration.init_pointers_ulid_extra/0.

Link to this function

migrate_virtual(name, schema)

View Source
Link to this function

migrate_virtual(atom, name, id)

View Source
Link to this function

pointer(table \\ Pointer, type)

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

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

Link to this function

strong_pointer(table \\ Pointer)

View Source

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.

Link to this function

unbreakable_pointer(table \\ Pointer)

View Source

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

Link to this function

weak_pointer(table \\ Pointer)

View Source

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.