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

Issue with Foreign Keys in SQL Table Creation #1172

Closed
sithu-go opened this issue Jan 16, 2025 · 12 comments
Closed

Issue with Foreign Keys in SQL Table Creation #1172

sithu-go opened this issue Jan 16, 2025 · 12 comments

Comments

@sithu-go
Copy link

sithu-go commented Jan 16, 2025

Please provide titles that are straightforward and concise. exp: [Question] How to use or [Feature] Add new feature

  请提供简单明了的标题。例如 [Question] 如何使用 or [Feature] 添加新功能
Copy link

dosubot bot commented Jan 16, 2025

Hello @sithu-go! I'm here to help you with any bugs, questions, or contributions. Let's work together to solve the issue you're facing.

The issue you're encountering with foreign keys in the user_roles table is likely due to a default SQL audit rule in the Yearning platform. Specifically, the rule DDLEnableForeignKey determines whether foreign keys are allowed in table creation [1].

To resolve this, you should check the configuration settings in Yearning to see if this rule is enabled or if there are any restrictions on using foreign keys. If the rule is disabled, you will need to enable it to allow foreign key constraints in your SQL tables.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@sithu-go
Copy link
Author

@dosu.
There's no DDLEnableForeignKey. I only see DDLEnablePrimaryKey.

image

Copy link

dosubot bot commented Jan 16, 2025

To enable foreign key constraints in the Yearning platform, you should set the DDLEnableForeignKey field to true in the AuditRole struct. This field is specifically designed to allow foreign keys. Here's how it is defined in the code:

type AuditRole struct {
    // ...
    DDLEnableForeignKey bool // 允许外键
    // ...
}

Ensure that this field is set to true in your configuration to enable foreign key constraints [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@sithu-go
Copy link
Author

I'm not a developer from yearning. How to set AuditRole in that struct.

I just use this app.
@dosu

Copy link

dosubot bot commented Jan 16, 2025

Could you provide more details about how you are accessing or using the Yearning platform? For example, are you using a web interface, a specific configuration file, or an API? This information will help me guide you on how to set the AuditRole or adjust the settings you need.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@sithu-go
Copy link
Author

sithu-go commented Jan 16, 2025

You just edited my issue detail. Everything includes in there.

Overwriting user issue's description is not a good idea.
@dosu

sorry to mention you here. I think you should check this bot.
@cookieY

Copy link

dosubot bot commented Jan 16, 2025

This is a tough nut to crack, could really use your help on this, @cookieY.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@sithu-go
Copy link
Author

I'm using

docker
`
image: yeelabs/yearning:latest

`

does this docker version include DDLEnableForeignKey?

@dosu

Copy link

dosubot bot commented Jan 16, 2025

Could you provide more information about the specific version of the Yearning platform you are using with Docker? Additionally, do you have access to any configuration files or environment variables that might allow you to adjust settings related to foreign keys? This information will help determine if the DDLEnableForeignKey option is available in your setup.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@sithu-go
Copy link
Author

@dosu

that is how my docker compose file looks like.

services:
    yearning:
        image: yeelabs/yearning:latest
        environment:
           MYSQL_USER: yearning
           MYSQL_PASSWORD: password
           MYSQL_ADDR: mysql
           MYSQL_DB: yearning
           SECRET_KEY: secretKey
           IS_DOCKER: is_docker
           Y_LANG: en_US
        ports:
           - 8000:8000
        # 首次使用请先初始化
        command: /bin/bash -c "./Yearning install && ./Yearning run"
        depends_on:
           - mysql
        restart: always

    mysql:
        image: mysql:5.7
        environment:
           MYSQL_ROOT_PASSWORD: password
           MYSQL_DATABASE: yearning
           MYSQL_USER: yearning
           MYSQL_PASSWORD: password
        command:
           - --character-set-server=utf8mb4
           - --collation-server=utf8mb4_general_ci
        volumes:
           - ./data/mysql:/var/lib/mysql

In docker hub, yeelabs/yearning is updated 3 months ago.

Isit a problem?

Copy link

dosubot bot commented Jan 16, 2025

The yeelabs/yearning:latest Docker image's codebase does include the DDLEnableForeignKey configuration option, as it is defined in the AuditRole struct within the src/engine/engine.go file of the Yearning codebase [1]. However, the availability of this option in your specific Docker setup depends on whether the image you are using includes this feature and if it is exposed for configuration.

Since you are using the latest tag, it is possible that the image includes recent updates, but without specific documentation or release notes, it's hard to confirm if DDLEnableForeignKey is enabled by default or configurable through environment variables. You might need to check the documentation or configuration files within the Docker container to see if this option is exposed for configuration.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@sithu-go
Copy link
Author

I see the issue why it caused it.
Backend returns global config list. but ui failed to render it.

I make a pull request which fix that issue.
You can find the PR here: #8 pull request

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

No branches or pull requests

1 participant