# When I do a migration, the changes are make in the test db

**URL:** <https://www.ruby-forum.com/t/when-i-do-a-migration-the-changes-are-make-in-the-test-db/188802>\
**Category:** Rails\
**Created:** [May 18, 2010, 6:35pm UTC](https://www.ruby-forum.com/t/when-i-do-a-migration-the-changes-are-make-in-the-test-db/188802 "2010-05-18T18:35:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jorgegetafe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eada6e/32.png) [@jorgegetafe](https://www.ruby-forum.com/u/jorgegetafe)\
**Post date:** [May 18, 2010, 6:35pm UTC](https://www.ruby-forum.com/t/when-i-do-a-migration-the-changes-are-make-in-the-test-db/188802/1 "2010-05-18T18:35:14Z")

</div>

When I do a migration, the changes are make in the test database. Does  
anyone know the reason?

In the config/environment.rb file, I have this: ENV[‘RAILS\_ENV’] ||=  
‘production’

And in the db/ folder, it creates a file named test.sqlite3

When I did the migrations, RoR used the test database, but when I want  
to make something in the application, the migrations donÂ´t appear  
because the app is using the production database.

Please, help me.

---

<div class="post-metadata">

**Author:** ![jorgegetafe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eada6e/32.png) [@jorgegetafe](https://www.ruby-forum.com/u/jorgegetafe)\
**Post date:** [May 18, 2010, 7:10pm UTC](https://www.ruby-forum.com/t/when-i-do-a-migration-the-changes-are-make-in-the-test-db/188802/2 "2010-05-18T19:10:46Z")

</div>

On May 18, 5:35 pm, Jorge alejandro Mendoza torres \<li…@ruby-  
[forum.com](http://forum.com)\> wrote:

> because the app is using the production database.

Is the environment variable RAILS\_ENV set ?

Fred

---

<div class="post-metadata">

**Author:** ![jorgegetafe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eada6e/32.png) [@jorgegetafe](https://www.ruby-forum.com/u/jorgegetafe)\
**Post date:** [May 18, 2010, 10:50pm UTC](https://www.ruby-forum.com/t/when-i-do-a-migration-the-changes-are-make-in-the-test-db/188802/3 "2010-05-18T22:50:57Z")

</div>

Have you tried using:

rake db:migrate RAILS\_ENV=production

-c

On May 18, 12:35 pm, Jorge alejandro Mendoza torres \<li…@ruby-

---

<div class="post-metadata">

**Author:** ![jorgegetafe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eada6e/32.png) [@jorgegetafe](https://www.ruby-forum.com/u/jorgegetafe)\
**Post date:** [May 19, 2010, 6:36pm UTC](https://www.ruby-forum.com/t/when-i-do-a-migration-the-changes-are-make-in-the-test-db/188802/4 "2010-05-19T18:36:26Z")

</div>

On 19 May 2010 16:09, Jorge alejandro Mendoza torres  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> production database.
> 
> But I have another problem, I had a record and I inserted others three  
> records to my table, if I make a search and I want to find one of three  
> new records, I can’t find it, for instance:
> 
> var = Table.find(:first, :conditions =\> [“id\_oficina = ?”,  
> clave[i].to\_i])
> 
> In my table, all records exist.

You would really have been be better to start a new thread for this.  
Now the subject does not relate to your problem.  
Have a look in the log file (development.log if you are in development  
mode), it will show the sql being used. Does it look right?

How do you know it is not finding the record?

Colin

---

<div class="post-metadata">

**Author:** ![jorgegetafe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/eada6e/32.png) [@jorgegetafe](https://www.ruby-forum.com/u/jorgegetafe)\
**Post date:** [May 19, 2010, 5:09pm UTC](https://www.ruby-forum.com/t/when-i-do-a-migration-the-changes-are-make-in-the-test-db/188802/5 "2010-05-19T17:09:10Z")

</div>

daphonz wrote:

> Have you tried using:
> 
> rake db:migrate RAILS\_ENV=production
> 
> -c
> 
> On May 18, 12:35ï¿½pm, Jorge alejandro Mendoza torres \<li…@ruby-

I already tried the instruction and the migrations were made in the  
production database.

But I have another problem, I had a record and I inserted others three  
records to my table, if I make a search and I want to find one of three  
new records, I can’t find it, for instance:

var = Table.find(:first, :conditions =\> [“id\_oficina = ?”,  
clave[i].to\_i])

In my table, all records exist.
