附件迁移

dev_local_2
daiao 5 years ago
parent 90a6dc3fcd
commit f6bf2e8eb1

@ -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

@ -0,0 +1,5 @@
class ModifyCopyFromForAttachments < ActiveRecord::Migration[5.2]
def change
change_column :attachments, :copy_from, :string
end
end
Loading…
Cancel
Save