narf37

narf37

I am using phoenix and the tds ecto adapter, on a controller i dont have any repo import or alias , and every time i call a controller action the tds adapter keeps querying the schema_migrations tables. I does the following 8 queries

IF NOT EXISTS (SELECT * FROM [INFORMATION_SCHEMA].[TABLES] WHERE [TABLE_NAME] = 'schema_migrations') CREATE TABLE [schema_migrations] ([version] bigint, [inserted_at] datetime, CONSTRAINT [schema_migrations_pkey] PRIMARY KEY CLUSTERED ([version])); 
go
exec sp_unprepare @handle=7
go
declare @p1 int
set @p1=4
exec sp_prepare @handle=@p1 output,@params=N'',@stmt=N'sp_getapplock @Resource = ''ecto_ApiSystem.Repo'', @LockMode = ''Exclusive'', @LockOwner = ''Transaction'', @LockTimeout = -1'
select @p1
go
sp_getapplock @Resource = 'ecto_ApiSystem.Repo', @LockMode = 'Exclusive', @LockOwner = 'Transaction', @LockTimeout = -1
go
exec sp_unprepare @handle=4
go
declare @p1 int
set @p1=5
exec sp_prepare @handle=@p1 output,@params=N'',@stmt=N'SELECT CAST(s0.[version] AS bigint) FROM [schema_migrations] AS s0'
select @p1
go
SELECT CAST(s0.[version] AS bigint) FROM [schema_migrations] AS s0
go
exec sp_unprepare @handle=5
go

I am fairly new on elixir and ecto , I know that this is a behaviour to allow migrations on distributed deployments, my question is why is it happening on a route that does not touch the database and why is it happen on every single call.

Showing Posts 1 to 4

al2o3cr

al2o3cr

Hi @narf37! I went ahead and formatted your log messages with triple-backticks ``` so they’re more legible.

Regarding your question, that check is coming from the CheckRepoStatus plug:

https://github.com/phoenixframework/phoenix_ecto/blob/master/lib/phoenix_ecto/check_repo_status.ex

which is included in the default endpoint.ex generated by Phoenix. It only runs in development mode; more discussion on that in the Plug guide.

narf37

narf37 OP

Also i dont have any schemas defined or migrations pending my repo looks like this

defmodule ApiSystem.Repo do
use Ecto.Repo,
otp_app: :api_system,
adapter: Ecto.Adapters.Tds
end

scope “/api”, ApiSystemWeb do
pipe_through :api

get "/test", TestController, :testMethod

end

defmodule ApiSystemWeb.TestController do
use ApiSystemWeb, :controller
alias Jason

def testMethod(conn, _params) do
conn
|>json(%{test: “ok”})
end

end

narf37

narf37 OP

thats it!, i commented and now it dont get query.

is there a reason why it was to be done on every request?

al2o3cr

al2o3cr

Most web frameworks (Phoenix included) will reload your application’s code when a change to the files is detected. In Phoenix, that check happens on every request.

But this can lead to unexpected behavior when the user creates a migration, adds a new field to a schema, but forgets to run the migration - the newly-loaded code expects a field that isn’t there!

CheckRepoStatus aims to prevent that problem by verifying that the development database is caught-up.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews