Phoenix 1.3 boilerplate db relation error

After using the generator mix phx.gen.html and firing up the server seem to be getting an error

ERROR 42P01 (undefined_table): relation “blog_posts” does not exist

have used the generator correctly with contexts … phx.gen.html Blog Post posts title:string body:string

ecto.create / migrate

tried new projects and json generator same thing…

How to resolve and why is it doing this straight out of the box

What is the entire output when you ran mix ecto.create on the fresh database and what is the contents of your priv/repo/migrations directory?

are you on latest phoenix rc?

check the migration for what table was actually created.

I believe dropping that table, upgrading to latest rc and rerunning phx.gen might solve it.

$ mix ecto.migrate

17:07:51.922 [info]  Already up

/priv/repo/migrations is empty


I believe I just found the issue…

The generator is creating the wrong directory in my phx project folder…

my phoenix project is under c:/home/phx/

and inside my project folder the generator has created a /home/phx/myApp/priv/repo/migrations

David@ADMINRG-E6T26UQ MINGW64 /c/home/phx/api_example
$ mix phx.gen.html Blog Post posts title:string body:string

  • creating lib/api_example/web/controllers/post_controller.ex
  • creating lib/api_example/web/templates/post/edit.html.eex
  • creating lib/api_example/web/templates/post/form.html.eex
  • creating lib/api_example/web/templates/post/index.html.eex
  • creating lib/api_example/web/templates/post/new.html.eex
  • creating lib/api_example/web/templates/post/show.html.eex
  • creating lib/api_example/web/views/post_view.ex
  • creating test/api_example/web/controllers/post_controller_test.exs
  • creating ./lib/api_example/blog/post.ex
  • creating home/phx/api_example/priv/repo/migrations/20170703160511_create_blog_post.exs
  • creating ./lib/api_example/blog/blog.ex
  • injecting ./lib/api_example/blog/blog.ex
  • creating ./test/api_example/blog/blog_test.exs
  • injecting ./test/api_example/blog/blog_test.exs

that windows bug is (should be!) fixed in master

so upgrade all the way to master.

believe it’s

mix archive.install
EDIT: you might have to git clone and install ‘phx’ that way

and upgrade deps to git master in your project.

{:phoenix, github: "phoenixframework/phoenix", override: true},

1 Like