arpan
Hi everyone, I have been trying to setup xandra in order to use Cassandra in my phoenix project. The xandra connection with Cassandra is made in my application.ex file, by specifying it as a child in my supervision tree like {Xandra, name: :xandra_connection} now I can execute queries like …
statement =
"CREATE KEYSPACE test WITH replication = {'class':'SimpleStrategy', 'replication_factor' : 3};"
Xandra.execute(:xander_connection, statement, [])
This works but in case of migrations involving xandra I need to establish the xandra connection every time like…
defmodule Test.Repo.Migrations.CreateKeyspace do
use Ecto.Migration
def up do
Xandra.start_link(name: :xander_connection)
statement =
"CREATE KEYSPACE test WITH replication = {'class':'SimpleStrategy', 'replication_factor' : 3};"
Xandra.execute(:xander_connection, statement, [])
end
def down do
Xandra.start_link(name: :xander_connection)
statement = "DROP KEYSPACE test"
Xandra.execute(:xander_connection, statement, [])
end
end
I want to establish the connection once before running the migrations and avoid writing Xandra.start_link(name: :xander_connection) every time in the migrations.
Can anyone help me with this?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley:
Mutonex gamedesign was finish...
New
Do we have maintainer of absinthe-graphql/dataloader here? We have a PR that we’d like to merge to the library. Relatively small additive...
New
Hello
I’ve been coding in Elixir for almost two years now because of my current job where we implemented Elixir in our application. But ...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
al2o3cr
How do you start Xandra normally? If you’re using an application entry in
mix.exs, you could try adding astart_apps_before_migrationentry referring to it to your Repo’s configuration.https://github.com/elixir-ecto/ecto_sql/blob/192f235a6aa386fcd3ca241680bd950510740ec6/lib/ecto/migration.ex#L221-L224
arpan
Thanks for the reply, I already saw this but I am confused, how do I specify
Xandra.start_link(name: :xander_connection)instart_apps_before_migrationsince it only accepts a list of atoms where the atoms are .app files.I added this in my config
config :app, App.Repo, start_apps_before_migration: [:xandra]This will try to start the app defined in
_build/dev/lib/xandra/ebin/xandra.appbut does this actually do
Xandra.start_link()?Also I need to specify a name to the Xandra process like
Xandra.start_link(name: :xander_connection)So that later I can use this name to execute queries like
Xandra.execute(:xander_connection, query, [])without the name I don’t know the pid of the Xandra process even if it is started.
SPrio-kt
Here xandra is a child process for the Your Application Supervisor, So you can start the Xandra before migration, by writing this line
start_apps_before_migration: [:my_app]in your Repo configuration. This means you are starting your application before migration. Your config.exs may look like -thiago
I tried following @SPrio-kt’s solution, but now everytime I try to run tests or start the server I keep getting errors with the following message:
** (RuntimeError) cannot use Logger, the :logger application is not running.Has anyone else stumbled upon this issue?