# `Storehouse.Ecto.Migrations`
[🔗](https://github.com/hattoriai/storehouse/blob/v0.2.0/lib/storehouse/ecto/migrations.ex#L2)

The tables of a library of files (`Storehouse.Ecto.Blob`,
`Storehouse.Ecto.Usage`), for a migration of the app's:

    defmodule MyApp.Repo.Migrations.AddStorehouseBlobs do
      use Ecto.Migration

      def up, do: Storehouse.Ecto.Migrations.up()
      def down, do: Storehouse.Ecto.Migrations.down()
    end

It makes two tables:

  * `storehouse_blobs` - a file a row: its key (unique), store, owner,
    name, type, size, checksum, width, height, metadata, analysis,
    `processing_error` and timestamps, with a UUID for its id. The same
    file of the same owner is one row (a unique index of the owner and
    the checksum).
  * `storehouse_usages` - which records use each file: the blob, the
    record's table and id. A blob a record uses cannot be deleted, by
    the database's own foreign key.

Apps that keep their files in records' columns (`Storehouse.Ecto.File`)
need neither.

## Options

  * `:blobs` and `:usages` - the tables' names. The defaults are
    `"storehouse_blobs"` and `"storehouse_usages"`.
  * `:unique_checksum` - `false` lets an owner keep the same file twice.
    The default is `true`.
  * `:prefix` - the database schema (PostgreSQL's) of the tables.

# `down`

```elixir
@spec down(keyword()) :: :ok
```

Drops the tables.

# `up`

```elixir
@spec up(keyword()) :: :ok
```

Makes the tables.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
