From a792f429a659bf74debdabea1b27856daeb47d22 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki <7413593+a8m@users.noreply.github.com> Date: Mon, 1 May 2023 17:14:17 +0300 Subject: [PATCH] dialect/sql/schema: allow ariga.io/atlas schema diff to be extended (#3514) By not relying on the SchemaDiff signature, we allow the schema.Differ to be extended without introducing breaking changes to ent --- dialect/sql/builder.go | 2 +- dialect/sql/schema/atlas.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dialect/sql/builder.go b/dialect/sql/builder.go index edd732ca5..6d9537df8 100644 --- a/dialect/sql/builder.go +++ b/dialect/sql/builder.go @@ -2748,7 +2748,7 @@ type ( // custom clause for locking. clause string } - // LockOption allows configuring the LockConfig using functional options. + // LockOption allows configuring the LockOptions using functional options. LockOption func(*LockOptions) ) diff --git a/dialect/sql/schema/atlas.go b/dialect/sql/schema/atlas.go index 519edba09..e2870dcd5 100644 --- a/dialect/sql/schema/atlas.go +++ b/dialect/sql/schema/atlas.go @@ -1153,7 +1153,9 @@ func (r *diffDriver) RealmDiff(_, _ *schema.Realm) ([]schema.Change, error) { // SchemaDiff creates the diff between two schemas, but includes "diff hooks". func (r *diffDriver) SchemaDiff(from, to *schema.Schema) ([]schema.Change, error) { - var d Differ = DiffFunc(r.Driver.SchemaDiff) + var d Differ = DiffFunc(func(current, desired *schema.Schema) ([]schema.Change, error) { + return r.Driver.SchemaDiff(current, desired) + }) for i := len(r.hooks) - 1; i >= 0; i-- { d = r.hooks[i](d) }