Railsy way to Export Database Schema?

Is there a nice way in rails to automatically extract an exising
database schema from an existing app and then in a new app automatically
create a database based on this schema?

On 8/28/06, Homer S. [email protected] wrote:

Is there a nice way in rails to automatically extract an exising
database schema from an existing app and then in a new app automatically
create a database based on this schema?

Sure:

cd /path/to/myapp
rake db:schema:dump
cp db/schema.rb /path/to/otherapp/db/
cd /path/to/otherapp
rake db:schema:load

jeremy

rake db:schema:dump

This will dump the current schema into a file called schema.rb in your
db
directory.

On 8/28/06, Homer S. [email protected] wrote:


Marlon

On 8/29/06, Homer S. [email protected] wrote:

MySQL and have a table with a full text index on it and the table type
is MyISAM. When I do the dump/load the new table is created as InnoDB
(which doesn’t support full text)

Is this a known issue?

Yes - it’s fixed in MySQL 5.1 maybe? :wink:

Kidding. If you’re moving between two MySQLs, set the schema dump format
to
:sql in config/environment.rb. That’ll give you a ‘native’ schema dump.

jeremy

cd /path/to/myapp
rake db:schema:dump
cp db/schema.rb /path/to/otherapp/db/
cd /path/to/otherapp
rake db:schema:load

This is great (thx) but its not pulling over the table type. I am using
MySQL and have a table with a full text index on it and the table type
is MyISAM. When I do the dump/load the new table is created as InnoDB
(which doesn’t support full text)

Is this a known issue?

On 8/29/06, Brian H. [email protected] wrote:

I know you asked for a “rails” way to do it… but gee… mysqldump is so
easy. :slight_smile:

Too true! Good point, Brian.

jeremy

I know you asked for a “rails” way to do it… but gee… mysqldump is
so
easy. :slight_smile:

http://digg.com/software/Ruby_on_Rails_Database_Backups_and_Exports_Tutorial

Explains backups for mysql, postgresql and sqlite on both linux and
windows.

On 8/29/06, Benjamin G. [email protected] wrote:

http://digg.com/software/Ruby_on_Rails_Database_Backups_and_Exports_Tutorial

Explains backups for mysql, postgresql and sqlite on both linux and
windows.

I can’t tell whether you’re into Rails or driving google ad revenue.

jeremy