Skip to content

Commit

Permalink
adds execute_ddl alter function clause, #44
Browse files Browse the repository at this point in the history
  • Loading branch information
Danwhy committed Feb 18, 2019
1 parent 403bb1a commit 8be05cb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/alog/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,22 @@ defmodule Alog.Connection do
end

def execute_ddl({:alter, %Ecto.Migration.Table{}, changes} = command) do
with :ok <-
Enum.each(
changes,
fn
{:remove, :cid, _, _} ->
raise ArgumentError, "you cannot remove cid"

{_, _, _, [primary_key: true]} ->
raise ArgumentError, "you cannot add a primary key"

_ ->
nil
end
) do
Ecto.Adapter.Postgres.Connection.execute_ddl(command)
end
end

def execute_ddl({:create, %Ecto.Migration.Index{}} = command) do
Expand Down

0 comments on commit 8be05cb

Please sign in to comment.