Applying seed bug

Wappler Version : 3.9.4
Operating System : W10
Server Model: Node
Database Type: Mysql
Hosting Type: node / docker

Expected behavior

What do you think should happen?

Seed should remove current database records and replace with the ones in the seed.

Actual behavior

What actually happens?

Error occurs: cannot delete or update a parent row: a foreign key constraint fails.
image


How to reproduce

  1. Create seed of a table. tick the ‘delete records’ box
  2. Apply seed immediately

Extra info:
Knex file looks like this:

exports.seed = function(knex) {
  // Deletes ALL existing entries
  return knex('smart_courses.courses').del()
    .then(function () {
      // Inserts seed entries
      return knex('smart_courses.courses').insert([
  {
    "teacher": 34,
    "course_title": "The pain and the prize",
    "course_description": "What you gain and what you lose",
    "course_length": "5",
    "course_cover_image": "assets/course_cover_images/pain-prize-bg.jpg",
    "created_at": "2021-04-07T09:44:36.000Z",
    "updated_at": "2021-04-07T09:44:36.000Z",
    "school": null
  }, CONTINUED...

The table looks like this:

There are references to this table in these tables:

Well this is more an SQL design and referential integrity. So it depends on how you have defined your foreign keys and their on update/on delete constrains.

See also:

@George I see… I have only used Wappler UI for the database. I’m loving the DB manager.
So I was hoping this would work - so I can set up a bunch of data in dev environment and then sync it with the db in production.

I didn’t even realise there were constraints set up - I guess it’s default or something that wappler did. Is this issue something that will be made easy through wappler’s ui?

This has been fixed in Wappler 4.7.2

This topic was automatically closed after 42 hours. New replies are no longer allowed.