Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change schema_migration: true option to ecto_query: :schema_migrations #633

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
josevalim marked this conversation as resolved.
Show resolved Hide resolved
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
Loading