Needle.Migration.Indexable (Bonfire v1.0.0-social-rc.3.22)

View Source

Helpers for creating indexes on pointer fields in migrations.

Summary

Functions

Creates index for a pointer field on a table.

Bulk-creates indexes for pointer fields on a table.

Adds a pointer field and an index for it. Note: this uses alter table and can't be run in the same migration as the create table call for the same table.

Functions

create_index_for_pointer(table_name, fields, opts \\ [])

Creates index for a pointer field on a table.

create_indexes_for_pointers(table_name, fields, opts \\ [])

Bulk-creates indexes for pointer fields on a table.

Examples

create_indexes_for_pointers(:my_table, [:user_id, :thread_id])
create_indexes_for_pointers(:my_table, [user_id: [unique: true], thread_id: [unique: false]], [where: "deleted_at IS NULL"])

create_pointer_with_index(table_name, field, type, ref_table \\ Pointer, opts \\ [])

Adds a pointer field and an index for it. Note: this uses alter table and can't be run in the same migration as the create table call for the same table.

Example

create_pointer_with_index(:my_table, :thread_id, :strong, Needle.Pointer, unique: false)