timeoff-management / timeoff-management-application

Simple yet powerful absence management software for small and medium size business (community edition)
https://TimeOff.Management
MIT License
951 stars 588 forks source link

MySQL foreign key error #284

Closed APMarte closed 6 years ago

APMarte commented 6 years ago

Hi, like @enriquetoledano reported on issue #204 mysql has a problem with foreign key constraint. In the same issue @genietto84 shown one possible solution:

check on the MySql and the error is:

Error in foreign key constraint of table timeoff/departmentsupervisor: FOREIGN KEY (department_id) REFERENCES Department (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (user_id) REFERENCES User (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB: You have defined a SET NULL condition though some of the columns are defined as NOT NULL.

I made this change on lib/model/db/department.js on line 73

foreignKey : 'department_id',

Become:

foreignKey : {name: 'department_id', allowNull: false},

And seem to work fine.

Are you willing to accept a PR?

vpp commented 6 years ago

Yes, please

Sent from my iPhone

On 6 Jun 2018, at 19:05, António Pedro Martins notifications@github.com wrote:

Hi, like @enriquetoledano reported on issue #204 mysql has a problem with foreign key constraint. In the same issue @genietto84 shown one possible solution:

check on the MySql and the error is:

Error in foreign key constraint of table timeoff/departmentsupervisor: FOREIGN KEY (department_id) REFERENCES Department (id) ON DELETE SET NULL ON UPDATE CASCADE, FOREIGN KEY (user_id) REFERENCES User (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB: You have defined a SET NULL condition though some of the columns are defined as NOT NULL.

I made this change on lib/model/db/department.js on line 73

foreignKey : 'department_id',

Become:

foreignKey : {name: 'department_id', allowNull: false},

And seem to work fine.

Are you willing to accept a PR?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.