mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 05:23:18 +12:00
fix: set default properly when modifying
This commit is contained in:
parent
803a6d79b8
commit
055e22f3b7
2 changed files with 19 additions and 1 deletions
|
@ -471,6 +471,17 @@ defmodule AshPostgres.MigrationGenerator do
|
|||
else
|
||||
string
|
||||
end
|
||||
rescue
|
||||
exception ->
|
||||
IO.puts("""
|
||||
Exception while formatting:
|
||||
|
||||
#{inspect(exception)}
|
||||
|
||||
#{inspect(string)}
|
||||
""")
|
||||
|
||||
reraise exception, __STACKTRACE__
|
||||
end
|
||||
|
||||
defp streamline(ops, acc \\ [])
|
||||
|
@ -619,6 +630,9 @@ defmodule AshPostgres.MigrationGenerator do
|
|||
name in keys || (multitenancy.attribute && name == multitenancy.attribute)
|
||||
end
|
||||
|
||||
defp after?(%Operation.AddUniqueIndex{table: table}, %Operation.RemoveUniqueIndex{table: table}),
|
||||
do: true
|
||||
|
||||
defp after?(
|
||||
%Operation.AddUniqueIndex{identity: %{keys: keys}, table: table},
|
||||
%Operation.AlterAttribute{table: table, new_attribute: %{name: name}}
|
||||
|
|
|
@ -124,8 +124,12 @@ defmodule AshPostgres.MigrationGenerator.Operation do
|
|||
|
||||
default =
|
||||
if attribute.default != old_attribute.default do
|
||||
if is_nil(attribute.default) do
|
||||
", default: nil"
|
||||
else
|
||||
", default: #{attribute.default}"
|
||||
end
|
||||
end
|
||||
|
||||
null =
|
||||
if attribute.allow_nil? != old_attribute.allow_nil? do
|
||||
|
|
Loading…
Reference in a new issue