agrs-sequelize-sdk 1.4.52 → 1.4.53

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.
Files changed (116) hide show
  1. package/migrations/2026-05-17-PIXELS-FOLLOWUP.md +85 -85
  2. package/migrations/2026-05-17-add-platform-to-ad.js +19 -19
  3. package/migrations/2026-05-17-add-platform-to-adaccount.js +19 -19
  4. package/migrations/2026-05-17-add-platform-to-adperformance.js +19 -19
  5. package/migrations/2026-05-17-add-platform-to-adset.js +19 -19
  6. package/migrations/2026-05-17-add-platform-to-adsetperformance.js +19 -19
  7. package/migrations/2026-05-17-add-platform-to-aiarticleretryqueue.js +19 -19
  8. package/migrations/2026-05-17-add-platform-to-aicampaignqueue.js +19 -19
  9. package/migrations/2026-05-17-add-platform-to-article.js +19 -19
  10. package/migrations/2026-05-17-add-platform-to-campaign.js +19 -19
  11. package/migrations/2026-05-17-add-platform-to-codefuelcampaign.js +19 -19
  12. package/migrations/2026-05-17-add-platform-to-dynamicfeed.js +19 -19
  13. package/migrations/2026-05-17-add-platform-to-facebookretryqueue.js +19 -19
  14. package/migrations/2026-05-17-add-platform-to-pages.js +19 -19
  15. package/migrations/2026-05-17-add-platform-to-presets.js +19 -19
  16. package/migrations/2026-05-18-add-group-id-to-ai-campaign-queue.js +18 -18
  17. package/migrations/2026-05-18-add-platform-code-to-creation-logs.js +65 -65
  18. package/migrations/2026-05-18-add-platform-code-to-pixels.js +55 -55
  19. package/migrations/2026-05-18-add-platform-code-to-rsoc-feed-campaigns.js +55 -55
  20. package/migrations/2026-05-18-add-platform-date-index-to-adperformance.js +16 -16
  21. package/migrations/2026-05-18-add-platform-date-index-to-adsetperformance.js +16 -16
  22. package/migrations/2026-05-18-add-review-status-to-ad.js +36 -36
  23. package/migrations/2026-05-18-create-canonical-insights.js +84 -84
  24. package/migrations/2026-05-18-create-snapchat-public-profiles.js +68 -68
  25. package/migrations/2026-05-18-create-tiktok-identities.js +71 -71
  26. package/migrations/2026-05-18-create-tiktok-snapchat-campaigns.js +143 -143
  27. package/migrations/2026-05-18-create-tt-snp-adset-ad-tables.js +309 -309
  28. package/migrations/RUN_ME_MANUALLY_2026-05-17.sql +99 -99
  29. package/migrations/add-requested-from-dashboard-to-articles.js +17 -17
  30. package/migrations/change-adset-name-to-text.js +79 -79
  31. package/models/AICampaignQueue.js +152 -152
  32. package/models/AIGenerationLog.js +85 -85
  33. package/models/AIGenerationRequest.js +212 -212
  34. package/models/AdAccountValues.js +25 -25
  35. package/models/AdHistory.js +30 -30
  36. package/models/AdPerformance.js +104 -104
  37. package/models/AdSet.js +295 -295
  38. package/models/AdSetHistory.js +30 -30
  39. package/models/AdsetPerformance.js +137 -137
  40. package/models/AiArticleRetryQueue.js +157 -157
  41. package/models/AiCreationRetryQueue.js +134 -134
  42. package/models/ApiAuditLog.js +127 -127
  43. package/models/ApiToken.js +67 -67
  44. package/models/Article.js +222 -222
  45. package/models/AutomationRule.js +179 -179
  46. package/models/BannerTemplate.js +129 -129
  47. package/models/Buyers.js +25 -25
  48. package/models/Campaign.js +168 -163
  49. package/models/CampaignActionHistory.js +101 -101
  50. package/models/CampaignCreationLog.js +340 -340
  51. package/models/CampaignCreationLogV2.js +392 -392
  52. package/models/CampaignHistory.js +33 -33
  53. package/models/CampaignTag.js +46 -0
  54. package/models/CampaignTagAssignment.js +48 -0
  55. package/models/CanonicalInsights.js +68 -68
  56. package/models/Channel.js +55 -55
  57. package/models/Domain.js +44 -44
  58. package/models/DynamicFeed.js +218 -218
  59. package/models/ExplorAdsChannel.js +61 -61
  60. package/models/FacebookRetryQueue.js +163 -163
  61. package/models/Feed.js +33 -33
  62. package/models/FeedArticleConfiguration.js +80 -80
  63. package/models/FrontStoryChannel.js +59 -59
  64. package/models/FrontStoryChannelV2.js +60 -60
  65. package/models/GenericFlowRequest.js +114 -114
  66. package/models/MidoWebChannel.js +47 -47
  67. package/models/MineBrandBlocklist.js +40 -40
  68. package/models/MineChannel.js +42 -42
  69. package/models/MineRedirectDomain.js +36 -36
  70. package/models/MineWebhookEvent.js +53 -53
  71. package/models/Pages.js +117 -117
  72. package/models/PipelineExecution.js +59 -59
  73. package/models/PolicyDogsCreativeCache.js +50 -50
  74. package/models/PolicyDogsImageCache.js +30 -30
  75. package/models/Presets.js +40 -40
  76. package/models/PublicApiBatch.js +155 -155
  77. package/models/PublicApiBatchItem.js +166 -166
  78. package/models/PublicApiIdempotencyCache.js +135 -135
  79. package/models/RSOCFeedCampaign.js +387 -387
  80. package/models/RsocKeywordPerformance.js +110 -110
  81. package/models/RuleAction.js +90 -90
  82. package/models/RuleCondition.js +137 -137
  83. package/models/RuleExecution.js +107 -107
  84. package/models/RulesValues.js +56 -56
  85. package/models/SingularChannel.js +31 -31
  86. package/models/SnapchatAd.js +69 -69
  87. package/models/SnapchatAdSquad.js +92 -92
  88. package/models/SnapchatCampaign.js +69 -69
  89. package/models/SnapchatChannel.js +31 -31
  90. package/models/SnapchatPublicProfiles.js +67 -67
  91. package/models/SupportedLocale.js +23 -23
  92. package/models/SyncHistory.js +249 -249
  93. package/models/TTQChannel.js +42 -42
  94. package/models/TemplateMetadata.js +260 -260
  95. package/models/Tier2_AdAccounts.js +110 -110
  96. package/models/Tier2_Assets.js +70 -70
  97. package/models/Tier2_BusinessManagers.js +105 -105
  98. package/models/Tier2_CreditLines.js +99 -99
  99. package/models/Tier2_Pages.js +91 -91
  100. package/models/Tier2_Pixels.js +82 -82
  101. package/models/Tier2_Tokens.js +64 -64
  102. package/models/Tier2_UserAdAccounts.js +83 -83
  103. package/models/TikTokAd.js +71 -71
  104. package/models/TikTokAdGroup.js +82 -82
  105. package/models/TikTokCampaign.js +71 -71
  106. package/models/TiktokChannel.js +31 -31
  107. package/models/TiktokIdentities.js +65 -65
  108. package/models/TokenRotationState.js +121 -121
  109. package/models/TonicRSOCKeywordPerformance.js +122 -122
  110. package/models/Users.js +190 -185
  111. package/models/Vertical.js +25 -25
  112. package/models/newFiles.js +137 -137
  113. package/package.json +21 -19
  114. package/run.sh +214 -214
  115. package/services/sequelizeService.js +110 -110
  116. package/tarzo-skalio-integration-docs.md +691 -691
@@ -1,309 +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
- };
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
+ };