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

ecto.migrate cannot create migration table #17

Open
astavonintsc opened this issue Feb 21, 2020 · 1 comment
Open

ecto.migrate cannot create migration table #17

astavonintsc opened this issue Feb 21, 2020 · 1 comment

Comments

@astavonintsc
Copy link

How to reproduce:
Create any migration for the new DB, call mix ecto.migrate

Expected result: migration successfully executed.
Actual result:

warning: :pool_timeout option no longer has an effect and has been replaced with an improved queuing system.
See "Queue config" in DBConnection.start_link/2 documentation for more information.

  (ecto_sql) lib/ecto/adapters/sql.ex:469: Ecto.Adapters.SQL.adapter_config/1
  (ecto_sql) lib/ecto/adapters/sql.ex:456: Ecto.Adapters.SQL.init/3
  (ecto) lib/ecto/repo/supervisor.ex:172: Ecto.Repo.Supervisor.init/1
  (stdlib) supervisor.erl:295: :supervisor.init/1
  (stdlib) gen_server.erl:374: :gen_server.init_it/2

** (FunctionClauseError) no function clause matching in String.Unicode.codepoints/1    
    
    The following arguments were given to String.Unicode.codepoints/1:
    
        # 1
        ["CREATE TABLE IF NOT EXISTS ", [34, "schema_migrations", 34], 32, 40, [[[], [[34, "version", 34], 32, "Int64", [[], []]], ", "], [34, "inserted_at", 34], 32, "DateTime", [[], []]], 41, [], " ENGINE = TinyLog "]
    
    Attempted function clauses (showing 1 out of 1):
    
        def codepoints(binary) when is_binary(binary)
    
    (elixir) lib/elixir/unicode/unicode.ex:300: String.Unicode.codepoints/1
    (clickhousex) lib/clickhousex/query.ex:39: DBConnection.Query.Clickhousex.Query.parse/2
    (db_connection) lib/db_connection.ex:1122: DBConnection.parse/3
    (db_connection) lib/db_connection.ex:531: DBConnection.prepare_execute/4
    (clickhousex) lib/clickhousex.ex:59: Clickhousex.query/4
    (ecto_sql) lib/ecto/adapters/sql.ex:291: Ecto.Adapters.SQL.query!/4
    (elixir) lib/enum.ex:1336: Enum."-map/2-lists^map/1-0-"/2
    (ecto_sql) lib/ecto/adapters/sql.ex:699: Ecto.Adapters.SQL.execute_ddl/4
@alex88
Copy link

alex88 commented Sep 2, 2021

Like other queries in ClickhouseEcto.Query the fix is to change the connection execute ddl to

  def execute_ddl(command),
    do: ClickhouseEcto.Migration.execute_ddl(command) |> IO.iodata_to_binary()

but it then fails with

** (UndefinedFunctionError) function ClickhouseEcto.Connection.ddl_logs/1 is undefined or private
    (clickhouse_ecto 0.3.0) ClickhouseEcto.Connection.ddl_logs(%Clickhousex.Result{columns: ["count"], command: :updated, num_rows: 1, rows: [[1]]})
    (elixir 1.12.2) lib/enum.ex:3894: Enum.flat_map_list/2
    (ecto_sql 3.7.0) lib/ecto/adapters/sql.ex:845: Ecto.Adapters.SQL.execute_ddl/4
    (ecto_sql 3.7.0) lib/ecto/migrator.ex:645: Ecto.Migrator.verbose_schema_migration/3
    (ecto_sql 3.7.0) lib/ecto/migrator.ex:473: Ecto.Migrator.lock_for_migrations/4
    (ecto_sql 3.7.0) lib/ecto/migrator.ex:388: Ecto.Migrator.run/4
    (ecto_sql 3.7.0) lib/ecto/migrator.ex:146: Ecto.Migrator.with_repo/3
    (ecto_sql 3.7.0) lib/mix/tasks/ecto.migrate.ex:133: anonymous fn/5 in Mix.Tasks.Ecto.Migrate.run/2

Update: this fixes the above error:

  def ddl_logs(%Clickhousex.Result{command: command, num_rows: num_rows}),
    do: [{:debug, "Successfully #{command} #{num_rows} rows", []}]

Now the problem is:

** (UndefinedFunctionError) function ClickhouseEcto.lock_for_migrations/3 is undefined or private
    (clickhouse_ecto 0.3.0) ClickhouseEcto.lock_for_migrations(%{cache: #Reference<0.1177087518.2266628098.100040>, opts: [timeout: 15000, pool_size: 2, pool: DBConnection.ConnectionPool], pid: #PID<0.632.0>, repo: Things5.ChRepo, sql: ClickhouseEcto.Connection, telemetry: {Things5.ChRepo, :debug, [:things5, :ch_repo, :query]}}, [migration_source: "schema_migrations", all: true], #Function<13.122349345/0 in Ecto.Migrator.lock_for_migrations/4>)

which seems to happen even with:

  use Ecto.Adapters.SQL,
    driver: :clickhousex,
    migration_lock: false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants