What would be really neat is an Entity diagramming tool for Active record! I managed a rake db:schema:dump on a Core data generated sqlite database - the results were interesting! You get stuff like:
It doesn't look as though a clean (and easily scriptable) conversion to rails compatible migrations could be made without a lot of fuss. Interestingly Core Data many to many relationships didn't convert into migrations well, as the two variables didn't seem to have a type.
# Could not dump table "Z_7OWNEDBY" because of following StandardError
# Unknown type '' for column 'Z_7OWNEDPRODUCTS'
(I'm guessing it should be something like CREATE TABLE Z_7OWNEDBY ( Z_7OWNEDPRODUCTS INTEGER, Z_10OWNEDBY INTEGER); )
Initially I tried creating a mysql compatible schema by hand editing the sqlite dump and piping the schema into a mysql db, which worked, but oddly my rails installation (on Leopard) doesn't want to talk to mysql.
At any rate I had dreams for automating the procedure (so as to use the XCode diagramming tool to create my Rails back end schema migration descriptions) but at best I think all I can gain is a hint towards how I should (hand) write my migrations. Was worth a try!
Email me if you have tried this out before or have any clues!
by Mathieu Tozer — Jul 17
ActiveRecord::Schema.define() do
create_table "ZATTRIBUTE", :id => false, :force => true do |t|
t.column "Z_ENT", :integer
t.column "Z_PK", :integer
t.column "Z_OPT", :integer
t.column "ZPRODUCT", :integer
t.column "ZCREATORUSER", :integer
t.column "ZDATECREATED", :timestamp
t.column "ZATTRIBVALUE", :string, :limit => nil
t.column "ZNAME", :string, :limit => nil
end
...
It doesn't look as though a clean (and easily scriptable) conversion to rails compatible migrations could be made without a lot of fuss. Interestingly Core Data many to many relationships didn't convert into migrations well, as the two variables didn't seem to have a type.
sqlite .dump gives
CREATE TABLE Z_7OWNEDBY ( Z_7OWNEDPRODUCTS, Z_10OWNEDBY);
# Could not dump table "Z_7OWNEDBY" because of following StandardError
# Unknown type '' for column 'Z_7OWNEDPRODUCTS'
(I'm guessing it should be something like CREATE TABLE Z_7OWNEDBY ( Z_7OWNEDPRODUCTS INTEGER, Z_10OWNEDBY INTEGER); )
Initially I tried creating a mysql compatible schema by hand editing the sqlite dump and piping the schema into a mysql db, which worked, but oddly my rails installation (on Leopard) doesn't want to talk to mysql.
At any rate I had dreams for automating the procedure (so as to use the XCode diagramming tool to create my Rails back end schema migration descriptions) but at best I think all I can gain is a hint towards how I should (hand) write my migrations. Was worth a try!
Email me if you have tried this out before or have any clues!