Troubleshooting Ecto Associations and Insert Query

218
clicks
Troubleshooting Ecto Associations and Insert Query

Source: reddit.com

Type: Discussion

George Summers has encountered a problem while working with Ecto, the database wrapper and query generator for Elixir. The project involves processing and storing data from API polling into a SQLite database. George has set up schemas for `User`, `Chat`, and `Counter` with `has_many` and `belongs_to` associations. However, when attempting to insert a new `Counter` with associated `User` and `Chat` entries, the code is failing with an error indicating that the `counters` table lacks a `chat_id` column. George provided the `Counter` schema and migration details, highlighting the absence of `_id` fields in the user code and confusion about why Ecto is looking for these fields during insertion.

© HashMerge 2024