# Migrate to .sql file

**URL:** <https://www.ruby-forum.com/t/migrate-to-sql-file/113208>\
**Category:** Rails\
**Created:** [August 28, 2007, 8:07pm UTC](https://www.ruby-forum.com/t/migrate-to-sql-file/113208 "2007-08-28T20:07:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmanruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/97f17d/32.png) [@cmanruby](https://www.ruby-forum.com/u/cmanruby)\
**Post date:** [August 28, 2007, 8:07pm UTC](https://www.ruby-forum.com/t/migrate-to-sql-file/113208/1 "2007-08-28T20:07:20Z")

</div>

Would anyone know how to make “rake migrate” or “rake db:schema:load”  
produce an SQL file instead of operating directly on the DB?

The reason that I ask is that my ROR hosting (servage) does not seem  
to allow me to connect to the DB server from the internet or to  
execute rake.

So am I stuck with creating the SQL manually or will rails do it for  
me?

–  
Christian

---

<div class="post-metadata">

**Author:** ![cmanruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/97f17d/32.png) [@cmanruby](https://www.ruby-forum.com/u/cmanruby)\
**Post date:** [August 28, 2007, 8:11pm UTC](https://www.ruby-forum.com/t/migrate-to-sql-file/113208/2 "2007-08-28T20:11:20Z")

</div>

rake db:structure:dump # Dump the database structure to a SQL file

also try ‘rake -T’ for a list of helpful rake tasks

On 8/28/07, Christian M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> me?
> 
> –  
> Christian
> 
> >

–  
David Andrew T.  
[http://dathompson.blogspot.com](http://dathompson.blogspot.com)

---

<div class="post-metadata">

**Author:** ![cmanruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/97f17d/32.png) [@cmanruby](https://www.ruby-forum.com/u/cmanruby)\
**Post date:** [August 28, 2007, 8:40pm UTC](https://www.ruby-forum.com/t/migrate-to-sql-file/113208/3 "2007-08-28T20:40:25Z")

</div>

Thanks David,

But when I look into databases.rake, it appears that it actually uses  
the client for the given DB to make the dump from the DB.

It seems that I forgot to mention that I use postgresql for  
development and my hosting service uses MySQL. So the schema that I  
get from my development DB is unusable on the hosting service.

I guess that I should just use MySQL for development… …Or  
implement “rake db:schema:generate”.

–  
Christian M.

On 28 Aug., 20:10, “David Andrew T.”

---

<div class="post-metadata">

**Author:** ![cmanruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/97f17d/32.png) [@cmanruby](https://www.ruby-forum.com/u/cmanruby)\
**Post date:** [August 28, 2007, 9:31pm UTC](https://www.ruby-forum.com/t/migrate-to-sql-file/113208/4 "2007-08-28T21:31:34Z")

</div>

If you intention is to be able to use MySQL for your production server  
and  
Postgres for your development then you could just set them up in your  
config/database.yml file as such.

If you use ‘rake db:schema:dump RAILS\_ENV=development’ against your  
Postgres/dev database, this will create a rubified schema of your  
database.  
You could then use ‘rake db:schema:load RAILS\_ENV=production’ against  
your  
MySQL/env database. (This is presuming that you have set your  
database.ymlto reflect these configurations.)

btw…this will not give you a true dump of your database (with all of  
the  
data), just the schema.

If the problem is that you do not have shell access to your server and  
so  
cannot call ‘rake’ from the command line there, but have to update the  
database schma through some other web based sql loader, then I would  
recommend just switching your local database to whatever you are using  
for  
your production and save yourself the frustration. Simply solve the  
problem  
and solve the problem simply as they say.

Hope this helps.

On 8/28/07, Christian M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > also try ‘rake -T’ for a list of helpful rake tasks
> > 
> > > The reason that I ask is that my ROR hosting (servage) does not seem  
> > > David Andrew T.[http://dathompson.blogspot.com](http://dathompson.blogspot.com)
> 
> >

–  
David Andrew T.  
[http://dathompson.blogspot.com](http://dathompson.blogspot.com)

---

<div class="post-metadata">

**Author:** ![cmanruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/97f17d/32.png) [@cmanruby](https://www.ruby-forum.com/u/cmanruby)\
**Post date:** [August 28, 2007, 10:00pm UTC](https://www.ruby-forum.com/t/migrate-to-sql-file/113208/5 "2007-08-28T22:00:37Z")

</div>

It did help. I go for “Simply solve the problem and solve the problem  
simply as they say” and install MySQL.

And then I will dream of having the time and skills to implement “rake  
db:schema:generate”.

Thanks.

–  
Christian M.

On 28 Aug., 21:30, “David Andrew T.”
