migration-scripts icon indicating copy to clipboard operation
migration-scripts copied to clipboard

Cannot read properties of undefined (reading 'includes')

Open rlisac opened this issue 1 year ago • 7 comments

Bug report

Required System information

  • Node.js version: 16.13.2
  • NPM version: 8.1.2
  • Source Strapi version: 3.6.8
  • Target Strapi version: 4.3.8
  • Source Database: mysql
  • Target Database: mysql
  • Operating system: OSX
  • Which script are you running: v3-sql-v4-sql

Describe the bug

When running the script, the script aborts with the following error: const v3RelationTables = tables.filter((t) => t.includes("__")); TypeError: Cannot read properties of undefined (reading 'includes')

Steps to reproduce the behavior

  1. Go to 'nvm use 16'
  2. Run $ yarn
  3. Run $ yarn start
  4. See error

Screenshots

issue_RLI

Code snippets

const v3RelationTables = tables.filter((t) => t.includes("__"));

Additional context

Before starting the script, I had to adjust certain columns in the table to be compliant with the snake_case.

rlisac avatar Sep 16 '22 17:09 rlisac

I'm experiencing the same issue, apparently some tables are showing up as "undefined", which causes the the migration script to stop.

System information

  • Node.js version: 14.20.1
  • NPM version: 6.14.17
  • Source Strapi version: 3.6.8
  • Target Strapi version: 4.3.8
  • Source Database: mysql
  • Target Database: mysql
  • Operating system: OSX
  • Which script are you running: v3-sql-v4-sql

image

jpizzati-uvl avatar Sep 27 '22 14:09 jpizzati-uvl

It appear that this is a case issue. I was able to resolve this by renaming all instances of "table_name" to "TABLE_NAME", (3) in total and found in:

  • index.js
  • migrateComponents.js
  • relationHelpers.js

Screen Shot 2022-09-27 at 20 13 14

Screen Shot 2022-09-27 at 20 13 30

Screen Shot 2022-09-27 at 20 13 45

jpizzati-uvl avatar Sep 27 '22 18:09 jpizzati-uvl

Hi, what version of mysql (mariadb) are you using? I'm not able to reproduce this error. In the meantime I created fix in way you proposed viz #55

martincapek avatar Sep 30 '22 11:09 martincapek

I'm on version 2.18.1 (npm)

jpizzati-uvl avatar Sep 30 '22 11:09 jpizzati-uvl

And the database itself? Im using mariadb:10.5.8

martincapek avatar Sep 30 '22 13:09 martincapek

mysql 8.0.28

jpizzati-uvl avatar Sep 30 '22 18:09 jpizzati-uvl

Okey, I will test it also on that, thanks!

martincapek avatar Oct 04 '22 06:10 martincapek