将数据从SQLite3迁移到Postgresql

时间:2018-03-05 19:59:21

标签: ruby-on-rails ruby postgresql sqlite sequel

我正在开发一个rails应用程序,需要将我的数据从SQLite3迁移到Postgres。我按照这个tutorial

尝试使用续集gem

但是当我运行sequel -C sqlite://db/development.sqlite3 postgres://keemtaker:password@localhost/tuma_development 时,我收到此错误

  

数据库连接成功

     

迁移已成功转移

     

错误:Sequel :: DatabaseError:PG :: DuplicateTable:错误:关系“申请人”已经存在

错误似乎指向架构中的一个表,但不知道如何解决这个问题。这是我的db:schema

    ActiveRecord::Schema.define(version: 20180220173537) do

  # These are extensions that must be enabled in order to support this database
  enable_extension "plpgsql"

  create_table "applicants", force: :cascade do |t|
    t.bigint "job_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.string "full_name"
    t.string "email"
    t.string "mobile_number"
    t.text "cover_letter"
    t.string "resume"
    t.index ["job_id"], name: "index_applicants_on_job_id"
  end

  create_table "companies", force: :cascade do |t|
    t.string "name"
    t.text "description"
    t.string "website"
    t.string "location"
    t.string "address"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.bigint "user_id"
    t.string "photo"
    t.string "logo"
    t.index ["user_id"], name: "index_companies_on_user_id"
  end

  create_table "company_industries", force: :cascade do |t|
    t.bigint "company_id"
    t.bigint "industry_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["company_id"], name: "index_company_industries_on_company_id"
    t.index ["industry_id"], name: "index_company_industries_on_industry_id"
  end

  create_table "company_perks", force: :cascade do |t|
    t.bigint "company_id"
    t.bigint "perk_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["company_id"], name: "index_company_perks_on_company_id"
    t.index ["perk_id"], name: "index_company_perks_on_perk_id"
  end

  create_table "industries", force: :cascade do |t|
    t.string "name"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

  create_table "jobs", force: :cascade do |t|
    t.string "title"
    t.string "role"
    t.text "description"
    t.string "requirements"
    t.string "duties"
    t.bigint "company_id"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.string "job_type"
    t.string "keywords"
    t.string "salary"
    t.string "equity"
    t.text "pitch"
    t.string "email"
    t.string "location"
    t.index ["company_id"], name: "index_jobs_on_company_id"
  end

这是我的database.yml

 development:
  adapter: postgresql
  encoding: unicode
  database: tuma_development
  pool: 5
  timeout: 5000
  username: keemtaker
  password: 'password'

test:
  adapter: postgresql
  encoding: unicode
  database: tuma_test
  pool: 5
  timeout: 5000
  username: keemtaker
  password: 'password'


production:
  adapter: postgresql
  database: tuma_production
  timeout: 5000
  pool: 5

0 个答案:

没有答案