2019年4月2日カテゴリー:

EC-CUBE3データ移行:会員データ・管理者データ(MySQL)

 

 

EC-CUBE3→EC-CUBE3機能カスタマイズ版

機能カスタマイズ版はインストールと同時に機能が実装されます。
詳しくは↓こちらをご覧ください。
EC-CUBE3機能カスタマイズ版 
EC-CUBE4機能カスタマイズ版

※ ログイン暗号情報を移行するため、管理者のデータも移行する。

Ⅰ 移行元の操作

各テーブルのsqlをダウンロード(エクスポート)します。
—————————————-
① dtb_customer
② dtb_customer_address
③ dtb_customer_favorite_product
④ dtb_mail_history
⑤ dtb_member
—————————————-

Ⅱ 移行先の操作

1 dtb_customer

外部キー制約あり。

dtb_order
① Constraint properties→「FK_1D66D8079395C3F3」
② カラム→「customer_id」

dtb_customer_address
① Constraint properties→「FK_6C38C0F89395C3F3」
② カラム→「customer_id」

dtb_customer_favorite_product
① Constraint properties→「FK_ED6313839395C3F3」
② カラム→「customer_id」

(1)下記SQLを実行して外部キーを削除する。

[php]
ALTER TABLE dtb_order DROP FOREIGN KEY FK_1D66D8079395C3F3;
ALTER TABLE dtb_customer_address DROP FOREIGN KEY FK_6C38C0F89395C3F3;
ALTER TABLE dtb_customer_favorite_product DROP FOREIGN KEY FK_ED6313839395C3F3;
[/php]

(2)dtb_customerテーブルを空にする。

(3)sqlをインポートする。アップロードファイル→参照、「実行」をクリック。

(4)下記SQLを実行して参照元テーブルに外部キーを復元する。

[php]
DELETE FROM dtb_order WHERE customer_id NOT IN( SELECT customer_id FROM dtb_customer );
DELETE FROM dtb_customer_address WHERE customer_id NOT IN( SELECT customer_id FROM dtb_customer );
DELETE FROM dtb_customer_favorite_product WHERE customer_id NOT IN( SELECT customer_id FROM dtb_customer );

