feat: store created_by and updated_by for apps, modelconfigs, and sites #7613
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
Important
Please review the checklist below before submitting your pull request.
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint godsDescription
This PR adds
created_by
andupdated_by
fields toApp
,AppModelConfig
, andSite
models to store account id who created or updated the apps, model configs, or sites.Fixes #7593
Changes:
created_by
andupdated_by
are added toApp
,AppModelConfig
, andSite
modelsWorkflow
model is not changed since it already has*_by
filedsApp
,AppModelConfig
, orSite
, bothcreated_by
andupdated_by
are filled with the account id who created the objectApp
orSite
,updated_by
for each models are updated with the account id who modified the objectAppModelConfig
is always replaced with new object upon update,updated_by
doesn't hold much meaning. This means thatupdated_by
and exisingupdated_at
forAppModelConfig
always equal tocreated_by
andcreated_at
. Still, I preparedupdated_by
because there was alreadyupdated_at
. I think it might be a good idea forAppModelConfig
to only havecreated_*
(removingupdated_*
). Please let me know if any modifications are needed*_by
fields to respond these fields through API.Type of Change
Testing Instructions
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Start new instance of Dify 0.7.1
Invite User-A and User-B as Editor, activate them, then gather ids for these users
Logged in as User-A and create App-A and publish it
Logged in as User-A and create Workflow-A and connect End block, then publish it
Ensure App-A and Workflow-A has no
created_by
norupdated_by
fieldsBuild custom dify-api image with this PR
Upgrade the instance to the new image
Ensure the migrations are happened
Logged in as User-B and create App-B and Workflow-B
Ensure that all apps has additional fields, App-A and Workflow-A have empty created_by and updated_by, App-B and Workflow-B have valid created_by and updated_by for User-B
Make any changes on any apps by any users
Ensure appropreate fields are updated
Ensure per-apps endpoints return additional metadata