elixir-lang/ecto — pull request #336 by joshnuss (2014-12-24 10:45:08+00:00)
Title: Updated Migration DSL

This is an updated version of #132.

TODO

- [ ] Add more column types (boolean, decimal, etc..), currently only primary key, varchar, datetime, integer
- [ ] Add `timestamps/0` function to DSL (maybe this should be a separate PR, since the models should support this notion too)
- [ ] Add `references/1` for creating foreign keys i.e.

```elxir
create table(:products) do
add reference(:category)
end
```

It supports a DSL syntax, for creating/dropping/altering objects:

## Change Example:

```elixir
defmodule Repo.Migrations.CreatePosts do
use Ecto.Migration

def change do
create table(:posts) do
add :title, :string
add :published_at, :time
end
end
end
```

## Up/Down Example:
```elixir
defmodule Repo.Migrations.CreatePosts do
use Ecto.Migration

def up do
create table(:posts) do
add :title, :string
add :published_at, :time
end
end

def down do
drop table(:posts)
end
end
```

## Alter Example:
```elixir
defmodule Repo.Migrations.CreatePosts do
use Ecto.Migration

def change do
alter table(:posts) do
add :summary, :string
remove :published_at
change :title, :string
rename :owner, :created_by
end
end
end

```