ALTER TABLE dtb_order ADD CONSTRAINT FK_1D66D8079395C3F3 FOREIGN KEY (customer_id) REFERENCES dtb_customer (customer_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_customer_address ADD CONSTRAINT FK_6C38C0F89395C3F3 FOREIGN KEY (customer_id) REFERENCES dtb_customer (customer_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_customer_favorite_product ADD CONSTRAINT FK_ED6313839395C3F3 FOREIGN KEY (customer_id) REFERENCES dtb_customer (customer_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
[/php]

2 dtb_customer_address

外部キー制約なし

(1)空にする。

(2)sqlインポート

3 dtb_customer_favorite_product

外部キー制約なし

(1)空にする。

(2)sqlインポート

4 dtb_mail_history

dtb_mail_history自身に設定されている外部キー制約を削除する。

dtb_order
・Constraint properties→「FK_4870AB118D9F6D38」
・カラム→「order_id」

(1)下記SQLを実行して外部キーを削除する。

[php]
ALTER TABLE dtb_mail_history DROP FOREIGN KEY FK_4870AB118D9F6D38;
[/php]

(2)dtb_mail_historyテーブルを空にする。

(3)sqlをインポートする。アップロードファイル→参照、「実行」をクリック。

(4)下記SQLを実行して自身のテーブルに外部キーを復元する。

[php]
DELETE FROM dtb_mail_history WHERE order_id NOT IN( SELECT order_id FROM dtb_order );

ALTER TABLE dtb_mail_history ADD CONSTRAINT FK_4870AB118D9F6D38 FOREIGN KEY (order_id) REFERENCES dtb_order (order_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
[/php]

5 dtb_member

外部キー制約あり。

dtb_faq
① Constraint properties→「FK_15046F5861220EA6」
② カラム→「creator_id」

dtb_class_name
① Constraint properties→「FK_187C95AD61220EA6」
② カラム→「creator_id」

dtb_product_class
① Constraint properties→「FK_1A11D1BA61220EA6」
② カラム→「creator_id」

dtb_mail_template
① Constraint properties→「FK_1CB16DB261220EA6」
② カラム→「creator_id」

dtb_ticker
① Constraint properties→「FK_1E9BC90861220EA6」
② カラム→「creator_id」

dtb_product_image
① Constraint properties→「FK_3267CC7A61220EA6」
② カラム→「creator_id」

dtb_delivery
① Constraint properties→「FK_3420D9FA61220EA6」
② カラム→「creator_id」

dtb_topimage
① Constraint properties→「FK_3B5AB76661220EA6」
② カラム→「creator_id」

dtb_lp
① Constraint properties→「FK_4177A97261220EA6」
② カラム→「creator_id」

dtb_product_tag
① Constraint properties→「FK_4433E72161220EA6」
② カラム→「creator_id」

dtb_mail_history
① Constraint properties→「FK_4870AB1161220EA6」
② カラム→「creator_id」

dtb_authority_role
① Constraint properties→「FK_4A1F70B161220EA6」
② カラム→「creator_id」

dtb_category
① Constraint properties→「FK_5ED2C2B61220EA6」
② カラム→「creator_id」

dtb_payment
① Constraint properties→「FK_7AFF628F61220EA6」
② カラム→「creator_id」

dtb_class_category
① Constraint properties→「FK_9B0D1DBA61220EA6」
② カラム→「creator_id」

dtb_product_stock
① Constraint properties→「FK_BC6C9E4561220EA6」
② カラム→「creator_id」

dtb_product
① Constraint properties→「FK_C49DE22F61220EA6」
② カラム→「creator_id」

dtb_news
① Constraint properties→「FK_EA4C351761220EA6」
② カラム→「creator_id」

dtb_csv
① Constraint properties→「FK_F55F48C361220EA6」
② カラム→「creator_id」

(1)下記SQLを実行して外部キーを削除する。

[php]
ALTER TABLE dtb_faq DROP FOREIGN KEY FK_15046F5861220EA6;
ALTER TABLE dtb_class_name DROP FOREIGN KEY FK_187C95AD61220EA6;
ALTER TABLE dtb_product_class DROP FOREIGN KEY FK_1A11D1BA61220EA6;
ALTER TABLE dtb_mail_template DROP FOREIGN KEY FK_1CB16DB261220EA6;
ALTER TABLE dtb_ticker DROP FOREIGN KEY FK_1E9BC90861220EA6;
ALTER TABLE dtb_product_image DROP FOREIGN KEY FK_3267CC7A61220EA6;
ALTER TABLE dtb_delivery DROP FOREIGN KEY FK_3420D9FA61220EA6;
ALTER TABLE dtb_topimage DROP FOREIGN KEY FK_3B5AB76661220EA6;
ALTER TABLE dtb_lp DROP FOREIGN KEY FK_4177A97261220EA6;
ALTER TABLE dtb_product_tag DROP FOREIGN KEY FK_4433E72161220EA6;
ALTER TABLE dtb_mail_history DROP FOREIGN KEY FK_4870AB1161220EA6;
ALTER TABLE dtb_authority_role DROP FOREIGN KEY FK_4A1F70B161220EA6;
ALTER TABLE dtb_tax_rule DROP FOREIGN KEY FK_59F696DE61220EA6;
ALTER TABLE dtb_category DROP FOREIGN KEY FK_5ED2C2B61220EA6;
ALTER TABLE dtb_payment DROP FOREIGN KEY FK_7AFF628F61220EA6;
ALTER TABLE dtb_class_category DROP FOREIGN KEY FK_9B0D1DBA61220EA6;
ALTER TABLE dtb_product_stock DROP FOREIGN KEY FK_BC6C9E4561220EA6;
ALTER TABLE dtb_product DROP FOREIGN KEY FK_C49DE22F61220EA6;
ALTER TABLE dtb_news DROP FOREIGN KEY FK_EA4C351761220EA6;
ALTER TABLE dtb_csv DROP FOREIGN KEY FK_F55F48C361220EA6;
[/php]

(2)dtb_memberテーブルを空にする。

(3)sqlをインポートする。アップロードファイル→参照、「実行」をクリック。

(4)下記SQLを実行して参照元テーブルに外部キーを復元する。

[php]
DELETE FROM dtb_faq WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_class_name WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_product_class WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_mail_template WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_ticker WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_product_image WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_delivery WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_topimage WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_lp WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_product_tag WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_mail_history WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_authority_role WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_tax_rule WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_category WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_payment WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_class_category WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_product_stock WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_product WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_news WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );
DELETE FROM dtb_csv WHERE creator_id NOT IN( SELECT member_id FROM dtb_member );

ALTER TABLE dtb_faq ADD CONSTRAINT FK_15046F5861220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_class_name ADD CONSTRAINT FK_187C95AD61220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_product_class ADD CONSTRAINT FK_1A11D1BA61220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_mail_template ADD CONSTRAINT FK_1CB16DB261220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_ticker ADD CONSTRAINT FK_1E9BC90861220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_product_image ADD CONSTRAINT FK_3267CC7A61220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_delivery ADD CONSTRAINT FK_3420D9FA61220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_topimage ADD CONSTRAINT FK_3B5AB76661220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_lp ADD CONSTRAINT FK_4177A97261220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_product_tag ADD CONSTRAINT FK_4433E72161220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_mail_history ADD CONSTRAINT FK_4870AB1161220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_authority_role ADD CONSTRAINT FK_4A1F70B161220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_tax_rule ADD CONSTRAINT FK_59F696DE61220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_category ADD CONSTRAINT FK_5ED2C2B61220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_payment ADD CONSTRAINT FK_7AFF628F61220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_class_category ADD CONSTRAINT FK_9B0D1DBA61220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_product_stock ADD CONSTRAINT FK_BC6C9E4561220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_product ADD CONSTRAINT FK_C49DE22F61220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_news ADD CONSTRAINT FK_EA4C351761220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE dtb_csv ADD CONSTRAINT FK_F55F48C361220EA6 FOREIGN KEY (creator_id) REFERENCES dtb_member (member_id) ON DELETE RESTRICT ON UPDATE RESTRICT;
[/php]

6 移行元のパスワードでログインできるようにする

(1)移行元、生成されている「app/config/eccube/config.yml」をダウンロード
(2)auth_magic:*************************←コピー
(3)移行先、生成されている「app/config/eccube/config.yml」をダウンロード
(4)auth_magic:*************************←ペーストして、アップロード

つまり、移行元のauth_magicを移行先のauth_magicで使用するということです。