我可以转储当前的
Database#schema,但是我想用该模式创建一个新表(在不同的数据库中),但我不知道如何做到这一点?
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!
最佳答案 一种方法可以通过
Migrations完成
>从数据库转储副本: –
sequel -d mysql:// root @ localhost / database1> DB / 001_test.rb
>编辑仅包括所需的表格.
>运行迁移到新数据库: –
sequel -m db / mysql:// root @ localhost / database2