我想将生成的Sequel迁移的SQL语句输出到文件,而不必连接到实际的数据库。 我需要这个,因为我想以MySQL的形式导出语句,但我通常使用PostgreSQL。
在创建数据库时,我可以尝试使用-E
选项设置MySQL并输出,但这不是事情应该如何正常工作?
我需要的是:
sequel -m db/migrations/ -E --type mysql > msysql_statements.sql
我将Sequel与migrations一起使用。
有没有办法实现这个目标?
我尝试了 Jeremy Evans 的回答:
sequel -m db/migrations/ -t -E mock://mysql
错误在输出之后:
I, [2016-07-18T13:57:09.020630 #21573] INFO -- : SELECT NULL AS `nil` FROM `schema_migrations` LIMIT 1
I, [2016-07-18T13:57:09.020802 #21573] INFO -- : SELECT * FROM `schema_migrations` LIMIT 1
/home/me/.rvm/gems/ruby-2.2.1/gems/sequel-4.34.0/lib/sequel/extensions/migration.rb:751:in `schema_dataset': Migrator table schema_migrations does not contain column filename (Sequel::Migrator::Error)
from /home/me/.rvm/gems/ruby-2.2.1/gems/sequel-4.34.0/lib/sequel/extensions/migration.rb:450:in `initialize'
from /home/me/.rvm/gems/ruby-2.2.1/gems/sequel-4.34.0/lib/sequel/extensions/migration.rb:652:in `initialize'
from /home/me/.rvm/gems/ruby-2.2.1/gems/sequel-4.34.0/lib/sequel/extensions/migration.rb:397:in `new'
from /home/me/.rvm/gems/ruby-2.2.1/gems/sequel-4.34.0/lib/sequel/extensions/migration.rb:397:in `run'
from /home/me/.rvm/gems/ruby-2.2.1/gems/sequel-4.34.0/lib/sequel/extensions/migration.rb:368:in `apply'
from /home/me/.rvm/gems/ruby-2.2.1/gems/sequel-4.34.0/bin/sequel:160:in `<top (required)>'
from /home/me/.rvm/gems/ruby-2.2.1/bin/sequel:23:in `load'
from /home/me/.rvm/gems/ruby-2.2.1/bin/sequel:23:in `<main>'
from /home/me/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
from /home/me/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
不幸的是,它似乎试图从模拟数据库中访问某些内容。
根据Jeremy的回答,我有一些可以使用的东西,我提出了以下hacky解决方法,它至少产生了大部分陈述,但不是全部:(:
sequel -m db/migrations/ -t -E mock://mysql > mysql-statements.sql
答案 0 :(得分:2)
sequel -m db/migrations/ -E mock://mysql > msysql_statements.sql
答案 1 :(得分:0)
Nulldb https://github.com/nulldb/nulldb将是完美的。
答案 2 :(得分:0)