# Errors with 1-m associations (mysql+npm project setup)

**URL:** <https://community.forestadmin.com/t/errors-with-1-m-associations-mysql-npm-project-setup/2898>\
**Category:** Help me!\
**Tags:** setup\
**Created:** [July 13, 2021, 5:07pm UTC](https://community.forestadmin.com/t/errors-with-1-m-associations-mysql-npm-project-setup/2898 "2021-07-13T17:07:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Partizan\_Chg](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/partizan_chg/32/2676_2.png) [@Partizan\_Chg](https://community.forestadmin.com/u/Partizan_Chg)\
**Post date:** [July 13, 2021, 5:07pm UTC](https://community.forestadmin.com/t/errors-with-1-m-associations-mysql-npm-project-setup/2898/1 "2021-07-13T17:07:08Z")

</div>

I created the first project following the instructions for the MySQL DB. Installation via npm was successful, all models recognized, no errors or warnings. I went to the forestadmin app and I see all the tables. But in those tables where there are foreign keys, an error occurs. For example, I have a simple relation one _user_ - many _characters_, error when trying to view the table _characters_:

```javascript
[forest] ��� Unexpected error: Unknown column 'characters.user_uid'
in 'on clause'
{
  "name": "SequelizeDatabaseError",
  "parent": {
    "code": "ER_BAD_FIELD_ERROR",
    "errno": 1054,
    "sqlState": "42S22",
    "sqlMessage": "Unknown column 'characters.user_uid' in 'on clause'",
    "sql": "SELECT count(`characters`.`uid`) AS `count` FROM `characters
` AS `characters` LEFT OUTER JOIN `users` AS `userUid` ON `characters`.`
user_uid` = `userUid`.`uid` LEFT OUTER JOIN `users` AS `userUidUserUid`
ON `characters`.`user_uid` = `userUidUserUid`.`uid`;"

```

But there is no foreign key ‘user\_uid’. Correct foreign key name is ‘userUid’. It looks like it ignores the correct foreign key name and tries to generate it according to the rule tableName+\_+primaryKey.

In addition, I see strange extra associations in the table settings: `userUidUserUid` - I don’t have such a table.

## Context

- Database Dialect: MySQL
- Database Version: 8.0.19
- Project Name: mcm

---

<div class="post-metadata">

**Author:** ![anon16419211](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anon16419211](https://community.forestadmin.com/u/anon16419211)\
**Post date:** [July 15, 2021, 7:47am UTC](https://community.forestadmin.com/t/errors-with-1-m-associations-mysql-npm-project-setup/2898/2 "2021-07-15T07:47:27Z")

</div>

Hello @Partizan_Chg & welcome on our community forum 🙂

Can you share to me the following file _models/characters.js_ from your project?

Kind regards,

---

<div class="post-metadata">

**Author:** ![Partizan\_Chg](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/partizan_chg/32/2676_2.png) [@Partizan\_Chg](https://community.forestadmin.com/u/Partizan_Chg)\
**Post date:** [July 23, 2021, 11:09pm UTC](https://community.forestadmin.com/t/errors-with-1-m-associations-mysql-npm-project-setup/2898/3 "2021-07-23T23:09:32Z")

</div>

Hello 🙂

[characters.tar](https://community.forestadmin.com/uploads/short-url/plWukfK1FEmolrJkkONPbZuviXi.tar) (4 KB)

For example I also attached my sequelize model declaration (typescript decorator).  
[DBCharacter.model.tar](https://community.forestadmin.com/uploads/short-url/gORG73CFqtuGu3U7GbXcf30ZshX.tar) (3 KB)

---

<div class="post-metadata">

**Author:** ![anon23361380](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/32.png) [@anon23361380](https://community.forestadmin.com/u/anon23361380)\
**Post date:** [July 26, 2021, 9:14am UTC](https://community.forestadmin.com/t/errors-with-1-m-associations-mysql-npm-project-setup/2898/4 "2021-07-26T09:14:49Z")

</div>

Hello @Partizan_Chg,

Can you send us also the definition of both tables `users` and `characters` please?

Best regards,  
Mia

---

<div class="post-metadata">

**Author:** ![Partizan\_Chg](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/partizan_chg/32/2676_2.png) [@Partizan\_Chg](https://community.forestadmin.com/u/Partizan_Chg)\
**Post date:** [July 31, 2021, 9:21pm UTC](https://community.forestadmin.com/t/errors-with-1-m-associations-mysql-npm-project-setup/2898/5 "2021-07-31T21:21:39Z")

</div>

Hello!

[models.tar](https://community.forestadmin.com/uploads/short-url/9MHsiYGO6HnfBhxbZ02L2DVilry.tar) (6 KB)
