Skip to content

Commit

Permalink
Change schema_migration: true option to `ecto_query: :schema_migrat…
Browse files Browse the repository at this point in the history
…ions` (#633)
  • Loading branch information
andrewtimberlake committed Aug 27, 2024
1 parent 41ed13e commit d37bd8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lib/ecto/migration/schema_migration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ defmodule Ecto.Migration.SchemaMigration do
@default_opts [
timeout: :infinity,
log: false,
# Keep schema_migration for backwards compatibility
schema_migration: true,
ecto_query: :schema_migration,
telemetry_options: [schema_migration: true]
]

Expand Down
6 changes: 3 additions & 3 deletions test/support/test_repo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ defmodule EctoSQL.TestAdapter do

def execute(_, _, {:nocache, {:all, query}}, _, opts) do
%{from: %{source: {"schema_migrations", _}}} = query
true = opts[:schema_migration]
:schema_migrations = opts[:ecto_query]
versions = MigrationsAgent.get()
{length(versions), Enum.map(versions, &[elem(&1, 0)])}
end

def execute(_, _, {:nocache, {:delete_all, query}}, params, opts) do
%{from: %{source: {"schema_migrations", _}}} = query
[version] = params
true = opts[:schema_migration]
:schema_migrations = opts[:ecto_query]
MigrationsAgent.down(version, opts)
{1, nil}
end

def insert(_, %{source: "schema_migrations"}, val, _, _, opts) do
true = opts[:schema_migration]
:schema_migrations = opts[:ecto_query]
version = Keyword.fetch!(val, :version)
MigrationsAgent.up(version, opts)
{:ok, []}
Expand Down

0 comments on commit d37bd8f

Please sign in to comment.