diff --git a/scripts/migrate_encrypt_orderdelivery.php b/scripts/migrate_encrypt_orderdelivery.php new file mode 100644 index 00000000..c3d2cf7a --- /dev/null +++ b/scripts/migrate_encrypt_orderdelivery.php @@ -0,0 +1,57 @@ + PDO::ERRMODE_EXCEPTION] +); + +echo "=== Migrasi t_orderdelivery ===\n"; +$total = 0; +$stmt = $pdo->prepare( + "UPDATE t_orderdelivery SET T_OrderDeliveryDestination_enc = ? WHERE T_OrderDeliveryID = ?" +); + +while (true) { + $rows = $pdo->query( + "SELECT T_OrderDeliveryID, T_OrderDeliveryDestination + FROM t_orderdelivery + WHERE T_OrderDeliveryDestination_enc IS NULL + LIMIT 500" + )->fetchAll(PDO::FETCH_ASSOC); + + if (empty($rows)) break; + + foreach ($rows as $row) { + $stmt->execute([ + $enc->encrypt((string)($row['T_OrderDeliveryDestination'] ?? '')), + $row['T_OrderDeliveryID'], + ]); + $total++; + } + echo " {$total} rows...\n"; +} + +echo "t_orderdelivery selesai: {$total} rows\n";