diff --git a/app/controllers/initialization_data_controller.rb b/app/controllers/initialization_data_controller.rb index 7ed01ad8c..69e6b696b 100644 --- a/app/controllers/initialization_data_controller.rb +++ b/app/controllers/initialization_data_controller.rb @@ -107,22 +107,22 @@ class InitializationDataController < ApplicationController # 链接库 def connect_to_origin_date database - ActiveRecord::Base.establish_connection( - adapter: "mysql2", - host: "rm-bp13v5020p7828r5r.mysql.rds.aliyuncs.com", - username: "testeducoder", - password: "TEST@123", - database: "#{database}", - encoding: "utf8" - ) # ActiveRecord::Base.establish_connection( # adapter: "mysql2", - # host: "127.0.0.1", - # username: "root", - # password: "123456", + # host: "rm-bp13v5020p7828r5r.mysql.rds.aliyuncs.com", + # username: "testeducoder", + # password: "TEST@123", # database: "#{database}", # encoding: "utf8" # ) + ActiveRecord::Base.establish_connection( + adapter: "mysql2", + host: "127.0.0.1", + username: "root", + password: "123456", + database: "#{database}", + encoding: "utf8" + ) end @@ -402,10 +402,10 @@ class InitializationDataController < ApplicationController cloud_url course_second_category_id] Attachment.bulk_insert(*attachment_attrs) do |worker| @attachments.each do |att| - logger.info("########att_id: #{att.id}") base_attr = att.attributes.dup.except("author_id", "disk_directory", "copy_from") # 本地版将过关任务的图片迁移到files/localshixuns 目录下, copy_from记录的是他原来的目录结构 - worker.add(base_attr.merge(author_id: 1, disk_directory: "localshixuns", copy_from: att.disk_directory)) + logger.info("########att.disk_directory: #{att.disk_directory}") + worker.add(base_attr.merge(author_id: 1, disk_directory: "localshixuns", copy_from: "#{att.disk_directory}")) end end end diff --git a/db/migrate/20190927030644_modify_copy_from_for_attachments.rb b/db/migrate/20190927030644_modify_copy_from_for_attachments.rb new file mode 100644 index 000000000..c83faee13 --- /dev/null +++ b/db/migrate/20190927030644_modify_copy_from_for_attachments.rb @@ -0,0 +1,5 @@ +class ModifyCopyFromForAttachments < ActiveRecord::Migration[5.2] + def change + change_column :attachments, :copy_from, :string + end +end