ForestAdmin / lumber

Install Forest Admin in minutes.
https://www.forestadmin.com
MIT License
2.08k stars 106 forks source link

TypeError: Cannot read property 'field' of undefined #25

Open solocreativeco opened 7 years ago

solocreativeco commented 7 years ago

Installation worked, got a hooray message, but this error happens when I run it.

/Users/path/to/lumber/project/node_modules/sequelize/lib/associations/belongs-to.js:64
  this.targetKeyField = this.target.rawAttributes[this.targetKey].field || this.targetKey;
                                                                 ^
TypeError: Cannot read property 'field' of undefined

Using Postgres on Heroku for DB. Installed with --ssl flag.

SeyZ commented 7 years ago

Hey @solocreativeco ! Thanks for report the issue.

One of your generated model relationship (models/) seems to be incorrect :( Do you have the database (sample data or empty) to share? Then I'll be able to reproduce the issue on my side.

Thanks!

solocreativeco commented 7 years ago

@SeyZ I wonder if it's because I have more than one foreign key on most tables along with cascade update and delete turned on. I could send you the database structure. I'm also using pgcrypto to generate UUIDs.

SeyZ commented 7 years ago

Hey @solocreativeco The database structure would be awesome, not need to have data! Is it possible?

solocreativeco commented 7 years ago

@SeyZ What's the best way to get that to you?

SeyZ commented 7 years ago

@solocreativeco sandro@munda.me

solocreativeco commented 7 years ago

Thanks, on it's way

btubbs commented 7 years ago

Also running into this issue with a Postgres database. Like solocreativeco, I'm using a custom PG function to generate IDs.

SteveMGits commented 5 years ago

I have encountered this same issue using MySQL, with the admin panel and DB all running locally. Seems to be related to my database design as I get now issues with a new database with a single empty table.

Using Lumber 1.14.2 and MySQL 5.7

VincentMolinie commented 5 years ago

This issue is due to the id field not conventional. We need to fix it @SeyZ. For now if you want to fix your issue it seems that specifying works for me (Especially inside models/advertisements) @SteveMGits:

    'Id': {
      type: DataTypes.Integer,
      primaryKey: true,
      autoincrement: true,
    },
SteveMGits commented 5 years ago

@VincentMolinie thanks for the followup! Should I create a new issue then? Or, if one already exists, would you please share it? We're definitely interested in the product but I know we want to use UUIDs as our primary keys.