Contributions 1 min read

# Change type column of object\_relations\_\* tables to enum

Another one of our pull requests is accepted, and this time, our Pimcore team made sure that we can safely keep our database integrity. Find out how they did it.

Last updated on 14 January, 2022

## Key takeaways

1. The type column in Pimcore's object\_relations tables was a varchar(50), so unsupported values could be written directly in the database.
2. Factory's accepted pull request changed the column to an enum limited to object, asset and document, the values Pimcore supports.
3. Restricting the column type protects database integrity and lowers the chance of invalid values in relation records.

## **What was the issue?**

In tables where relations are stored, column ‘type’ that represents the type of the object that is in relation was set to varchar(50). The problem wasn’t severe because pimcore handles the changes in that column but it was possible to change that value directly in the database and put something that is not supported by Pimcore.

## **How did you solve it?**

Type of column ‘type’ is changed from varchar(50) to enum(‘object’, ‘asset’, ‘document’) limiting values in that field to that that Pimcore can work with.

## **Why is this fix important?**

It helps in keeping database integrity and also lowers the chance of having a bad value in that field.

## **Which Pimcore learning materials would you recommend to your colleagues?**

Our [blog posts on Pimcore](https://factory.dev/pimcore-knowledge-base/whitepaper) and [how-to guides](https://factory.dev/pimcore-knowledge-base/how-to) of course. Also, [official Pimcore documentation](https://pimcore.com/docs/pimcore/current/) and their demo project are a great way to start. There is a lot of examples in it and you’ll find out exactly how the platform works.

And if you want to check out this [pull request](https://github.com/pimcore/pimcore/pull/10760), just follow the link!

## Related

[Contributions **Fix for image assets that don’t have set dimensions** Tomislav, our Pimcore developer, has done it again and his new pull request has been accepted. Image assets have been causing some lesser issues, and now the issue… 1 min read](https://factory.dev/pimcore-knowledge-base/contributions/image-assets-fix) [Contributions **Validation errors with subItems without context stack fix** Our Pimcore developer, Tomislav, has solved another issue on the Pimcore platform. Find out why this pull request is important and what use will users have from this… 1 min read](https://factory.dev/pimcore-knowledge-base/contributions/validation-errors-fix) [Contributions **Added async option to headscript fix** Check out one of our Pimcore developers helped add the async option to the headscript, and bringing closer the release of Pimcore X! 1 min read](https://factory.dev/pimcore-knowledge-base/contributions/added-async-option-headscript-fix)

---

Source: https://factory.dev/pimcore-knowledge-base/contributions/change-type-column
