# Problems using Rom with a legacy database

**URL:** <https://discourse.rom-rb.org/t/problems-using-rom-with-a-legacy-database/573>\
**Category:** Issues\
**Created:** [December 14, 2022, 8:54am UTC](https://discourse.rom-rb.org/t/problems-using-rom-with-a-legacy-database/573 "2022-12-14T08:54:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![choallin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/choallin/32/277_2.png) [@choallin](https://discourse.rom-rb.org/u/choallin)\
**Post date:** [December 14, 2022, 8:54am UTC](https://discourse.rom-rb.org/t/problems-using-rom-with-a-legacy-database/573/1 "2022-12-14T08:54:09Z")

</div>

I have a new Hanami 2 application and have configured Rom according to the “Getting Started” guidelines. I have access to my (legacy) database now, so this is working.

Now, I want to change a few things in my schema so that it is easier to work with it. Some columns in the database are in uppercase and I want to access them in lowercase. I tried to “fix” this with a custom entity and overwriting the `method_missing` method but this feels a little bit clunky. Is there a way I can configure the schema to automatically lower case the column names?

---

<div class="post-metadata">

**Author:** ![alassek](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/alassek/32/260_2.png) [@alassek](https://discourse.rom-rb.org/u/alassek)\
**Post date:** [December 14, 2022, 9:26pm UTC](https://discourse.rom-rb.org/t/problems-using-rom-with-a-legacy-database/573/2 "2022-12-14T21:26:57Z")

</div>

Have you looked into using a [custom mapper](https://rom-rb.org/learn/core/5.2/mappers/) for this?

---

<div class="post-metadata">

**Author:** ![solnic](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/solnic/32/279_2.png) [@solnic](https://discourse.rom-rb.org/u/solnic)\
**Post date:** [December 15, 2022, 7:11am UTC](https://discourse.rom-rb.org/t/problems-using-rom-with-a-legacy-database/573/3 "2022-12-15T07:11:38Z")

</div>

You can override default dataset via `dataset do ... end` in relation classes and do project there. This will work for reading. Then for writing you can use changesets to upcase. Currently there’s no way to have automatic bi-directional mapping because it’s a very rare requirement and nobody had the time to implement it.

---

<div class="post-metadata">

**Author:** ![wuarmin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.rom-rb.org/wuarmin/32/233_2.png) [@wuarmin](https://discourse.rom-rb.org/u/wuarmin)\
**Post date:** [August 3, 2023, 9:28am UTC](https://discourse.rom-rb.org/t/problems-using-rom-with-a-legacy-database/573/4 "2023-08-03T09:28:48Z")

</div>

Why not using [identifier\_mangling.rb](https://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/identifier_mangling_rb.html)?

```ruby
rom_config.gateways[:default].connection.extension :identifier_mangling
rom_config.gateways[:default].connection.identifier_output_method = :downcase

```
