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

Deleting an entity from an existing model #22

Closed
vaind opened this issue Sep 8, 2020 · 1 comment · Fixed by #29
Closed

Deleting an entity from an existing model #22

vaind opened this issue Sep 8, 2020 · 1 comment · Fixed by #29
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@vaind
Copy link
Contributor

vaind commented Sep 8, 2020

When an entity definition is removed (e.g. from a .go file, or the .go file defining an entity is removed altogether), the user might want to delete the entity from the model. Currently, the generator doesn't recognize this situation because it's executed for each individual input file, combining all of them into the same model - therefore it doesn't distinguish between missing entities and the ones that haven't been processed yet.

There are a couple of ways to approach this, the simplest would probably be adding a new CLI argument/action, sth. like --remove=EntityName. Alternatively, we could change the way the generator is launched so that it has the complete list of files to include in the model.

@vaind vaind added the enhancement New feature or request label Sep 8, 2020
@vaind
Copy link
Contributor Author

vaind commented Sep 8, 2020

The current workaround, if someone really really wants to remove the entity from the model, is to manually update the objectbox-model.json, removing the entity JSON code block defining it and adding its uid to the retiredEntityUids list to avoid reuse of the same UID (which would break things). Additionally, the same has to be done for the removed properties, indexes, and relations (each has its retired*Uids list). After the generator is re-run, the entity would be removed from the objectbox-model.go.

I don't recommend doing this as it's easy to make an error when manually editing the model JSON file, potentially causing a loss of data. If you can, wait for the generator to support the removal.

@vaind vaind added this to the 1.0 milestone Dec 11, 2020
@vaind vaind self-assigned this Dec 21, 2020
@vaind vaind mentioned this issue Dec 21, 2020
@vaind vaind closed this as completed in #29 Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant