We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2e542e6 commit 0e12dc3Copy full SHA for 0e12dc3
1 file changed
lib/fable/migrations.ex
@@ -1,11 +1,13 @@
1
defmodule Fable.Migrations do
2
use Ecto.Migration
3
4
- def events_table(table) do
+ def events_table(table, opts \\ []) do
5
+ aggregate_type = Keyword.get(opts, :aggregate_type, :uuid)
6
+
7
create table(table, primary_key: false) do
8
add(:id, :bigserial, primary_key: true)
9
add(:prev_event_id, :integer)
- add(:aggregate_id, :uuid, null: false)
10
+ add(:aggregate_id, aggregate_type, null: false)
11
add(:aggregate_table, :string, null: false)
12
add(:type, :string, null: false)
13
add(:version, :integer, null: false)
@@ -24,7 +26,7 @@ defmodule Fable.Migrations do
24
26
as $$
25
27
DECLARE
28
rcount int;
- result uuid;
29
+ result #{aggregate_type};
30
find_aggregate text := format(
31
'SELECT id FROM %I WHERE id = $1', NEW.aggregate_table
32
);
0 commit comments