Skip to content

Instantly share code, notes, and snippets.

@radzserg
Created September 26, 2016 15:16
Show Gist options
  • Save radzserg/146330d7eca8e683b337f4d21c53309b to your computer and use it in GitHub Desktop.
Save radzserg/146330d7eca8e683b337f4d21c53309b to your computer and use it in GitHub Desktop.
Migration for image model.
defmodule App.Repo.Migrations.CreateImage do
use Ecto.Migration
def change do
create table(:images) do
add :type, :string, null: false
add :path, :string, null: false
add :mime, :string
add :size, :integer
add :width, :integer
add :height, :integer
add :parent_id, references(:images, on_delete: :nothing)
timestamps()
end
create index(:images, [:parent_id])
create index(:images, [:parent_id, :width, :height])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment