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

Error running ecto.reset #1289

Closed
joekain opened this Issue Mar 3, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@joekain

joekain commented Mar 3, 2016

Environment

  • Erlang/OTP 18 [erts-7.2] [source-e6dd627] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
  • Elixir 1.2.2
  • PostgreSQL 9.4.5.0
  • Ecto 2.0.0-beta.1
  • postgrex 0.11.1
  • Geo 1.0.1
  • Mac OS X 10.11.3 (El Capitan)

Current behavior

I have a simple reproduction case here: https://github.com/joekain/oid_migration_issue It fails on branch master when I run the mix ecto.reset command in the seeds like this:

$ mix ecto.reset
The database for OidMigrationIssue.Repo has been dropped.
The database for OidMigrationIssue.Repo has been created.

12:26:34.077 [info]  == Running OidMigrationIssue.Repo.Migrations.EnablePostgis.up/0 forward

12:26:34.078 [info]  execute "CREATE EXTENSION IF NOT EXISTS postgis"

12:26:35.161 [info]  == Migrated in 10.8s

12:26:35.208 [info]  == Running OidMigrationIssue.Repo.Migrations.CreateGeoModel.change/0 forward

12:26:35.208 [info]  create table geo_models

12:26:35.213 [info]  == Migrated in 0.0s
** (ArgumentError) no extension found for oid `1845866`
    (postgrex) lib/postgrex/types.ex:298: Postgrex.Types.fetch!/2
    (postgrex) lib/postgrex/types.ex:215: Postgrex.Types.encoder/2
    (elixir) lib/enum.ex:1088: Enum."-map/2-lists^map/1-0-"/2
    (elixir) lib/enum.ex:1088: Enum."-map/2-lists^map/1-0-"/2
    (postgrex) lib/postgrex/query.ex:82: DBConnection.Query.Postgrex.Query.encoders/2
    (postgrex) lib/postgrex/query.ex:43: DBConnection.Query.Postgrex.Query.describe/2
    (db_connection) lib/db_connection.ex:884: DBConnection.describe_execute/5
    (db_connection) lib/db_connection.ex:966: anonymous fn/4 in DBConnection.run_meter/5
    (db_connection) lib/db_connection.ex:1009: DBConnection.run_begin/3
    (db_connection) lib/db_connection.ex:421: DBConnection.query/4
    (ecto) lib/ecto/adapters/sql.ex:380: Ecto.Adapters.SQL.struct/6
    (ecto) lib/ecto/repo/schema.ex:369: Ecto.Repo.Schema.apply/5
    (ecto) lib/ecto/repo/schema.ex:175: anonymous fn/11 in Ecto.Repo.Schema.do_insert/4
    (ecto) lib/ecto/repo/schema.ex:108: Ecto.Repo.Schema.insert!/4
    (elixir) lib/code.ex:363: Code.require_file/2
    (mix) lib/mix/tasks/run.ex:68: Mix.Tasks.Run.run/1
    (mix) lib/mix/task.ex:309: Mix.Task.run_alias/3

Expected behavior

The seeds should succeed.

The seeds work with Ecto 1.1.4. You can see this in action by checking out tag "working-with-ecto-1.1.4" from the sample repo.

Observations

I believe the missing oid is related to the PostGIS extension.

Running the mix operations as separate shell commands works fine:

$ mix ecto.drop && mix ecto.create && mix ecto.migrate && mix run priv/repo/seeds.exs
The database for OidMigrationIssue.Repo has been dropped.
The database for OidMigrationIssue.Repo has been created.

12:33:29.217 [info]  == Running OidMigrationIssue.Repo.Migrations.EnablePostgis.up/0 forward

12:33:29.218 [info]  execute "CREATE EXTENSION IF NOT EXISTS postgis"

12:33:30.327 [info]  == Migrated in 11.0s

12:33:30.371 [info]  == Running OidMigrationIssue.Repo.Migrations.CreateGeoModel.change/0 forward

12:33:30.371 [info]  create table geo_models

12:33:30.376 [info]  == Migrated in 0.0s
[debug] INSERT INTO "geo_models" ("inserted_at","updated_at","geom") VALUES ($1,$2,$3) RETURNING "id" [{{2016, 3, 3}, {20, 33, 31, 0}}, {{2016, 3, 3}, {20, 33, 31, 0}}, %Geo.Point{coordinates: {30, -90}, srid: 4326}] OK query=7.6ms queue=49.6ms

I thought this could be related to #1080 where the problem affects the seeds now the migrations are fixed. Based on this I tried adding the following to the beginning of my seeds file but it didn't seem to help:

{:ok, _} = Application.ensure_all_started(:ecto)
{:ok, _} = Application.ensure_all_started(:postgrex)

I also tried running against Ecto master and the problem persisted.

@stevedomin

This comment has been minimized.

Show comment
Hide comment
@stevedomin

stevedomin Mar 3, 2016

Contributor

I was literally going to submit a new issue for that, just ran into it as well.

I'm seeing the same behaviour when trying to use Calecto dates in my seed script.

Contributor

stevedomin commented Mar 3, 2016

I was literally going to submit a new issue for that, just ran into it as well.

I'm seeing the same behaviour when trying to use Calecto dates in my seed script.

@josevalim

This comment has been minimized.

Show comment
Hide comment
@josevalim

josevalim Mar 3, 2016

Member

Fixed in master, thank you!

Member

josevalim commented Mar 3, 2016

Fixed in master, thank you!

@josevalim josevalim closed this Mar 3, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment