# Migrations from Mysql to Oracle. PLS HELP!

**URL:** <https://www.ruby-forum.com/t/migrations-from-mysql-to-oracle-pls-help/96955>\
**Category:** Rails\
**Created:** [July 3, 2006, 7:20pm UTC](https://www.ruby-forum.com/t/migrations-from-mysql-to-oracle-pls-help/96955 "2006-07-03T19:20:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheSAllnighter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f19dbf/32.png) [@TheSAllnighter](https://www.ruby-forum.com/u/TheSAllnighter)\
**Post date:** [July 3, 2006, 7:20pm UTC](https://www.ruby-forum.com/t/migrations-from-mysql-to-oracle-pls-help/96955/1 "2006-07-03T19:20:43Z")

</div>

Hi all,  
I’m using Rails/Mysql as development platform. the production server is  
under Rails/Oracle.  
Right now, i’m trying to install my application under the production  
server, the connection to orcale is fine via Rails, but i have a weird  
problem. example :  
here is a extract from my db scheme :

Table User :\_\_\_\_\_\_\_\_\_\_\_\_\_  
id\_user |  
first\_name |  
last\_name |  
login |  
password |  
id\_profile |  
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_|

Table Profile :\_\_\_\_\_\_\_\_\_\_  
id\_profile |  
name |  
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_|

and my Models :  
class Profile \< ActiveRecord::Base  
set\_table\_name “PROFILE”  
set\_primary\_key “ID\_PROFILE”  
has\_many :user  
end

class User \< ActiveRecord::Base  
set\_table\_name “user”  
set\_primary\_key “ID\_USER”  
belongs\_to :profil,  
:foreign\_key =\> “ID\_PROFILE”  
end

with the rails console, I try the following command :

> > x = User.find(1)  
> > =\> #\<User:0x454cf8b4 @attributes={“id\_profile”=\>1, “first\_name”=\>“Nom”,  
> > “last\_name”=\>“Prenom”, “password”=\>“test”, “login”=\>“login”,  
> > “id\_user”=\>1}\>

That’s fine. but when iwant to get the user profile :

> > x.profile  
> > =\> nil
> 
> > x.profile.name  
> > NoMethodError: You have a nil object when you didn’t expect it!  
> > The error occured while evaluating nil.name  
> > from (irb):12

knowing that i did not have any problems with Mysql, what could be the  
problem with Oracle ?  
Could you help me please ? thanks

---

<div class="post-metadata">

**Author:** ![TheSAllnighter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f19dbf/32.png) [@TheSAllnighter](https://www.ruby-forum.com/u/TheSAllnighter)\
**Post date:** [July 3, 2006, 10:40pm UTC](https://www.ruby-forum.com/t/migrations-from-mysql-to-oracle-pls-help/96955/2 "2006-07-03T22:40:38Z")

</div>

Look out for oracle reserved words,

My first bet is PROFILE

---

<div class="post-metadata">

**Author:** ![TheSAllnighter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f19dbf/32.png) [@TheSAllnighter](https://www.ruby-forum.com/u/TheSAllnighter)\
**Post date:** [July 4, 2006, 12:53am UTC](https://www.ruby-forum.com/t/migrations-from-mysql-to-oracle-pls-help/96955/3 "2006-07-04T00:53:46Z")

</div>

Leon L. wrote:

> Look out for oracle reserved words,
> 
> My first bet is PROFILE

Thank you for your reply.  
i have the same problem with the other tables of the database (example:  
region, ville, commune) and i don’t think they are reserved word.  
it seems that all the relationships doesn’t work in active record once  
i’ve switched to oracle.

---

<div class="post-metadata">

**Author:** ![TheSAllnighter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f19dbf/32.png) [@TheSAllnighter](https://www.ruby-forum.com/u/TheSAllnighter)\
**Post date:** [July 4, 2006, 1:07am UTC](https://www.ruby-forum.com/t/migrations-from-mysql-to-oracle-pls-help/96955/4 "2006-07-04T01:07:36Z")

</div>

On Tue, 2006-07-04 at 00:53 +0200, The A. wrote:

> Leon L. wrote:
> 
> > Look out for oracle reserved words,
> > 
> > My first bet is PROFILE
> 
> Thank you for your reply.  
> i have the same problem with the other tables of the database (example:  
> region, ville, commune) and i don’t think they are reserved word.  
> it seems that all the relationships doesn’t work in active record once  
> i’ve switched to oracle.

* * *

my thinking was if the column name is id\_profile, then the foreign key  
should be ‘id\_profile’ not ‘ID\_PROFILE’ - I don’t think that there is  
any forgiveness in the case of these objects…the same is true of table  
names, etc.

Craig

---

<div class="post-metadata">

**Author:** ![TheSAllnighter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f19dbf/32.png) [@TheSAllnighter](https://www.ruby-forum.com/u/TheSAllnighter)\
**Post date:** [July 4, 2006, 1:20am UTC](https://www.ruby-forum.com/t/migrations-from-mysql-to-oracle-pls-help/96955/5 "2006-07-04T01:20:16Z")

</div>

> my thinking was if the column name is id\_profile, then the foreign key  
> should be ‘id\_profile’ not ‘ID\_PROFILE’ - I don’t think that there is  
> any forgiveness in the case of these objects…the same is true of table  
> names, etc.
> 
> Craig

The problem is that the production database is a legacy database and  
other applications are working with it. I had to use some workaround to  
“shortcut” rails conventions ☹

---

<div class="post-metadata">

**Author:** ![TheSAllnighter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f19dbf/32.png) [@TheSAllnighter](https://www.ruby-forum.com/u/TheSAllnighter)\
**Post date:** [July 4, 2006, 1:38am UTC](https://www.ruby-forum.com/t/migrations-from-mysql-to-oracle-pls-help/96955/6 "2006-07-04T01:38:32Z")

</div>

On Tue, 2006-07-04 at 01:20 +0200, The A. wrote:

> > my thinking was if the column name is id\_profile, then the foreign key  
> > should be ‘id\_profile’ not ‘ID\_PROFILE’ - I don’t think that there is  
> > any forgiveness in the case of these objects…the same is true of table  
> > names, etc.
> > 
> > Craig
> 
> The problem is that the production database is a legacy database and  
> other applications are working with it. I had to use some workaround to  
> “shortcut” rails conventions ☹

* * *

try doing a rake schema\_dump and see what rails calls the tables &  
columns

Craig

---

<div class="post-metadata">

**Author:** ![TheSAllnighter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f19dbf/32.png) [@TheSAllnighter](https://www.ruby-forum.com/u/TheSAllnighter)\
**Post date:** [July 4, 2006, 2:18am UTC](https://www.ruby-forum.com/t/migrations-from-mysql-to-oracle-pls-help/96955/7 "2006-07-04T02:18:59Z")

</div>

On Tue, 2006-07-04 at 02:08 +0200, The A. wrote:

> > try doing a rake schema\_dump and see what rails calls the tables &  
> > columns  
> > i have this error message :  
> > rake aborted!  
> > Don’t know how to build task ‘schema\_dump’  
> > did i missed something ?

* * *

rake --tasks

rake db:schema:dump

Craig

---

<div class="post-metadata">

**Author:** ![TheSAllnighter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f19dbf/32.png) [@TheSAllnighter](https://www.ruby-forum.com/u/TheSAllnighter)\
**Post date:** [July 4, 2006, 2:08am UTC](https://www.ruby-forum.com/t/migrations-from-mysql-to-oracle-pls-help/96955/8 "2006-07-04T02:08:13Z")

</div>

> try doing a rake schema\_dump and see what rails calls the tables &  
> columns  
> i have this error message :  
> rake aborted!  
> Don’t know how to build task ‘schema\_dump’  
> did i missed something ?

---

<div class="post-metadata">

**Author:** ![TheSAllnighter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f19dbf/32.png) [@TheSAllnighter](https://www.ruby-forum.com/u/TheSAllnighter)\
**Post date:** [July 4, 2006, 2:39am UTC](https://www.ruby-forum.com/t/migrations-from-mysql-to-oracle-pls-help/96955/9 "2006-07-04T02:39:54Z")

</div>

> rake --tasks
> 
> rake db:schema:dump
> 
> Craig

this is the result of the command :

# Could not dump table “region” because of following

ActiveRecord::StatementInvalid

# OCIError: ORA-00918: column ambiguously defined: SELECT

lower(i.index\_name) as index\_name, i.uniqueness, lowe  
r(c.column\_name) as column\_name  
FROM user\_indexes i, user\_ind\_columns c  
WHERE i.table\_name = ‘REGION’  
AND c.index\_name = i.index\_name  
AND i.index\_name NOT IN (SELECT index\_name FROM  
user\_constraints WHERE constraint\_type = ‘P’)  
ORDER BY i.index\_name, c.column\_position

I have the same error message in the db/schema.rb file for all the  
database tables (OCIError: ORA-00918: column ambiguously defined).

---

<div class="post-metadata">

**Author:** ![TheSAllnighter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f19dbf/32.png) [@TheSAllnighter](https://www.ruby-forum.com/u/TheSAllnighter)\
**Post date:** [July 4, 2006, 7:45pm UTC](https://www.ruby-forum.com/t/migrations-from-mysql-to-oracle-pls-help/96955/10 "2006-07-04T19:45:13Z")

</div>

Craig W. wrote:

> On Tue, 2006-07-04 at 00:53 +0200, The A. wrote:
> 
> > Leon L. wrote:
> > 
> > > Look out for oracle reserved words,
> > > 
> > > My first bet is PROFILE
> > 
> > Thank you for your reply.  
> > i have the same problem with the other tables of the database (example:  
> > region, ville, commune) and i don’t think they are reserved word.  
> > it seems that all the relationships doesn’t work in active record once  
> > i’ve switched to oracle.
> 
> * * *
> 
> my thinking was if the column name is id\_profile, then the foreign key  
> should be ‘id\_profile’ not ‘ID\_PROFILE’ - I don’t think that there is  
> any forgiveness in the case of these objects…the same is true of table  
> names, etc.
> 
> Craig

That’s it ! I’ve changed :foreign\_key =\> “ID\_PROFILE” by :foreign\_key =\>  
“id\_profile” and it works.  
Thanks a lot 🙂
