Permalink
Browse files

Also write JSON file to /output for easy migration

  • Loading branch information...
soundasleep committed May 25, 2018
1 parent 2179a95 commit 84ba51c2fccd6b162ceca537139958ccf7ffaca7
Showing with 21 additions and 0 deletions.
  1. +21 −0 batch/batch_export_to_csv_gz.php
@@ -82,6 +82,17 @@ function exportUserIdTable($table, $user, $user_id_key = "user_id") {
exportData($table, $user, $q);
}
$filename = "all-users.csv";
echo "Writing $filename...\n";
flush();
$fp = fopen($filename, "w") or die("Could not open $filename");
foreach ($users as $user) {
fwrite($fp, $user['email'] . "," . $user['id'] . "\n");
}
fclose($fp);
foreach ($users as $user) {
exportUserIdTable("users", $user, "id");
exportUserIdTable("user_oauth2_identities", $user);
@@ -511,4 +522,14 @@ function exportUserIdTable($table, $user, $user_id_key = "user_id") {
echo "Compressing...\n";
flush();
`cd ${user['id']} && zip -r ${user['id']}.zip * && cd ..`;
// write alternative JSON
if (!file_exists("output/")) {
mkdir("output", 0777, true);
}
$filename = "output/${user['id']}.json";
echo "Writing $filename...\n";
flush();
file_put_contents($filename, json_encode($json, JSON_PRETTY_PRINT));
}

0 comments on commit 84ba51c

Please sign in to comment.