vinniefranco / exandra Goto Github PK
View Code? Open in Web Editor NEWScyllaDB + Ecto
License: MIT License
ScyllaDB + Ecto
License: MIT License
At the moment there is no way to declare a tuple in the schemas, probably a custom type (like Exandra.Set
) is necessary
Describe the bug
I added the exandra to the deps {:exandra, "~> 0.6"}
Then I made a repo with config
defmodule Chats.XandraRepo do
use Ecto.Repo,
otp_app: :chats,
adapter: Exandra
end
And generated a migration.
But when I run mix ecto.migrate
I get the following error
[error] Could not create schema migrations table. This error usually happens due to the following:
* The database does not exist
* The "schema_migrations" table, which Ecto uses for managing
migrations, was defined by another library
* There is a deadlock while migrating (such as using concurrent
indexes with a migration_lock)
To fix the first issue, run "mix ecto.create" for the desired MIX_ENV.
To address the second, you can run "mix ecto.drop" followed by
"mix ecto.create", both for the desired MIX_ENV. Alternatively you may
configure Ecto to use another table and/or repository for managing
migrations:
I see my keyspace in cqlsh
so the database definitely exists
What can I do to fix it?
Currently, for this migration:
rename table("my_table"), :old_name, to: :new_name
You get this:
** (FunctionClauseError) no function clause matching in Exandra.Connection.execute_ddl/1
The following arguments were given to Exandra.Connection.execute_ddl/1:
# 1
{:rename, %Ecto.Migration.Table{name: "cursors", prefix: nil, comment: nil, primary_key: true, engine: nil, options: nil}, :source_type, :resource_type}
Attempted function clauses (showing 9 out of 9):
def execute_ddl({command, %Ecto.Migration.Table{} = table, columns}) when command === :create or command === :create_if_not_exists
def execute_ddl({:alter, %Ecto.Migration.Table{} = table, columns})
def execute_ddl({command, %Ecto.Migration.Table{} = table, _}) when command === :drop or command === :drop_if_exists
def execute_ddl({_command, %Ecto.Migration.Constraint{}, _})
def execute_ddl({_command, %Ecto.Migration.Constraint{}})
def execute_ddl({command, %Ecto.Migration.Index{} = index}) when command === :create or command === :create_if_not_exists
def execute_ddl({command, %Ecto.Migration.Index{} = index, :restrict}) when command === :drop or command === :drop_if_exists
def execute_ddl({command, %Ecto.Migration.Index{}, :cascade}) when command === :drop or command === :drop_if_exists
def execute_ddl(string) when is_binary(string)
(exandra 0.6.5) lib/exandra/connection.ex:645: Exandra.Connection.execute_ddl/1
(ecto_sql 3.10.1) lib/ecto/adapters/sql.ex:1003: Ecto.Adapters.SQL.execute_ddl/4
(ecto_sql 3.10.1) lib/ecto/migration/runner.ex:327: Ecto.Migration.Runner.log_and_execute_ddl/3
(elixir 1.15.2) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
(stdlib 5.0.2) timer.erl:270: :timer.tc/2
(ecto_sql 3.10.1) lib/ecto/migration/runner.ex:25: Ecto.Migration.Runner.run/8
(ecto_sql 3.10.1) lib/ecto/migrator.ex:362: Ecto.Migrator.attempt/8
(ecto_sql 3.10.1) lib/ecto/migrator.ex:283: anonymous fn/5 in Ecto.Migrator.do_up/5
Steps to reproduce.
On the repo https://github.com/cyberchitta/M.ai perform
mix ecto.drop
mix ecto.create
mix ecto.migrate
mix run priv/repo/seeds.exs
results in the stacktrace
** (Ecto.ChangeError) value `<<96, 78, 199, 171, 247, 83, 76, 152, 146, 66, 173, 187, 123, 148, 19, 228>>` for `Mai.Chat.Message.chat_id` in `insert` does not match type :binary_id
(ecto 3.11.2) lib/ecto/repo/schema.ex:1049: Ecto.Repo.Schema.dump_field!/6
(ecto 3.11.2) lib/ecto/repo/schema.ex:1058: anonymous fn/6 in Ecto.Repo.Schema.dump_fields!/5
(stdlib 5.2) maps.erl:416: :maps.fold_1/4
(ecto 3.11.2) lib/ecto/repo/schema.ex:1056: Ecto.Repo.Schema.dump_fields!/5
(ecto 3.11.2) lib/ecto/repo/schema.ex:989: Ecto.Repo.Schema.dump_changes!/7
(ecto 3.11.2) lib/ecto/repo/schema.ex:367: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
(ecto 3.11.2) lib/ecto/repo/schema.ex:273: Ecto.Repo.Schema.insert!/4
(elixir 1.16.2) lib/enum.ex:992: anonymous fn/3 in Enum.each/2
(elixir 1.16.2) lib/enum.ex:4388: Enum.reduce_range/5
(elixir 1.16.2) lib/enum.ex:2532: Enum.each/2
(elixir 1.16.2) lib/enum.ex:992: anonymous fn/3 in Enum.each/2
(elixir 1.16.2) lib/enum.ex:4388: Enum.reduce_range/5
(elixir 1.16.2) lib/enum.ex:2532: Enum.each/2
priv/repo/seeds.exs:22: (file)
However, <<96, 78, 199, 171, 247, 83, 76, 152, 146, 66, 173, 187, 123, 148, 19, 228>>
is a 16 byte binary, so it should be a uuid
i.e. a :binary_id
, and the cast should work.
In fact, a very similar insert earlier in the same script (for inserting a new chat with a foreign key) does actually work.
UPDATE. Using exandra 0.10.2
Some basic CQL types are not supported (possibly because tuples are unsupported at the moment #58)
Hey! I just discovered Exandra while randomly looking to xandra
dependents on Hex and it seems it would simplify a lot some codebases we're working on, but that would require support for querying across multiple keyspaces.
Right now, I see it's mainly meant to be used with a single keyspace (since a keyspace is required to be passed in start_link
), but I already verified that it's possible to query tables on other keyspaces by just using
from "<keyspace>.<table>"
Would it be possible to map the different keyspaces onto Ecto prefixes? From the documentation it seems that MySQL maps them on different databases, which are more or less the equivalents of keyspaces. From the tests it seems to be supported at least in migrations, but passing prefix: :foo
in Repo.all
doesn't seem to work (though it sets the prefix on the returned schema).
If you think this is possible and it would be a desirable feature to have, I can try to tackle this with a PR.
Describe the bug
Xandra query options (eg :uuid_format
) no longer work, crashing with ** (NimbleOptions.ValidationError) unknown options [:uuid_format], valid options are: [:compressor, :force, :tracing, :custom_payload, :telemetry_metadata, :timeout]
.
I believe this is because the same options are passed to Xandra.prepare and Xandra.execute, and with whatyouhide/xandra@f9c34be Xandra.prepare does no longer validate valid prepare options only.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Valid options are passed to Xandra.execute
Desktop (please complete the following information):
Originally posted by restlessronin March 28, 2024
I am successfully running migrations now. One of my migrations is giving me the following
11:32:40.004 [info] create table messages
** (Xandra.Error) line 1:32 : Missing ')'
(ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1054: Ecto.Adapters.SQL.raise_sql_call_error/1
(elixir 1.16.2) lib/enum.ex:1700: Enum."-map/2-lists^map/1-1-"/2
(ecto_sql 3.11.1) lib/ecto/adapters/sql.ex:1161: Ecto.Adapters.SQL.execute_ddl/4
(ecto_sql 3.11.1) lib/ecto/migration/runner.ex:348: Ecto.Migration.Runner.log_and_execute_ddl/3
(elixir 1.16.2) lib/enum.ex:1700: Enum."-map/2-lists^map/1-1-"/2
(stdlib 5.2) timer.erl:270: :timer.tc/2
(ecto_sql 3.11.1) lib/ecto/migration/runner.ex:25: Ecto.Migration.Runner.run/8
(ecto_sql 3.11.1) lib/ecto/migrator.ex:365: Ecto.Migrator.attempt/8
Here is the migration being attempted
defmodule Mai.Repo.Migrations.CreateMessages do
use Ecto.Migration
def change do
create table(:messages, primary_key: false) do
add(:id, :binary_id, primary_key: true)
add(:order, :int)
add(:role, :string)
add(:content, :string)
add(:chat_id, :binary_id)
add(:original_message_id, :binary_id)
timestamps()
end
end
end
i changed from :integer
to :int
, but that didn't seem to matter.
UPDATE. When I remove the :order
field, however, the migration succeeds.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.