You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On MySQL, the table creation does not happen successfully (because of the impossibly stupid handling of foreign keys in MySQL).
I had to modify the 'createTables' class as follows
`
createTables(){constknex=this.knex;returnknex.schema.dropTableIfExists('Person_Movie')// changed order of dropping for MySQL.then(()=>{returnknex.schema.dropTableIfExists('Review');}).then(()=>{returnknex.schema.dropTableIfExists('Person');}).then(()=>{returnknex.schema.dropTableIfExists('Movie');}).then(()=>{returnknex.schema.createTable('Movie',(table)=>{table.increments('id').primary().unsigned();table.string('name');table.date('release_date');});}).then(()=>{returnknex.schema.createTable('Person',(table)=>{table.increments('id').primary().unsigned();table.string('firstName');table.string('lastName');table.enum('gender',_.values(models.Person.Gender));table.integer('age');table.json('addresses',true);table.integer('parentId').unsigned().nullable().defaultTo(0)// .references('id') /* delay creation of foreign key for mysql */// .inTable('Person').index();});}).then(()=>{returnknex.schema.raw('alter table Person add CONSTRAINT FOREIGN KEY (`parentId`) REFERENCES `Person` (`id`)');}).then(()=>{returnknex.schema.createTable('Review',(table)=>{table.increments('id').primary().unsigned();table.string('title');table.integer('stars');table.string('text');table.integer('movieId').unsigned().nullable().references('id').inTable('Movie').index();table.integer('reviewerId').unsigned().nullable().references('id').inTable('Person').index();});}).then(()=>{returnknex.schema.createTable('Person_Movie',(table)=>{table.increments('id').primary().unsigned().index();table.integer('movieId').unsigned().nullable().references('id').inTable('Movie').index();table.integer('personId').unsigned().nullable().references('id').inTable('Person').index();});});}
`
Evenafterthis,though,thereweremanyfailures,Ihaveattachedazipfilewithalogoftheerrors,pleaseseeattached[test_errors.zip](https://github.com/Vincit/objection-graphql/files/1417732/test_errors.zip)
The text was updated successfully, but these errors were encountered:
@koskimas Thanks! MySQL is notorious for it's poor foreign key handling, for many years now. And I don't understand why knex has a 'dropForeign' method, but no 'addForeign' method. Weird.
On MySQL, the table creation does not happen successfully (because of the impossibly stupid handling of foreign keys in MySQL).
I had to modify the 'createTables' class as follows
`
The text was updated successfully, but these errors were encountered: