Ecto: Allow enabling extenstions using migrations

Created on 5 Dec 2016  路  6Comments  路  Source: elixir-ecto/ecto

It would be nice to have Ecto.Migration.extension method which would allow us to run:

defmodule MyApp.Migrations.EnableExtensions do
  use Ecto.Migration

  def change do
    create_if_not_exist extension("uuid-ossp")
  end
end

Or similar code. Similar to #1805

Enhancement Intermediate

Most helpful comment

Maybe we should look into ways of making it possible for extensions to provide such behaviour?

All 6 comments

Extensions are very postgresql specific. I would personally rather see them in a separate package, something like PostgresEcto that could also include other postgresql specific extensions - macros wrapping fragments for some common functions, etc.

I can try to produce something like that.

Unfortunately it is not possible to implement something like the above in a third party project. In any case, I don't mind having Postgres specific behaviour in Ecto most times, specially this one which is a very minor feature.

@josevalim I can accept that challenge.

Maybe we should look into ways of making it possible for extensions to provide such behaviour?

@michalmuskala I would love to and tried a couple times in the past. The best solution I had in mind is to define one protocol per adapter and I am not confident it is the best way to go.

Was this page helpful?
0 / 5 - 0 ratings