Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seed into mysql doesn't work #122

Open
pjsotou opened this issue Apr 7, 2024 · 3 comments
Open

Seed into mysql doesn't work #122

pjsotou opened this issue Apr 7, 2024 · 3 comments

Comments

@pjsotou
Copy link

pjsotou commented Apr 7, 2024

When I try to run the project using a MySQL instance the import doesnt work

yarn strapi import -f ../seed-data.tar.gz

[ERROR] insert into components_layout_footers_categories_links (category_id, category_order, footer_id) values (2, 3, 2) - ER_NO_REFERENCED_ROW_2: Cannot add or update a child row: a foreign key constraint fails (strapi.components_layout_footers_categories_links, CONSTRAINT components_layout_footers_categories_links_fk FOREIGN KEY (footer_id) REFERENCES components_layout_footers (id) ON DEL)

Here is my docker file

version: '3.1'

services:
  mysql:
    image: mysql:8
    command: --default-authentication-plugin=mysql_native_password
    environment:
      MYSQL_ROOT_PASSWORD: du1jh4812hd
      MYSQL_DATABASE: strapi
      MYSQL_USER: strapi
      MYSQL_PASSWORD: uf0joi1jfo3i98145jklfjdhklashjklKLJJd
    volumes:
    - mysql_data_8:/var/lib/mysql
    - ./init-mysql:/docker-entrypoint-initdb.d
    ports:
      - "3309:3306"

Here is my databse.js

module.exports = ({ env }) => ({
  connection: {
    client: 'mysql',
    connection: {
      host: env('DATABASE_HOST', '127.0.0.1'),
      port: env.int('DATABASE_PORT', 3309),
      database: env('DATABASE_NAME', 'strapi'),
      user: env('DATABASE_USERNAME', 'root'),
      password: env('DATABASE_PASSWORD', 'du1jh4812hd'),
      ssl: env.bool('DATABASE_SSL', false),
    },
  },
});

Remember to run in the mysql instance and exec

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'admin';

FLUSH PRIVILEGES;
@PaulBratslavsky
Copy link
Contributor

@pjsotou thank you, will take a look to see what can be going on here.

Quick question. Have you tried, adding your own data when running SQL and exporting and reimporting. I wonder if that will work for you.

When I created that export I was using SQLite, maybe there is something that is happening here.

@gnaaromat
Copy link

FYI: Also doesnt work with a postgres installation (I am not using the backend - already had strapi installed)

Here is the output from the import:

