Hello everyone,

We are really glad to announce that Ecto 2.0.0-beta.0 has been released. The upcoming Ecto version packs many goodies:

We have migrated to DBConnection, which considerably improves the performance of how Ecto manages connections to the database as a whole. Improved pool management, faster encoding/decoding, support for prepared queries and more

The effective deprecation of Ecto.Model in favor of a more data-oriented approach

Support for many_to_many associations and a more flexible approach to associations in general, including parallel preloading of associations

Introduction of a new SQL sandbox that allows developers to run database concurrent tests

Support for subqueries, composite primary keys, insert_all (alongside update_all and delete_all ) and more

There are many more features, bug fixes and improvements. There are also backwards incompatible changes (hence the 2.0.0 version). We recommend you to check the CHANGELOG for more information.

We appreciate developers to give this beta version a try. Keep in mind this is a beta release: bugs and regressions may exist. If you encounter an unexpected behaviour, please open up an issue report.

When trying the beta version, please pay close attention to performance. We have measured performance improvements up to 50% in some situations, but other use cases may have degraded. Please let us know of any performance measurement you run, for both positive and negative net outcomes.

This release supports only the Postgrex adapter, for PostgreSQL. MySQL support and a couple extra features, like structure loading and dumping, will be added before 2.0.0 is released.

Using Ecto 2.0 in Phoenix projects

Using Ecto 2.0 in Phoenix projects is relatively straight-forward. For a newly generated project, changes should be made to your dependencies and test files.

The first step is to update your Phoenix.Ecto dependency to 3.0.0-beta in your mix.exs . This dependency will effectively depend on Ecto 2.0 and integrate it with Phoenix:

{:phoenix_ecto, "~> 3.0.0-beta"}

Phoenix projects by default use test transactions in the test environment. Ecto 2.0 replaces test transactions by the new SQL sandbox. In your test/test_helper.exs , replace the following

Ecto.Adapters.SQL.begin_test_transaction(Demo.Repo)

by

Ecto.Adapters.SQL.Sandbox.mode(Demo.Repo, :manual)

Then, in each test/support/*_case.ex file, replace:

unless tags[:async] do Ecto.Adapters.SQL.restart_test_transaction(Demo.Repo, []) end

by

:ok = Ecto.Adapters.SQL.Sandbox.checkout(Demo.Repo)

Notice the new version no longer needs to guard against tags[:async] . With Ecto 2.0, you can run tests that depend on the database concurrently. For running acceptance tests via tools like Hound, you will currently need to use the shared mode but we will tackle it before the final 2.0 release. That’s all powered by and documented in the new SQL sandbox.

And that’s it! Of course, your project may have used other Ecto features that have been deprecated, so don’t forget to read the CHANGELOG.

We are also planning to release a series of blog posts, detailing and explaining the new Ecto 2.0 features, so keep posted!





