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

Document how to update ClassName references if changing the name of a DataObject class #299

Open
sunnysideup opened this issue Jul 5, 2023 · 2 comments

Comments

@sunnysideup
Copy link
Contributor

sunnysideup commented Jul 5, 2023

Affected Version

All versions

Description

When a DataObject ClassName is changed the SS project may not work anymore as there may be unexpected references to the classname in the database tables.

Unexpected as: not the main ClassName field in the table relating to the class itself, but references in other tables (including Foo_Versions).

Proposed solution

Use the concepts from this module: https://github.com/sunnysideup/silverstripe-search-all-tables-and-fields and keep a log of changes made.

Question

This may already be covered by:

---
Name: project
---
SilverStripe\ORM\DatabaseAdmin:
  classname_value_remapping:
    Building: 'Project\Web\Models\Building'
    City: 'Project\Web\Models\City'

Although I am not sure if it would fix all mentions.

@sunnysideup sunnysideup changed the title set up system to allow clean changes of classnames set up system to allow clean changes of DataObject ClassNames Jul 5, 2023
@michalkleiner
Copy link
Contributor

I believe the DatabaseAdmin::classname_value_remapping config already provides this for ORM-created db columns. Anywhere else it's project-level code.

@GuySartorelli
Copy link
Member

Yeah this functionality definitely already exists. I'd say it should be documented though, I couldn't find anything in the docs when I looked briefly just now.
I'll move this to the developer-docs repo.

@GuySartorelli GuySartorelli transferred this issue from silverstripe/silverstripe-framework Jul 7, 2023
@GuySartorelli GuySartorelli changed the title set up system to allow clean changes of DataObject ClassNames Document how to update ClassName references if changing the name of a DataObject class Jul 7, 2023
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

3 participants