Reputation: 21381
I can dump the current Database#schema, but I'd like to create a new table (in a different database) with that schema, but I dont see how this can be done?
DB = Sequel.connect('sqlite:///database_from.db')
schema = DB.schema :table
# schema => [[:id, {:auto_increment=>true, :allow_null=>false, :default=>nil, :primary_key=>true, :db_type=>"smallint(5) unsigned", :type=>:integer, :ruby_default=>nil}], [:field, {:allow_null=>true, :default=>nil, :primary_key=>false, :db_type=>"smallint(5) unsigned", :type=>:integer, :ruby_default=>nil}]]
DB2 = Sequel.connect('sqlite:///database_to.db')
DB2.create_table('table name', schema) #< allowing this would be cool!
Upvotes: 4
Views: 1896
Reputation: 21381
One way it can be done via Migrations
Dump the copy from database :-
sequel -d mysql://root@localhost/database1 > db/001_test.rb
Edit to only include the table required.
Run the migration into the new db :-
sequel -m db/ mysql://root@localhost/database2
Upvotes: 2