fireproofsocks

fireproofsocks

I’m going a bit nuts – I’m trying to create an alternate PostGres schema for an app’s tables. The idea is that Ecto can store its migrations stuff inside public, but all of our app’s tables we want in core. So here are our migrations:

Migration 1:

def change do
    execute("CREATE SCHEMA core")
    flush()
end

Migration 2:

  def up do
    create table("users", primary_key: false, prefix: "core") do
      add(:id, :binary_id, primary_key: true)
      add(:email, :string, size: 128)
      # ...  etc...
      timestamps(inserted_at: :created_at)
    end

Note the prefix core.

This works fine locally (but granted, our local dockerized instances of PostGres have very few restrictions). On prod, however, we are relying a custom module that calls Ecto.Migrator to run the migrations (because there’s no mix on prod).

Previously, this worked well (with a legacy app). But on the new app, the migrations are not running successfully.

Problem 1: the core schema does not seem to ever get created by the migration. Running the migrations chokes on migration 2 with an error like:

{:error,
 %Postgrex.Error{
   connection_id: 3411,
   message: nil,
   postgres: %{
     code: :invalid_schema_name,
     file: "namespace.c",
     line: "3023",
     message: "schema \"core\" does not exist",
     pg_code: "3F000",
     position: "14",
     routine: "get_namespace_oid",
     severity: "ERROR",
     unknown: "ERROR"
   },
   query: nil}}

Problem 2: even if I manually create the core schema (e.g. by logging into the PostGres instance), then the migrations complete successfully, but then I can’t actually query the database. Running any sort of Ecto query using the Repo just fails with the following error:

** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 1313ms. This means requests are coming in and your connection pool cannot serve them fast enough. You can address this by:

  1. Ensuring your database is available and that you can connect to it
  2. Tracking down slow queries and making sure they are running fast enough
  3. Increasing the pool_size (although this increases resource consumption)
  4. Allowing requests to wait longer by increasing :queue_target and :queue_interval

See DBConnection.start_link/2 for more information

    (ecto_sql 3.8.3) lib/ecto/adapters/sql.ex:932: Ecto.Adapters.SQL.raise_sql_call_error/1
    (ecto_sql 3.8.3) lib/ecto/adapters/sql.ex:847: Ecto.Adapters.SQL.execute/6
    (ecto 3.8.4) lib/ecto/repo/queryable.ex:221: Ecto.Repo.Queryable.execute/4
    (ecto 3.8.4) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
    (resources 1.1.0) lib/resources/pg_resource.ex:206: Resources.PGResource.get_many/3

This seems similar to Creating postgres schemas (schema_prefix) but I have no solution for it. I have checked the Ecto config and it all looks correct. I mean… I can run migrations (sort of), but I can’t seem to do anything else.

Does anyone have any ideas on this? Our previous database was set up manually without migrations – but I think we should be able to get it set up with normal migrations. Do special privileges need to be granted to the db user before queries are allowed?

Thanks in advance!

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
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
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
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
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
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
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
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
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews