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

[help wanted]: #59

Open
2tof opened this issue Feb 19, 2025 · 1 comment
Open

[help wanted]: #59

2tof opened this issue Feb 19, 2025 · 1 comment
Assignees
Labels
help wanted Extra attention is needed

Comments

@2tof
Copy link

2tof commented Feb 19, 2025

Contact Details

No response

What is your question?

I've tried to add an asset or a login-passport , I got this⬇️. But when I added the 1st asset, it did successfully.
I stopped the other mysql. The only running mysql is oneterm-mysql container.

服务错误: (pymysql.err.IntegrityError) (1452, 'Cannot add or update a child row: a foreign key constraint fails (acl.acl_role_permissions, CONSTRAINT acl_role_permissions_ibfk_1 FOREIGN KEY (rid) REFERENCES acl_roles (id))') [SQL: INSERT INTO acl_role_permissions (deleted_at, deleted, created_at, updated_at, rid, resource_id, group_id, perm_id, app_id) VALUES (%(deleted_at)s, %(deleted)s, %(created_at)s, %(updated_at)s, %(rid)s, %(resource_id)s, %(group_id)s, %(perm_id)s, %(app_id)s)] [parameters: {'deleted_at': None, 'deleted': 0, 'created_at': datetime.datetime(2025, 2, 20, 4, 46, 8, 891969), 'updated_at': None, 'rid': 0, 'resource_id': 36, 'group_id': None, 'perm_id': 8, 'app_id': 4}] (Background on this error at: https://sqlalche.me/e/14/gkpj)

Version

newest

@2tof 2tof added the help wanted Extra attention is needed label Feb 19, 2025
@LaeeqtheDev
Copy link

This error is indicating that when you're trying to insert a record into the acl_role_permissions table, the value for rid (role ID) is set to 0, which doesn’t exist in the acl_roles table. In other words, the foreign key constraint is being violated because you're referencing a role that hasn't been created.

Here are a few steps to resolve the issue:

  1. Verify the Role Exists:

    • Check the acl_roles table to see if there is a record with id = 0. Most systems start IDs at 1, so it's likely that no role with id = 0 exists.
  2. Update the Insert Data:

    • If 0 is not a valid role ID, update your code to use a valid role ID that already exists in acl_roles or create the necessary role entry if that's what’s expected.
  3. Review Your Data Flow:

    • Ensure that the process which assigns or passes the role ID (rid) is functioning as intended. There might be a misconfiguration or a bug that sets rid to 0 inadvertently.
  4. Check Default Values or Migrations:

    • If your application expects a default role, ensure that the default record is properly inserted into the acl_roles table during the setup or migration process.

By following these steps, you should be able to resolve the foreign key constraint error and proceed with adding your asset or login-passport functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants