Commit 3df410e4 by Евгений

Улучшение #19453

Первоначальная загрузка всех РК аккаунтов.
1 parent 6010941e
......@@ -12,6 +12,7 @@ class Campaigns extends Model
protected $fillable = [
'external_id',
'Name',
'token',
'TimeTargeting',
'NegativeKeywords',
'BlockedIps',
......
......@@ -27,7 +27,8 @@ class CheckCampaignsChange extends DirectRequest {
'external_id' => $campaign['CampaignId']
],
[
'updated' => $campaign['ChangesIn']
'updated' => $campaign['ChangesIn'],
'token' => $this->getToken()->id
]);
}
}
......
......@@ -19,6 +19,7 @@ class GetCampaigns extends DirectRequest{
foreach ($response['result']['Campaigns'] as $campaign){
$data[] = [
'external_id' => $campaign['Id'],
'token' => $this->getToken()->id,
'Name' => $campaign['Name'],
'TimeTargeting' => json_encode($campaign['TimeTargeting']),
'NegativeKeywords' => !empty($campaign['NegativeKeywords']['Items']) ?implode("\n", $campaign['NegativeKeywords']['Items']):'',
......@@ -39,6 +40,7 @@ class GetCampaigns extends DirectRequest{
Campaigns::upsert($data, [
'external_id'
],[
'token',
'Name',
'TimeTargeting',
'NegativeKeywords',
......
......@@ -15,6 +15,7 @@ class CreateCampaignsTable extends Migration
{
Schema::create('campaigns', function (Blueprint $table) {
$table->id();
$table->bigInteger('token');
$table->bigInteger('external_id')->unique();
$table->string('Name', 255)->nullable();
$table->json('TimeTargeting')->nullable();
......@@ -36,6 +37,8 @@ class CreateCampaignsTable extends Migration
\App\Service\Requests\Direct\CheckCampaignsChange::STAT,
])->nullable();
$table->timestamps();
$table->foreign('token')->references('id')->on('tokens');
});
}
......@@ -46,6 +49,9 @@ class CreateCampaignsTable extends Migration
*/
public function down()
{
Schema::table('campaigns', function (Blueprint $table) {
$table->dropForeign('campaigns_token_foreign');
});
Schema::dropIfExists('campaigns');
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!