strapi import -f ../nextjs-corporate-starter/seed-data.tar.gz
? The import will delete your existing data! Are you sure you want to proceed? Yes
[2024-04-11 15:29:15.513] warn: (Schema Integrity) plugin::i18n.locale does not exist on destination
[2024-04-11 15:29:15.514] warn: (Schema Integrity) plugin::users-permissions.permission does not exist on destination
[2024-04-11 15:29:15.515] warn: (Schema Integrity) plugin::users-permissions.role does not exist on destination
[2024-04-11 15:29:15.516] warn: (Schema Integrity) plugin::users-permissions.user does not exist on destination
[2024-04-11 15:29:15.516] warn: (Schema Integrity) api::article.article does not exist on destination
[2024-04-11 15:29:15.517] warn: (Schema Integrity) api::author.author does not exist on destination
[2024-04-11 15:29:15.517] warn: (Schema Integrity) api::category.category does not exist on destination
[2024-04-11 15:29:15.518] warn: (Schema Integrity) api::global.global does not exist on destination
[2024-04-11 15:29:15.518] warn: (Schema Integrity) api::lead-form-submission.lead-form-submission does not exist on destination
[2024-04-11 15:29:15.519] warn: (Schema Integrity) api::page.page does not exist on destination
[2024-04-11 15:29:15.519] warn: (Schema Integrity) api::product-feature.product-feature does not exist on destination
[2024-04-11 15:29:15.520] warn: (Schema Integrity) elements.feature-column does not exist on destination
[2024-04-11 15:29:15.520] warn: (Schema Integrity) elements.feature-row does not exist on destination
[2024-04-11 15:29:15.521] warn: (Schema Integrity) elements.feature does not exist on destination
[2024-04-11 15:29:15.521] warn: (Schema Integrity) elements.footer-section does not exist on destination
[2024-04-11 15:29:15.522] warn: (Schema Integrity) elements.logos does not exist on destination
[2024-04-11 15:29:15.522] warn: (Schema Integrity) elements.notification-banner does not exist on destination
[2024-04-11 15:29:15.523] warn: (Schema Integrity) elements.plan does not exist on destination
[2024-04-11 15:29:15.523] warn: (Schema Integrity) elements.testimonial does not exist on destination
[2024-04-11 15:29:15.524] warn: (Schema Integrity) layout.footer does not exist on destination
[2024-04-11 15:29:15.524] warn: (Schema Integrity) layout.logo does not exist on destination
[2024-04-11 15:29:15.525] warn: (Schema Integrity) layout.navbar does not exist on destination
[2024-04-11 15:29:15.525] warn: (Schema Integrity) links.button-link does not exist on destination
[2024-04-11 15:29:15.525] warn: (Schema Integrity) links.button does not exist on destination
[2024-04-11 15:29:15.525] warn: (Schema Integrity) links.link does not exist on destination
[2024-04-11 15:29:15.526] warn: (Schema Integrity) links.social-link does not exist on destination
[2024-04-11 15:29:15.526] warn: (Schema Integrity) meta.metadata does not exist on destination
[2024-04-11 15:29:15.527] warn: (Schema Integrity) sections.bottom-actions does not exist on destination
[2024-04-11 15:29:15.527] warn: (Schema Integrity) sections.feature-columns-group does not exist on destination
[2024-04-11 15:29:15.527] warn: (Schema Integrity) sections.feature-rows-group does not exist on destination
[2024-04-11 15:29:15.527] warn: (Schema Integrity) sections.features does not exist on destination
[2024-04-11 15:29:15.528] warn: (Schema Integrity) sections.heading does not exist on destination
[2024-04-11 15:29:15.528] warn: (Schema Integrity) sections.hero does not exist on destination
[2024-04-11 15:29:15.528] warn: (Schema Integrity) sections.large-video does not exist on destination
[2024-04-11 15:29:15.528] warn: (Schema Integrity) sections.lead-form does not exist on destination
[2024-04-11 15:29:15.529] warn: (Schema Integrity) sections.pricing does not exist on destination
[2024-04-11 15:29:15.529] warn: (Schema Integrity) sections.rich-text does not exist on destination
[2024-04-11 15:29:15.529] warn: (Schema Integrity) sections.testimonials-group does not exist on destination
[2024-04-11 15:29:15.530] warn: (Schema Integrity) shared.media does not exist on destination
[2024-04-11 15:29:15.530] warn: (Schema Integrity) shared.quote does not exist on destination
[2024-04-11 15:29:15.530] warn: (Schema Integrity) shared.rich-text does not exist on destination
[2024-04-11 15:29:15.530] warn: (Schema Integrity) shared.seo does not exist on destination
[2024-04-11 15:29:15.531] warn: (Schema Integrity) shared.slider does not exist on destination
[2024-04-11 15:29:15.531] warn: (Schema Integrity) shared.video-embed does not exist on destination
? There are differences in schema between the source and destination, and the data listed above will be lost. Are you sure you want to continue? Yes
Starting import...
✔ entities: 21 transfered (size: 19.6 KB) (elapsed: 217 ms)
✔ assets: 70 transfered (size: 23.3 MB) (elapsed: 4722 ms)
✔ links: 0 transfered (size: 0) (elapsed: 0 ms)
✔ configuration: 66 transfered (size: 139.5 KB) (elapsed: 59 ms)
┌────────────────────────┬───────┬───────────────┐
│ Type │ Count │ Size │
├────────────────────────┼───────┼───────────────┤
│ entities │ 21 │ 19.6 KB │
├────────────────────────┼───────┼───────────────┤
│ -- plugin::upload.file │ 21 │ ( 19.6 KB) │
├────────────────────────┼───────┼───────────────┤
│ assets │ 70 │ 23.3 MB │
├────────────────────────┼───────┼───────────────┤
│ -- .ico │ 1 │ ( 15 KB) │
├────────────────────────┼───────┼───────────────┤
│ -- .jpg │ 52 │ ( 23 MB) │
├────────────────────────┼───────┼───────────────┤
│ -- .png │ 13 │ ( 243.6 KB) │
├────────────────────────┼───────┼───────────────┤
│ -- .svg │ 4 │ ( 17.7 KB) │
├────────────────────────┼───────┼───────────────┤
│ configuration │ 66 │ 139.5 KB │
├────────────────────────┼───────┼───────────────┤
│ Total │ 157 │ 23.4 MB │
└────────────────────────┴───────┴───────────────┘

(all I did was create an admin user before running the import)

@PaulBratslavsky
Copy link
Contributor

Just some follow up questions.

  1. You are not using the backend from the Strapi starter correct?
  2. Is your content types and schema identical to what the backend of Strapi starter had?

In order to have smooth sailing with Data Transfer your schema has to match exactly. Hence you are getting this message.

? There are differences in schema between the source and destination, and the data listed above will be lost. Are you sure you want to continue? Yes

What I would recommend as a way to test. Use your currant Strpai instance.

  1. Create new data in the Strapi Admin
  2. Export the newly created data ( this way your current schema will match your exported file )
  3. Try to reimport the data.

This way we can see if it is the DTS that is failing or that the backup from my project is not compatible with yours.

Let, me know how it goes. And thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants