pointers v0.4.0 Pointers.Migration View Source

Helpers for writing Pointer-aware migrations.

Link to this section Summary

Functions

Adds a pointer primary key to the table. Not required if you are using create_pointable_table

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

Creates a pointable table along with its trigger.

Drops a mixin table. Actually just a simple cascading drop

Drops a pointable 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.

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.

Link to this section Types

Specs

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

Link to this section Functions

Specs

add_pointer_pk() :: nil

Adds a pointer primary key to the table. Not required if you are using create_pointable_table

Specs

add_pointer_ref_pk() :: nil
Link to this macro

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

View Source (macro)

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

Link to this macro

create_pointable_table(a, b)

View Source (macro)

Specs

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)

Specs

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

create_pointable_table(a, b, c, d)

View Source (macro)

Specs

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

Specs

drop_mixin_table(name :: binary()) :: nil

Drops a mixin table. Actually just a simple cascading drop

Link to this function

drop_pointable_table(schema)

View Source

Specs

drop_pointable_table(schema :: atom()) :: nil

Drops a pointable table

Link to this function

drop_pointable_table(name, id)

View Source

Specs

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

Specs

init_pointers() :: nil

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

Specs

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 Pointers.ULID.Migration.init_pointers_ulid_extra/0.

Link to this function

pointer(table \\ Pointer, type)

View Source

Specs

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.