Execute Raw SQL In An Ecto Migration
defmodule MyApp.Repo.Migrations.CreatePostsTable do
use Ecto.Migration
def up do
execute """
create table posts (
id serial primary key,
title varchar not null,
body varchar not null default '',
inserted_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
"""
end
def down do
execute "drop table posts;"
end
endLast updated