# Force the id value

**URL:** <https://www.ruby-forum.com/t/force-the-id-value/118641>\
**Category:** Rails\
**Created:** [October 29, 2007, 6:22pm UTC](https://www.ruby-forum.com/t/force-the-id-value/118641 "2007-10-29T18:22:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabriele](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/76d3ee/32.png) [@gabriele](https://www.ruby-forum.com/u/gabriele)\
**Post date:** [October 29, 2007, 6:22pm UTC](https://www.ruby-forum.com/t/force-the-id-value/118641/1 "2007-10-29T18:22:32Z")

</div>

Hallo,  
I’m trying to migrate a lot of values from a database (MS Access mdb  
via odbc) to another mysql database (from which I’ll start to build a  
RoR based application), using the ruby-odbc library I can access the  
datas in the mdb file, I would like that some important things, like  
the ids in the tables, will be the same in the two databases (all the  
foreign keys are already set in the mdb, so why do I have to compute  
them again?), table structure will be a bit different, the mysql based  
one will be more refined than the old software one, but most of the  
structure could be inherited from the mdb one.  
Thus I’m looking for a way not to waste all the informations that are  
already present, a.k.a. the joins already in place (without having to  
use two ids, the rails one and another field for the referenced one,  
this looks clumsy to me…).

Thank for the answer

---

<div class="post-metadata">

**Author:** ![gabriele](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/76d3ee/32.png) [@gabriele](https://www.ruby-forum.com/u/gabriele)\
**Post date:** [October 30, 2007, 6:45pm UTC](https://www.ruby-forum.com/t/force-the-id-value/118641/2 "2007-10-30T18:45:55Z")

</div>

Really none has had this problem?

---

<div class="post-metadata">

**Author:** ![gabriele](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/76d3ee/32.png) [@gabriele](https://www.ruby-forum.com/u/gabriele)\
**Post date:** [October 30, 2007, 7:18pm UTC](https://www.ruby-forum.com/t/force-the-id-value/118641/3 "2007-10-30T19:18:05Z")

</div>

Il giorno mar, 30/10/2007 alle 10.45 -0700, Gabriele T. ha scritto:

> Really none has had this problem?

Probable solution, but it don’t look like so clean, is to use the  
execute:

SomeModel.connection.execute(“UPDATE tablename SET id=‘3’ WHERE id=‘5’”)

Updating works, now I try with an insert…

Bye

---

<div class="post-metadata">

**Author:** ![gabriele](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/76d3ee/32.png) [@gabriele](https://www.ruby-forum.com/u/gabriele)\
**Post date:** [October 30, 2007, 7:38pm UTC](https://www.ruby-forum.com/t/force-the-id-value/118641/4 "2007-10-30T19:38:02Z")

</div>

Sorry for the “look like” in the previous post… O\_O

However the execute("INSERT… works as expected… this is probably  
the only way.
