mysql2postgres:基于 Ruby 的 MySQL 到 PostgreSQL 数据迁移工具项目

Mysqldump, writing in postgresql format

分支1Tags0
文件最后提交记录最后更新时间
11 年前
10 年前
6 年前
11 年前
10 年前
6 年前
6 年前
13 年前
6 年前
6 年前
6 年前

mysql-to-postgres - MySQL到PostgreSQL数据转换

构建状态
依赖状态

支持MRI或jruby。在master分支上支持的最低Ruby版本是2.1.7,下个版本也将有相同的要求。

通过稍微修改rails的database.yml配置,你可以将mysql-to-postgres集成到项目中。

安装

目前失败,参见 #81...

通过RubyGems

gem install mysqltopostgres

从源代码安装

git clone https://github.com/maxlapshin/mysql2postgres.git
cd mysql2postgres
bundle install
gem build mysqltopostgres.gemspec
sudo gem install mysqltopostgres-0.3.1.gem

示例配置

配置文件采用YAML格式编写,并作为命令行的第一个参数传递。

default: &default
  adapter: jdbcpostgresql
  encoding: unicode
  pool: 4
  username: terrapotamus
  password: default
  host: 127.0.0.1

development: &development
  <<: *default
  database: default_development

test: &test
  <<: *default
  database: default_test

production: &production
  <<: *default
  database: default_production

mysql_data_source: &pii
  host: localhost
  port: 3306
  socket: /tmp/mysqld.sock
  username: username
  password: default
  database: awesome_possum

mysql2psql:
  mysql:
    <<: *pii

  destination:
    production:
      <<: *production
    test:
      <<: *test
    development:
      <<: *development

  tables:
  - countries
  - samples
  - universes
  - variable_groups
  - variables
  - sample_variables

  # 如果suppress_data为true,只导出/迁移架构定义,不导出数据
  suppress_data: false

  # 如果suppress_ddl为true,只导入/导出数据,不处理架构
  suppress_ddl: true

  # 如果force_truncate为true,在加载表之前强制清空表
  force_truncate: false

  preserve_order: true

  remove_dump_file: true

  dump_file_directory: /tmp

  report_status: json    # false, json, xml

  # 如果clear_schema为true,转换前会重新创建public模式
  # 如果同时设置clear_schema和suppress_ddl,导入会失败。
  clear_schema: false

请注意,如果MySQL的主机未定义(nil)或者其值为'localhost',连接将会使用套接字。

测试

许可证

授权于MIT许可。

项目介绍

Mysqldump, writing in postgresql format

定制我的领域