Reputation: 1706
I am new to Elixir/Phoenix/Ecto. I created a database with 4 different schemas using ecto.migration. The tables were created correctly, but when I try to query the tables, ecto doesn't find them.
ERROR 42P01 (undefined_table): relation "users" does not exist
I know the problem is database schema-related because when I create the users table in the default schema, ecto finds it without any problem.
Upvotes: 0
Views: 1796
Reputation: 230
Make sure the migration file and the schema file have the same table name "users".
You can use the mix ecto.migrations
command to check the status of each migration file to make sure it was applied to the database.
In Phoenix, you don't have to use Ecto directly to create schemas. You can use phoenix commands to help you create the necessary files and modules:
mix phx.gen.html Accounts User users username:string age:integer
This will create a migration file which will create a "users" table. It will also create a schema file and module called MyApp.Accounts.User
which will be tied to the users
table through the schema "users" do
macro.
If you are creating a migration file manually, make sure you are using the correct table name everywhere, i.e., in queries and schema files.
Upvotes: 1