我创建了以下 SQL 代码来迁移我们的数据库。UP 查询工作正常,但我不知道如何修复 DOWN 查询。我只想插入 payment_gateway 表中的所有数据,但也必须匹配正确的 reseller_shop.id。
// UP
INSERT INTO payment_gateway (`type`, account, keyIn, keyOut, resellerShopId)
SELECT 'paymentGatewayOgone', rs.ogoneAccount, rs.ogoneSignatureIn, rs.ogoneSignatureOut, rs.id
FROM reseller_shop AS rs
WHERE rs.ogoneAccount <> '';
// DOWN
INSERT INTO reseller_shop (ogoneAccount, ogoneSignatureIn, ogoneSignatureOut)
SELECT pg.account, pg.keyIn, pg.keyOut
FROM payment_gateway AS pg
WHERE pg.type = 'paymentGatewayOgone'
AND reseller_shop.id = pg.resellerShopId