@@ -77,13 +77,11 @@ defmodule AshPostgres.MigrationGenerator.Operation do
7777 :bigint
7878 end
7979
80- def reference_type ( % { type: :integer , default: "nil" , generated?: true } , _ ) do
81- ":bigserial"
82- end
80+ def reference_type ( % { type: :identity } , _ ) , do: ":identity"
8381
84- def reference_type ( % { type: type } , _ ) do
85- type
86- end
82+ def reference_type ( % { type: :integer , default: "nil" , generated?: true } , _ ) , do: ":bigserial"
83+
84+ def reference_type ( % { type: type } , _ ) , do: type
8785
8886 def with_match ( reference , source_attribute \\ nil )
8987
@@ -489,6 +487,16 @@ defmodule AshPostgres.MigrationGenerator.Operation do
489487 |> join ( )
490488 end
491489
490+ def up ( % { attribute: % { type: :identity } = attribute } ) do
491+ [
492+ "add #{ inspect ( attribute . source ) } " ,
493+ ":identity" ,
494+ maybe_add_null ( attribute . allow_nil? ) ,
495+ maybe_add_primary_key ( attribute . primary_key? )
496+ ]
497+ |> join ( )
498+ end
499+
492500 def up ( % { attribute: % { type: :bigint , default: "nil" , generated?: true } = attribute } ) do
493501 [
494502 "add #{ inspect ( attribute . source ) } " ,
@@ -659,10 +667,14 @@ defmodule AshPostgres.MigrationGenerator.Operation do
659667 Map . get ( old_attribute , :references ) != Map . get ( attribute , :references ) do
660668 reference ( multitenancy , attribute , schema )
661669 else
662- if attribute . type == :bigint and attribute . default == "nil" and attribute . generated? do
663- ":bigserial "
670+ if attribute . type == :identity do
671+ ":identity "
664672 else
665- inspect ( attribute . type )
673+ if attribute . type == :bigint and attribute . default == "nil" and attribute . generated? do
674+ ":bigserial"
675+ else
676+ inspect ( attribute . type )
677+ end
666678 end
667679 end
668680
0 commit comments