agrs-sequelize-sdk 1.4.19 → 1.4.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations/2026-05-18-add-group-id-to-ai-campaign-queue.js +18 -0
- package/migrations/2026-05-18-add-platform-code-to-creation-logs.js +65 -0
- package/migrations/2026-05-18-add-platform-code-to-pixels.js +55 -0
- package/migrations/2026-05-18-add-platform-code-to-rsoc-feed-campaigns.js +55 -0
- package/migrations/2026-05-18-add-platform-date-index-to-adperformance.js +16 -0
- package/migrations/2026-05-18-add-platform-date-index-to-adsetperformance.js +16 -0
- package/migrations/2026-05-18-add-review-status-to-ad.js +36 -0
- package/migrations/2026-05-18-create-canonical-insights.js +84 -0
- package/migrations/2026-05-18-create-snapchat-public-profiles.js +68 -0
- package/migrations/2026-05-18-create-tiktok-identities.js +71 -0
- package/migrations/2026-05-18-create-tiktok-snapchat-campaigns.js +143 -0
- package/migrations/2026-05-18-create-tt-snp-adset-ad-tables.js +309 -0
- package/models/AICampaignQueue.js +9 -0
- package/models/Ad.js +12 -0
- package/models/AdPerformance.js +4 -0
- package/models/AdsetPerformance.js +5 -0
- package/models/CampaignCreationLog.js +12 -0
- package/models/CampaignCreationLogV2.js +8 -0
- package/models/CanonicalInsights.js +68 -0
- package/models/RSOCFeedCampaign.js +6 -0
- package/models/SnapchatAd.js +69 -0
- package/models/SnapchatAdSquad.js +92 -0
- package/models/SnapchatCampaign.js +69 -0
- package/models/SnapchatPublicProfiles.js +47 -0
- package/models/TikTokAd.js +71 -0
- package/models/TikTokAdGroup.js +82 -0
- package/models/TikTokCampaign.js +71 -0
- package/models/TiktokIdentities.js +51 -0
- package/models/Users.js +10 -0
- package/models/pixel.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Additive migration — creates four new tables to mirror TikTok ad groups/ads
|
|
4
|
+
// and Snapchat ad squads/ads in the local DB. No FKs to existing tables;
|
|
5
|
+
// loose coupling keeps platform isolation. Reporting joins to canonical_insights
|
|
6
|
+
// at the MV layer (see dashboard migration 004-multi-platform-ad-level.sql).
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
up: async (queryInterface, Sequelize) => {
|
|
10
|
+
// ----- TikTok Ad Groups -----
|
|
11
|
+
await queryInterface.createTable("tiktok_adgroups", {
|
|
12
|
+
adgroup_id: {
|
|
13
|
+
type: Sequelize.BIGINT,
|
|
14
|
+
primaryKey: true,
|
|
15
|
+
allowNull: false,
|
|
16
|
+
},
|
|
17
|
+
adgroup_name: {
|
|
18
|
+
type: Sequelize.STRING(255),
|
|
19
|
+
allowNull: false,
|
|
20
|
+
},
|
|
21
|
+
campaign_id: {
|
|
22
|
+
type: Sequelize.BIGINT,
|
|
23
|
+
allowNull: false,
|
|
24
|
+
comment:
|
|
25
|
+
"TikTok campaign_id; loose FK to tiktok_campaigns (no DB-level constraint)",
|
|
26
|
+
},
|
|
27
|
+
ad_account_id: {
|
|
28
|
+
type: Sequelize.STRING(64),
|
|
29
|
+
allowNull: false,
|
|
30
|
+
},
|
|
31
|
+
placement_type: {
|
|
32
|
+
type: Sequelize.STRING(50),
|
|
33
|
+
allowNull: true,
|
|
34
|
+
comment: "PLACEMENT_TYPE_AUTOMATIC / PLACEMENT_TYPE_NORMAL",
|
|
35
|
+
},
|
|
36
|
+
budget_mode: {
|
|
37
|
+
type: Sequelize.STRING(50),
|
|
38
|
+
allowNull: true,
|
|
39
|
+
},
|
|
40
|
+
budget: {
|
|
41
|
+
type: Sequelize.DECIMAL(12, 6),
|
|
42
|
+
allowNull: true,
|
|
43
|
+
},
|
|
44
|
+
bid_type: {
|
|
45
|
+
type: Sequelize.STRING(50),
|
|
46
|
+
allowNull: true,
|
|
47
|
+
},
|
|
48
|
+
bid_price: {
|
|
49
|
+
type: Sequelize.DECIMAL(12, 6),
|
|
50
|
+
allowNull: true,
|
|
51
|
+
},
|
|
52
|
+
optimize_goal: {
|
|
53
|
+
type: Sequelize.STRING(50),
|
|
54
|
+
allowNull: true,
|
|
55
|
+
},
|
|
56
|
+
operation_status: {
|
|
57
|
+
type: Sequelize.STRING(50),
|
|
58
|
+
allowNull: true,
|
|
59
|
+
comment: "ENABLE or DISABLE (TikTok native)",
|
|
60
|
+
},
|
|
61
|
+
schedule_start_time: {
|
|
62
|
+
type: Sequelize.DATE,
|
|
63
|
+
allowNull: true,
|
|
64
|
+
},
|
|
65
|
+
schedule_end_time: {
|
|
66
|
+
type: Sequelize.DATE,
|
|
67
|
+
allowNull: true,
|
|
68
|
+
},
|
|
69
|
+
created_at: {
|
|
70
|
+
type: Sequelize.DATE,
|
|
71
|
+
allowNull: false,
|
|
72
|
+
},
|
|
73
|
+
updated_at: {
|
|
74
|
+
type: Sequelize.DATE,
|
|
75
|
+
allowNull: true,
|
|
76
|
+
},
|
|
77
|
+
synced_at: {
|
|
78
|
+
type: Sequelize.DATE,
|
|
79
|
+
allowNull: false,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
await queryInterface.addIndex("tiktok_adgroups", ["campaign_id"]);
|
|
84
|
+
await queryInterface.addIndex("tiktok_adgroups", ["ad_account_id"]);
|
|
85
|
+
await queryInterface.addIndex("tiktok_adgroups", ["operation_status"]);
|
|
86
|
+
|
|
87
|
+
// ----- TikTok Ads -----
|
|
88
|
+
await queryInterface.createTable("tiktok_ads", {
|
|
89
|
+
ad_id: {
|
|
90
|
+
type: Sequelize.BIGINT,
|
|
91
|
+
primaryKey: true,
|
|
92
|
+
allowNull: false,
|
|
93
|
+
},
|
|
94
|
+
ad_name: {
|
|
95
|
+
type: Sequelize.STRING(255),
|
|
96
|
+
allowNull: false,
|
|
97
|
+
},
|
|
98
|
+
adgroup_id: {
|
|
99
|
+
type: Sequelize.BIGINT,
|
|
100
|
+
allowNull: false,
|
|
101
|
+
comment:
|
|
102
|
+
"TikTok adgroup_id; loose FK to tiktok_adgroups (no DB-level constraint)",
|
|
103
|
+
},
|
|
104
|
+
campaign_id: {
|
|
105
|
+
type: Sequelize.BIGINT,
|
|
106
|
+
allowNull: false,
|
|
107
|
+
},
|
|
108
|
+
ad_account_id: {
|
|
109
|
+
type: Sequelize.STRING(64),
|
|
110
|
+
allowNull: false,
|
|
111
|
+
},
|
|
112
|
+
ad_format: {
|
|
113
|
+
type: Sequelize.STRING(50),
|
|
114
|
+
allowNull: true,
|
|
115
|
+
comment: "SINGLE_VIDEO, SINGLE_IMAGE, etc.",
|
|
116
|
+
},
|
|
117
|
+
identity_id: {
|
|
118
|
+
type: Sequelize.STRING(64),
|
|
119
|
+
allowNull: true,
|
|
120
|
+
comment: "TikTok identity (Page equivalent)",
|
|
121
|
+
},
|
|
122
|
+
landing_page_url: {
|
|
123
|
+
type: Sequelize.TEXT,
|
|
124
|
+
allowNull: true,
|
|
125
|
+
},
|
|
126
|
+
display_name: {
|
|
127
|
+
type: Sequelize.STRING(255),
|
|
128
|
+
allowNull: true,
|
|
129
|
+
},
|
|
130
|
+
operation_status: {
|
|
131
|
+
type: Sequelize.STRING(50),
|
|
132
|
+
allowNull: true,
|
|
133
|
+
comment: "ENABLE or DISABLE (TikTok native)",
|
|
134
|
+
},
|
|
135
|
+
created_at: {
|
|
136
|
+
type: Sequelize.DATE,
|
|
137
|
+
allowNull: false,
|
|
138
|
+
},
|
|
139
|
+
updated_at: {
|
|
140
|
+
type: Sequelize.DATE,
|
|
141
|
+
allowNull: true,
|
|
142
|
+
},
|
|
143
|
+
synced_at: {
|
|
144
|
+
type: Sequelize.DATE,
|
|
145
|
+
allowNull: false,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
await queryInterface.addIndex("tiktok_ads", ["adgroup_id"]);
|
|
150
|
+
await queryInterface.addIndex("tiktok_ads", ["campaign_id"]);
|
|
151
|
+
await queryInterface.addIndex("tiktok_ads", ["operation_status"]);
|
|
152
|
+
|
|
153
|
+
// ----- Snapchat Ad Squads -----
|
|
154
|
+
await queryInterface.createTable("snapchat_ad_squads", {
|
|
155
|
+
id: {
|
|
156
|
+
type: Sequelize.STRING(36),
|
|
157
|
+
primaryKey: true,
|
|
158
|
+
allowNull: false,
|
|
159
|
+
comment: "Snapchat ad squad UUID",
|
|
160
|
+
},
|
|
161
|
+
name: {
|
|
162
|
+
type: Sequelize.STRING(255),
|
|
163
|
+
allowNull: false,
|
|
164
|
+
},
|
|
165
|
+
campaign_id: {
|
|
166
|
+
type: Sequelize.STRING(36),
|
|
167
|
+
allowNull: false,
|
|
168
|
+
comment: "Snapchat campaign UUID; loose FK to snapchat_campaigns",
|
|
169
|
+
},
|
|
170
|
+
ad_account_id: {
|
|
171
|
+
type: Sequelize.STRING(36),
|
|
172
|
+
allowNull: false,
|
|
173
|
+
},
|
|
174
|
+
status: {
|
|
175
|
+
type: Sequelize.STRING(50),
|
|
176
|
+
allowNull: true,
|
|
177
|
+
comment: "ACTIVE or PAUSED (Snap native)",
|
|
178
|
+
},
|
|
179
|
+
type: {
|
|
180
|
+
type: Sequelize.STRING(50),
|
|
181
|
+
allowNull: true,
|
|
182
|
+
comment: "SNAP_ADS",
|
|
183
|
+
},
|
|
184
|
+
bid_strategy: {
|
|
185
|
+
type: Sequelize.STRING(50),
|
|
186
|
+
allowNull: true,
|
|
187
|
+
},
|
|
188
|
+
optimization_goal: {
|
|
189
|
+
type: Sequelize.STRING(50),
|
|
190
|
+
allowNull: true,
|
|
191
|
+
},
|
|
192
|
+
billing_event: {
|
|
193
|
+
type: Sequelize.STRING(50),
|
|
194
|
+
allowNull: true,
|
|
195
|
+
},
|
|
196
|
+
placement_v2: {
|
|
197
|
+
type: Sequelize.JSONB,
|
|
198
|
+
allowNull: true,
|
|
199
|
+
comment: "Snap placement_v2 config (e.g. {config:'AUTOMATIC', ...})",
|
|
200
|
+
},
|
|
201
|
+
daily_budget_micro: {
|
|
202
|
+
type: Sequelize.BIGINT,
|
|
203
|
+
allowNull: true,
|
|
204
|
+
},
|
|
205
|
+
bid_micro: {
|
|
206
|
+
type: Sequelize.BIGINT,
|
|
207
|
+
allowNull: true,
|
|
208
|
+
},
|
|
209
|
+
targeting: {
|
|
210
|
+
type: Sequelize.JSONB,
|
|
211
|
+
allowNull: true,
|
|
212
|
+
},
|
|
213
|
+
start_time: {
|
|
214
|
+
type: Sequelize.DATE,
|
|
215
|
+
allowNull: true,
|
|
216
|
+
},
|
|
217
|
+
end_time: {
|
|
218
|
+
type: Sequelize.DATE,
|
|
219
|
+
allowNull: true,
|
|
220
|
+
},
|
|
221
|
+
created_at: {
|
|
222
|
+
type: Sequelize.DATE,
|
|
223
|
+
allowNull: false,
|
|
224
|
+
},
|
|
225
|
+
updated_at: {
|
|
226
|
+
type: Sequelize.DATE,
|
|
227
|
+
allowNull: true,
|
|
228
|
+
},
|
|
229
|
+
synced_at: {
|
|
230
|
+
type: Sequelize.DATE,
|
|
231
|
+
allowNull: false,
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
await queryInterface.addIndex("snapchat_ad_squads", ["campaign_id"]);
|
|
236
|
+
await queryInterface.addIndex("snapchat_ad_squads", ["ad_account_id"]);
|
|
237
|
+
await queryInterface.addIndex("snapchat_ad_squads", ["status"]);
|
|
238
|
+
|
|
239
|
+
// ----- Snapchat Ads -----
|
|
240
|
+
await queryInterface.createTable("snapchat_ads", {
|
|
241
|
+
id: {
|
|
242
|
+
type: Sequelize.STRING(36),
|
|
243
|
+
primaryKey: true,
|
|
244
|
+
allowNull: false,
|
|
245
|
+
comment: "Snapchat ad UUID",
|
|
246
|
+
},
|
|
247
|
+
name: {
|
|
248
|
+
type: Sequelize.STRING(255),
|
|
249
|
+
allowNull: false,
|
|
250
|
+
},
|
|
251
|
+
ad_squad_id: {
|
|
252
|
+
type: Sequelize.STRING(36),
|
|
253
|
+
allowNull: false,
|
|
254
|
+
comment: "Snapchat ad squad UUID; loose FK to snapchat_ad_squads",
|
|
255
|
+
},
|
|
256
|
+
ad_account_id: {
|
|
257
|
+
type: Sequelize.STRING(36),
|
|
258
|
+
allowNull: false,
|
|
259
|
+
},
|
|
260
|
+
creative_id: {
|
|
261
|
+
type: Sequelize.STRING(36),
|
|
262
|
+
allowNull: false,
|
|
263
|
+
},
|
|
264
|
+
status: {
|
|
265
|
+
type: Sequelize.STRING(50),
|
|
266
|
+
allowNull: true,
|
|
267
|
+
comment: "ACTIVE or PAUSED (Snap native)",
|
|
268
|
+
},
|
|
269
|
+
type: {
|
|
270
|
+
type: Sequelize.STRING(50),
|
|
271
|
+
allowNull: true,
|
|
272
|
+
comment: "SNAP_AD",
|
|
273
|
+
},
|
|
274
|
+
review_status: {
|
|
275
|
+
type: Sequelize.STRING(50),
|
|
276
|
+
allowNull: true,
|
|
277
|
+
comment: "Mirrors Plan Q Ad.review_status (e.g. PENDING_REVIEW, APPROVED)",
|
|
278
|
+
},
|
|
279
|
+
pending_review_since: {
|
|
280
|
+
type: Sequelize.DATE,
|
|
281
|
+
allowNull: true,
|
|
282
|
+
comment: "Timestamp when ad first entered pending review (Plan Q)",
|
|
283
|
+
},
|
|
284
|
+
created_at: {
|
|
285
|
+
type: Sequelize.DATE,
|
|
286
|
+
allowNull: false,
|
|
287
|
+
},
|
|
288
|
+
updated_at: {
|
|
289
|
+
type: Sequelize.DATE,
|
|
290
|
+
allowNull: true,
|
|
291
|
+
},
|
|
292
|
+
synced_at: {
|
|
293
|
+
type: Sequelize.DATE,
|
|
294
|
+
allowNull: false,
|
|
295
|
+
},
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
await queryInterface.addIndex("snapchat_ads", ["ad_squad_id"]);
|
|
299
|
+
await queryInterface.addIndex("snapchat_ads", ["ad_account_id"]);
|
|
300
|
+
await queryInterface.addIndex("snapchat_ads", ["status"]);
|
|
301
|
+
},
|
|
302
|
+
|
|
303
|
+
down: async (queryInterface) => {
|
|
304
|
+
await queryInterface.dropTable("snapchat_ads");
|
|
305
|
+
await queryInterface.dropTable("snapchat_ad_squads");
|
|
306
|
+
await queryInterface.dropTable("tiktok_ads");
|
|
307
|
+
await queryInterface.dropTable("tiktok_adgroups");
|
|
308
|
+
},
|
|
309
|
+
};
|
|
@@ -98,6 +98,12 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
98
98
|
field: "platform",
|
|
99
99
|
comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
|
|
100
100
|
},
|
|
101
|
+
group_id: {
|
|
102
|
+
type: DataTypes.UUID,
|
|
103
|
+
allowNull: true,
|
|
104
|
+
field: "group_id",
|
|
105
|
+
comment: "Groups rows created by a single multi-platform fanout request",
|
|
106
|
+
},
|
|
101
107
|
},
|
|
102
108
|
{
|
|
103
109
|
tableName: "ai_campaign_queue",
|
|
@@ -127,6 +133,9 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
127
133
|
{
|
|
128
134
|
fields: ["preset_id"],
|
|
129
135
|
},
|
|
136
|
+
{
|
|
137
|
+
fields: ["group_id"],
|
|
138
|
+
},
|
|
130
139
|
],
|
|
131
140
|
}
|
|
132
141
|
);
|
package/models/Ad.js
CHANGED
|
@@ -139,6 +139,18 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
139
139
|
defaultValue: "fb",
|
|
140
140
|
comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
|
|
141
141
|
},
|
|
142
|
+
review_status: {
|
|
143
|
+
type: DataTypes.STRING,
|
|
144
|
+
allowNull: true,
|
|
145
|
+
comment:
|
|
146
|
+
"Local review status mirror (e.g. PENDING_REVIEW after copy/URL edit on Snap). Cleared by status sync.",
|
|
147
|
+
},
|
|
148
|
+
pending_review_since: {
|
|
149
|
+
type: DataTypes.DATE,
|
|
150
|
+
allowNull: true,
|
|
151
|
+
comment:
|
|
152
|
+
"Timestamp when ad was optimistically flipped to PENDING_REVIEW after a triggering edit. Cleared when upstream review settles.",
|
|
153
|
+
},
|
|
142
154
|
},
|
|
143
155
|
{
|
|
144
156
|
tableName: "Ad",
|
package/models/AdPerformance.js
CHANGED
|
@@ -115,6 +115,11 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
115
115
|
fields: ["AdSetID", "Date"],
|
|
116
116
|
// Composite unique index to ensure one record per AdSet per date
|
|
117
117
|
},
|
|
118
|
+
{
|
|
119
|
+
name: "AdSetPerformance_platform_Date_idx",
|
|
120
|
+
fields: ["platform", "Date"],
|
|
121
|
+
// Composite index for platform-scoped date range queries
|
|
122
|
+
},
|
|
118
123
|
],
|
|
119
124
|
}
|
|
120
125
|
);
|
|
@@ -114,6 +114,13 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
114
114
|
allowNull: true,
|
|
115
115
|
comment: "Platform (e.g., Facebook)",
|
|
116
116
|
},
|
|
117
|
+
platform_code: {
|
|
118
|
+
type: DataTypes.ENUM("fb", "tt", "snp"),
|
|
119
|
+
allowNull: false,
|
|
120
|
+
defaultValue: "fb",
|
|
121
|
+
comment:
|
|
122
|
+
"Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
|
|
123
|
+
},
|
|
117
124
|
bid_strategy: {
|
|
118
125
|
type: DataTypes.STRING(100),
|
|
119
126
|
allowNull: true,
|
|
@@ -262,6 +269,11 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
262
269
|
fields: ["page_code"],
|
|
263
270
|
comment: "For page code filtering",
|
|
264
271
|
},
|
|
272
|
+
{
|
|
273
|
+
name: "idx_campaign_logs_platform_code",
|
|
274
|
+
fields: ["platform_code"],
|
|
275
|
+
comment: "For canonical platform filtering",
|
|
276
|
+
},
|
|
265
277
|
{
|
|
266
278
|
fields: ["process_id"],
|
|
267
279
|
},
|
|
@@ -109,6 +109,13 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
109
109
|
type: DataTypes.STRING(50),
|
|
110
110
|
allowNull: true,
|
|
111
111
|
},
|
|
112
|
+
platform_code: {
|
|
113
|
+
type: DataTypes.ENUM("fb", "tt", "snp"),
|
|
114
|
+
allowNull: false,
|
|
115
|
+
defaultValue: "fb",
|
|
116
|
+
comment:
|
|
117
|
+
"Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
|
|
118
|
+
},
|
|
112
119
|
language: {
|
|
113
120
|
type: DataTypes.STRING(50),
|
|
114
121
|
allowNull: true,
|
|
@@ -277,6 +284,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
277
284
|
{ fields: ["account_id", "status"] },
|
|
278
285
|
{ fields: ["vertical", "feed_provider"] },
|
|
279
286
|
{ fields: ["details"], using: "gin" },
|
|
287
|
+
{ fields: ["platform_code"] },
|
|
280
288
|
],
|
|
281
289
|
}
|
|
282
290
|
);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const CanonicalInsights = sequelize.define(
|
|
3
|
+
"CanonicalInsights",
|
|
4
|
+
{
|
|
5
|
+
id: {
|
|
6
|
+
type: DataTypes.BIGINT,
|
|
7
|
+
primaryKey: true,
|
|
8
|
+
autoIncrement: true,
|
|
9
|
+
},
|
|
10
|
+
platform: {
|
|
11
|
+
type: DataTypes.ENUM("fb", "tt", "snp"),
|
|
12
|
+
allowNull: false,
|
|
13
|
+
comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
|
|
14
|
+
},
|
|
15
|
+
entity_type: {
|
|
16
|
+
type: DataTypes.ENUM("campaign", "adset", "ad"),
|
|
17
|
+
allowNull: false,
|
|
18
|
+
},
|
|
19
|
+
entity_id: {
|
|
20
|
+
type: DataTypes.STRING(64),
|
|
21
|
+
allowNull: false,
|
|
22
|
+
},
|
|
23
|
+
date: {
|
|
24
|
+
type: DataTypes.DATEONLY,
|
|
25
|
+
allowNull: false,
|
|
26
|
+
},
|
|
27
|
+
impressions: {
|
|
28
|
+
type: DataTypes.BIGINT,
|
|
29
|
+
defaultValue: 0,
|
|
30
|
+
},
|
|
31
|
+
clicks: {
|
|
32
|
+
type: DataTypes.BIGINT,
|
|
33
|
+
defaultValue: 0,
|
|
34
|
+
},
|
|
35
|
+
spend: {
|
|
36
|
+
type: DataTypes.DECIMAL(14, 4),
|
|
37
|
+
defaultValue: 0,
|
|
38
|
+
},
|
|
39
|
+
conversions: {
|
|
40
|
+
type: DataTypes.BIGINT,
|
|
41
|
+
defaultValue: 0,
|
|
42
|
+
},
|
|
43
|
+
revenue: {
|
|
44
|
+
type: DataTypes.DECIMAL(14, 4),
|
|
45
|
+
defaultValue: 0,
|
|
46
|
+
},
|
|
47
|
+
raw_payload: {
|
|
48
|
+
type: DataTypes.JSONB,
|
|
49
|
+
allowNull: true,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
tableName: "canonical_insights",
|
|
54
|
+
indexes: [
|
|
55
|
+
{
|
|
56
|
+
unique: true,
|
|
57
|
+
name: "canonical_insights_unique_per_entity_date",
|
|
58
|
+
fields: ["platform", "entity_type", "entity_id", "date"],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
fields: ["platform", "date"],
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
return CanonicalInsights;
|
|
68
|
+
};
|
|
@@ -160,6 +160,12 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
160
160
|
type: DataTypes.STRING,
|
|
161
161
|
allowNull: false,
|
|
162
162
|
},
|
|
163
|
+
platform_code: {
|
|
164
|
+
type: DataTypes.ENUM("fb", "tt", "snp"),
|
|
165
|
+
allowNull: false,
|
|
166
|
+
defaultValue: "fb",
|
|
167
|
+
comment: "Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
|
|
168
|
+
},
|
|
163
169
|
mediaBuyer: {
|
|
164
170
|
type: DataTypes.STRING,
|
|
165
171
|
allowNull: true,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) =>
|
|
2
|
+
sequelize.define(
|
|
3
|
+
"SnapchatAd",
|
|
4
|
+
{
|
|
5
|
+
id: {
|
|
6
|
+
type: DataTypes.STRING(36),
|
|
7
|
+
primaryKey: true,
|
|
8
|
+
comment: "Snapchat ad UUID",
|
|
9
|
+
},
|
|
10
|
+
name: {
|
|
11
|
+
type: DataTypes.STRING(255),
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
ad_squad_id: {
|
|
15
|
+
type: DataTypes.STRING(36),
|
|
16
|
+
allowNull: false,
|
|
17
|
+
comment: "Snapchat ad squad UUID; loose FK to snapchat_ad_squads",
|
|
18
|
+
},
|
|
19
|
+
ad_account_id: {
|
|
20
|
+
type: DataTypes.STRING(36),
|
|
21
|
+
allowNull: false,
|
|
22
|
+
},
|
|
23
|
+
creative_id: {
|
|
24
|
+
type: DataTypes.STRING(36),
|
|
25
|
+
allowNull: false,
|
|
26
|
+
},
|
|
27
|
+
status: {
|
|
28
|
+
type: DataTypes.STRING(50),
|
|
29
|
+
allowNull: true,
|
|
30
|
+
comment: "ACTIVE or PAUSED (Snap native)",
|
|
31
|
+
},
|
|
32
|
+
type: {
|
|
33
|
+
type: DataTypes.STRING(50),
|
|
34
|
+
allowNull: true,
|
|
35
|
+
comment: "SNAP_AD",
|
|
36
|
+
},
|
|
37
|
+
review_status: {
|
|
38
|
+
type: DataTypes.STRING(50),
|
|
39
|
+
allowNull: true,
|
|
40
|
+
comment: "Mirrors Plan Q Ad.review_status (e.g. PENDING_REVIEW, APPROVED)",
|
|
41
|
+
},
|
|
42
|
+
pending_review_since: {
|
|
43
|
+
type: DataTypes.DATE,
|
|
44
|
+
allowNull: true,
|
|
45
|
+
comment: "Timestamp when ad first entered pending review (Plan Q)",
|
|
46
|
+
},
|
|
47
|
+
created_at: {
|
|
48
|
+
type: DataTypes.DATE,
|
|
49
|
+
allowNull: false,
|
|
50
|
+
},
|
|
51
|
+
updated_at: {
|
|
52
|
+
type: DataTypes.DATE,
|
|
53
|
+
allowNull: true,
|
|
54
|
+
},
|
|
55
|
+
synced_at: {
|
|
56
|
+
type: DataTypes.DATE,
|
|
57
|
+
allowNull: false,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
tableName: "snapchat_ads",
|
|
62
|
+
timestamps: false,
|
|
63
|
+
indexes: [
|
|
64
|
+
{ fields: ["ad_squad_id"] },
|
|
65
|
+
{ fields: ["ad_account_id"] },
|
|
66
|
+
{ fields: ["status"] },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) =>
|
|
2
|
+
sequelize.define(
|
|
3
|
+
"SnapchatAdSquad",
|
|
4
|
+
{
|
|
5
|
+
id: {
|
|
6
|
+
type: DataTypes.STRING(36),
|
|
7
|
+
primaryKey: true,
|
|
8
|
+
comment: "Snapchat ad squad UUID",
|
|
9
|
+
},
|
|
10
|
+
name: {
|
|
11
|
+
type: DataTypes.STRING(255),
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
campaign_id: {
|
|
15
|
+
type: DataTypes.STRING(36),
|
|
16
|
+
allowNull: false,
|
|
17
|
+
comment: "Snapchat campaign UUID; loose FK to snapchat_campaigns",
|
|
18
|
+
},
|
|
19
|
+
ad_account_id: {
|
|
20
|
+
type: DataTypes.STRING(36),
|
|
21
|
+
allowNull: false,
|
|
22
|
+
},
|
|
23
|
+
status: {
|
|
24
|
+
type: DataTypes.STRING(50),
|
|
25
|
+
allowNull: true,
|
|
26
|
+
comment: "ACTIVE or PAUSED (Snap native)",
|
|
27
|
+
},
|
|
28
|
+
type: {
|
|
29
|
+
type: DataTypes.STRING(50),
|
|
30
|
+
allowNull: true,
|
|
31
|
+
comment: "SNAP_ADS",
|
|
32
|
+
},
|
|
33
|
+
bid_strategy: {
|
|
34
|
+
type: DataTypes.STRING(50),
|
|
35
|
+
allowNull: true,
|
|
36
|
+
},
|
|
37
|
+
optimization_goal: {
|
|
38
|
+
type: DataTypes.STRING(50),
|
|
39
|
+
allowNull: true,
|
|
40
|
+
},
|
|
41
|
+
billing_event: {
|
|
42
|
+
type: DataTypes.STRING(50),
|
|
43
|
+
allowNull: true,
|
|
44
|
+
},
|
|
45
|
+
placement_v2: {
|
|
46
|
+
type: DataTypes.JSONB,
|
|
47
|
+
allowNull: true,
|
|
48
|
+
comment: "Snap placement_v2 config (e.g. {config:'AUTOMATIC', ...})",
|
|
49
|
+
},
|
|
50
|
+
daily_budget_micro: {
|
|
51
|
+
type: DataTypes.BIGINT,
|
|
52
|
+
allowNull: true,
|
|
53
|
+
},
|
|
54
|
+
bid_micro: {
|
|
55
|
+
type: DataTypes.BIGINT,
|
|
56
|
+
allowNull: true,
|
|
57
|
+
},
|
|
58
|
+
targeting: {
|
|
59
|
+
type: DataTypes.JSONB,
|
|
60
|
+
allowNull: true,
|
|
61
|
+
},
|
|
62
|
+
start_time: {
|
|
63
|
+
type: DataTypes.DATE,
|
|
64
|
+
allowNull: true,
|
|
65
|
+
},
|
|
66
|
+
end_time: {
|
|
67
|
+
type: DataTypes.DATE,
|
|
68
|
+
allowNull: true,
|
|
69
|
+
},
|
|
70
|
+
created_at: {
|
|
71
|
+
type: DataTypes.DATE,
|
|
72
|
+
allowNull: false,
|
|
73
|
+
},
|
|
74
|
+
updated_at: {
|
|
75
|
+
type: DataTypes.DATE,
|
|
76
|
+
allowNull: true,
|
|
77
|
+
},
|
|
78
|
+
synced_at: {
|
|
79
|
+
type: DataTypes.DATE,
|
|
80
|
+
allowNull: false,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
tableName: "snapchat_ad_squads",
|
|
85
|
+
timestamps: false,
|
|
86
|
+
indexes: [
|
|
87
|
+
{ fields: ["campaign_id"] },
|
|
88
|
+
{ fields: ["ad_account_id"] },
|
|
89
|
+
{ fields: ["status"] },
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
);
|