Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nishapanFFF/1ddef997951fa5c5f2f6b939f35936c8 to your computer and use it in GitHub Desktop.
Save nishapanFFF/1ddef997951fa5c5f2f6b939f35936c8 to your computer and use it in GitHub Desktop.
<?php
use Phinx\Migration\AbstractMigration;
class InsertFriendbuyToReferralShare extends AbstractMigration
{
public function change()
{
// we only care about rows that are not duplicate
$friendbuyRows = $this->fetchAll("SELECT * FROM friendbuy_shares");
$referralTable = $this->table('referral_shares');
foreach ($friendbuyRows as $friendbuyRow) {
$data = [[
'campaign_id' => $friendbuyRow['campaign_id'],
'created_at' => $friendbuyRow['created_at'],
'referrer_email' => $friendbuyRow['customer_email'],
'referred_email' => $friendbuyRow['email'],
'raw_data' => $friendbuyRow['raw_data'],
'vendor_id' => 1 //set vendor_id to 1 for friendbuy
]];
$referralTable->insert($data);
}
$referralTable->saveData();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment