From 8be05cb2492c8c376305c4690d23515d75f02b91 Mon Sep 17 00:00:00 2001 From: Danielwhyte Date: Mon, 18 Feb 2019 12:19:23 +0000 Subject: [PATCH] adds execute_ddl alter function clause, #44 --- lib/alog/connection.ex | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/alog/connection.ex b/lib/alog/connection.ex index 03aa313..9f848fb 100644 --- a/lib/alog/connection.ex +++ b/lib/alog/connection.ex @@ -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