agrs-sequelize-sdk 1.4.59 → 1.4.60

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 (120) 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 +151 -151
  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 -168
  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 -46
  54. package/models/CampaignTagAssignment.js +48 -48
  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 +56 -56
  68. package/models/MineBrandConfig.js +26 -26
  69. package/models/MineChannel.js +47 -47
  70. package/models/MineRedirectDomain.js +42 -42
  71. package/models/MineWebhookEvent.js +53 -53
  72. package/models/Pages.js +117 -117
  73. package/models/PipelineExecution.js +59 -59
  74. package/models/PolicyDogsCreativeCache.js +50 -50
  75. package/models/PolicyDogsImageCache.js +30 -30
  76. package/models/Presets.js +40 -40
  77. package/models/PublicApiBatch.js +155 -155
  78. package/models/PublicApiBatchItem.js +166 -166
  79. package/models/PublicApiIdempotencyCache.js +135 -135
  80. package/models/RSOCFeedCampaign.js +387 -387
  81. package/models/RSOCFeedConfig.js +46 -46
  82. package/models/RSOCRedirectWsCode.js +22 -22
  83. package/models/RsocKeywordPerformance.js +110 -110
  84. package/models/RuleAction.js +90 -90
  85. package/models/RuleCondition.js +137 -137
  86. package/models/RuleExecution.js +107 -107
  87. package/models/RulesValues.js +56 -56
  88. package/models/SingularChannel.js +31 -31
  89. package/models/SnapchatAd.js +69 -69
  90. package/models/SnapchatAdSquad.js +92 -92
  91. package/models/SnapchatCampaign.js +69 -69
  92. package/models/SnapchatChannel.js +31 -31
  93. package/models/SnapchatPublicProfiles.js +67 -67
  94. package/models/SupportedLocale.js +23 -23
  95. package/models/SyncHistory.js +249 -249
  96. package/models/TTQChannel.js +42 -42
  97. package/models/Team.js +33 -43
  98. package/models/TemplateMetadata.js +260 -260
  99. package/models/Tier2_AdAccounts.js +110 -110
  100. package/models/Tier2_Assets.js +70 -70
  101. package/models/Tier2_BusinessManagers.js +105 -105
  102. package/models/Tier2_CreditLines.js +99 -99
  103. package/models/Tier2_Pages.js +91 -91
  104. package/models/Tier2_Pixels.js +82 -82
  105. package/models/Tier2_Tokens.js +64 -64
  106. package/models/Tier2_UserAdAccounts.js +83 -83
  107. package/models/TikTokAd.js +71 -71
  108. package/models/TikTokAdGroup.js +82 -82
  109. package/models/TikTokCampaign.js +71 -71
  110. package/models/TiktokChannel.js +31 -31
  111. package/models/TiktokIdentities.js +65 -65
  112. package/models/TokenRotationState.js +121 -121
  113. package/models/TonicRSOCKeywordPerformance.js +122 -122
  114. package/models/Users.js +204 -204
  115. package/models/Vertical.js +25 -25
  116. package/models/newFiles.js +137 -137
  117. package/package.json +21 -19
  118. package/run.sh +214 -214
  119. package/services/sequelizeService.js +110 -110
  120. package/tarzo-skalio-integration-docs.md +691 -691
@@ -1,19 +1,19 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- up: async (queryInterface, Sequelize) => {
5
- await queryInterface.addColumn("Pages", "platform", {
6
- type: Sequelize.ENUM("fb", "tt", "snp"),
7
- allowNull: false,
8
- defaultValue: "fb",
9
- comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
10
- });
11
- },
12
-
13
- down: async (queryInterface, Sequelize) => {
14
- await queryInterface.removeColumn("Pages", "platform");
15
- await queryInterface.sequelize.query(
16
- 'DROP TYPE IF EXISTS "enum_Pages_platform";'
17
- );
18
- },
19
- };
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ await queryInterface.addColumn("Pages", "platform", {
6
+ type: Sequelize.ENUM("fb", "tt", "snp"),
7
+ allowNull: false,
8
+ defaultValue: "fb",
9
+ comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
10
+ });
11
+ },
12
+
13
+ down: async (queryInterface, Sequelize) => {
14
+ await queryInterface.removeColumn("Pages", "platform");
15
+ await queryInterface.sequelize.query(
16
+ 'DROP TYPE IF EXISTS "enum_Pages_platform";'
17
+ );
18
+ },
19
+ };
@@ -1,19 +1,19 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- up: async (queryInterface, Sequelize) => {
5
- await queryInterface.addColumn("Presets", "platform", {
6
- type: Sequelize.ENUM("fb", "tt", "snp"),
7
- allowNull: false,
8
- defaultValue: "fb",
9
- comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
10
- });
11
- },
12
-
13
- down: async (queryInterface, Sequelize) => {
14
- await queryInterface.removeColumn("Presets", "platform");
15
- await queryInterface.sequelize.query(
16
- 'DROP TYPE IF EXISTS "enum_Presets_platform";'
17
- );
18
- },
19
- };
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ await queryInterface.addColumn("Presets", "platform", {
6
+ type: Sequelize.ENUM("fb", "tt", "snp"),
7
+ allowNull: false,
8
+ defaultValue: "fb",
9
+ comment: "Ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
10
+ });
11
+ },
12
+
13
+ down: async (queryInterface, Sequelize) => {
14
+ await queryInterface.removeColumn("Presets", "platform");
15
+ await queryInterface.sequelize.query(
16
+ 'DROP TYPE IF EXISTS "enum_Presets_platform";'
17
+ );
18
+ },
19
+ };
@@ -1,18 +1,18 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- up: async (queryInterface, Sequelize) => {
5
- await queryInterface.addColumn("ai_campaign_queue", "group_id", {
6
- type: Sequelize.UUID,
7
- allowNull: true,
8
- comment:
9
- "Groups rows created by a single multi-platform fanout request",
10
- });
11
- await queryInterface.addIndex("ai_campaign_queue", ["group_id"]);
12
- },
13
-
14
- down: async (queryInterface) => {
15
- await queryInterface.removeIndex("ai_campaign_queue", ["group_id"]);
16
- await queryInterface.removeColumn("ai_campaign_queue", "group_id");
17
- },
18
- };
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ up: async (queryInterface, Sequelize) => {
5
+ await queryInterface.addColumn("ai_campaign_queue", "group_id", {
6
+ type: Sequelize.UUID,
7
+ allowNull: true,
8
+ comment:
9
+ "Groups rows created by a single multi-platform fanout request",
10
+ });
11
+ await queryInterface.addIndex("ai_campaign_queue", ["group_id"]);
12
+ },
13
+
14
+ down: async (queryInterface) => {
15
+ await queryInterface.removeIndex("ai_campaign_queue", ["group_id"]);
16
+ await queryInterface.removeColumn("ai_campaign_queue", "group_id");
17
+ },
18
+ };
@@ -1,65 +1,65 @@
1
- "use strict";
2
-
3
- /**
4
- * CampaignCreationLogs + CampaignCreationLogsV2 normalization (Phase 1):
5
- * - Add canonical `platform_code` ENUM column ('fb' | 'tt' | 'snp').
6
- * - Backfill from legacy VARCHAR `platform` column using case-insensitive mapping.
7
- * - Keep legacy `platform` column untouched (dropped in a follow-up plan).
8
- *
9
- * Mapping (case-insensitive on legacy `platform`):
10
- * facebook | fb -> fb
11
- * tiktok | tt -> tt
12
- * snapchat | snap | snp -> snp
13
- * else -> fb (safe default)
14
- */
15
- module.exports = {
16
- up: async (queryInterface, Sequelize) => {
17
- const tables = ["CampaignCreationLogs", "CampaignCreationLogsV2"];
18
-
19
- for (const table of tables) {
20
- // 1. Add the new column as nullable so we can backfill before enforcing NOT NULL.
21
- await queryInterface.addColumn(table, "platform_code", {
22
- type: Sequelize.ENUM("fb", "tt", "snp"),
23
- allowNull: true,
24
- comment:
25
- "Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
26
- });
27
-
28
- // 2. Backfill from legacy `platform` column (idempotent on platform_code IS NULL).
29
- await queryInterface.sequelize.query(`
30
- UPDATE "${table}"
31
- SET platform_code = CASE
32
- WHEN LOWER(platform) IN ('facebook', 'fb') THEN 'fb'::"enum_${table}_platform_code"
33
- WHEN LOWER(platform) IN ('tiktok', 'tt') THEN 'tt'::"enum_${table}_platform_code"
34
- WHEN LOWER(platform) IN ('snapchat', 'snap', 'snp') THEN 'snp'::"enum_${table}_platform_code"
35
- ELSE 'fb'::"enum_${table}_platform_code"
36
- END
37
- WHERE platform_code IS NULL;
38
- `);
39
-
40
- // 3. Enforce NOT NULL + default now that every row has a value.
41
- await queryInterface.changeColumn(table, "platform_code", {
42
- type: Sequelize.ENUM("fb", "tt", "snp"),
43
- allowNull: false,
44
- defaultValue: "fb",
45
- comment:
46
- "Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
47
- });
48
-
49
- // 4. Index for filter performance.
50
- await queryInterface.addIndex(table, ["platform_code"]);
51
- }
52
- },
53
-
54
- down: async (queryInterface) => {
55
- const tables = ["CampaignCreationLogs", "CampaignCreationLogsV2"];
56
-
57
- for (const table of tables) {
58
- await queryInterface.removeIndex(table, ["platform_code"]);
59
- await queryInterface.removeColumn(table, "platform_code");
60
- await queryInterface.sequelize.query(
61
- `DROP TYPE IF EXISTS "enum_${table}_platform_code";`
62
- );
63
- }
64
- },
65
- };
1
+ "use strict";
2
+
3
+ /**
4
+ * CampaignCreationLogs + CampaignCreationLogsV2 normalization (Phase 1):
5
+ * - Add canonical `platform_code` ENUM column ('fb' | 'tt' | 'snp').
6
+ * - Backfill from legacy VARCHAR `platform` column using case-insensitive mapping.
7
+ * - Keep legacy `platform` column untouched (dropped in a follow-up plan).
8
+ *
9
+ * Mapping (case-insensitive on legacy `platform`):
10
+ * facebook | fb -> fb
11
+ * tiktok | tt -> tt
12
+ * snapchat | snap | snp -> snp
13
+ * else -> fb (safe default)
14
+ */
15
+ module.exports = {
16
+ up: async (queryInterface, Sequelize) => {
17
+ const tables = ["CampaignCreationLogs", "CampaignCreationLogsV2"];
18
+
19
+ for (const table of tables) {
20
+ // 1. Add the new column as nullable so we can backfill before enforcing NOT NULL.
21
+ await queryInterface.addColumn(table, "platform_code", {
22
+ type: Sequelize.ENUM("fb", "tt", "snp"),
23
+ allowNull: true,
24
+ comment:
25
+ "Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
26
+ });
27
+
28
+ // 2. Backfill from legacy `platform` column (idempotent on platform_code IS NULL).
29
+ await queryInterface.sequelize.query(`
30
+ UPDATE "${table}"
31
+ SET platform_code = CASE
32
+ WHEN LOWER(platform) IN ('facebook', 'fb') THEN 'fb'::"enum_${table}_platform_code"
33
+ WHEN LOWER(platform) IN ('tiktok', 'tt') THEN 'tt'::"enum_${table}_platform_code"
34
+ WHEN LOWER(platform) IN ('snapchat', 'snap', 'snp') THEN 'snp'::"enum_${table}_platform_code"
35
+ ELSE 'fb'::"enum_${table}_platform_code"
36
+ END
37
+ WHERE platform_code IS NULL;
38
+ `);
39
+
40
+ // 3. Enforce NOT NULL + default now that every row has a value.
41
+ await queryInterface.changeColumn(table, "platform_code", {
42
+ type: Sequelize.ENUM("fb", "tt", "snp"),
43
+ allowNull: false,
44
+ defaultValue: "fb",
45
+ comment:
46
+ "Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
47
+ });
48
+
49
+ // 4. Index for filter performance.
50
+ await queryInterface.addIndex(table, ["platform_code"]);
51
+ }
52
+ },
53
+
54
+ down: async (queryInterface) => {
55
+ const tables = ["CampaignCreationLogs", "CampaignCreationLogsV2"];
56
+
57
+ for (const table of tables) {
58
+ await queryInterface.removeIndex(table, ["platform_code"]);
59
+ await queryInterface.removeColumn(table, "platform_code");
60
+ await queryInterface.sequelize.query(
61
+ `DROP TYPE IF EXISTS "enum_${table}_platform_code";`
62
+ );
63
+ }
64
+ },
65
+ };
@@ -1,55 +1,55 @@
1
- "use strict";
2
-
3
- /**
4
- * Pixels normalization (Phase 1):
5
- * - Add canonical `platform_code` ENUM column ('fb' | 'tt' | 'snp').
6
- * - Backfill from legacy VARCHAR `platform` column using case-insensitive mapping.
7
- * - Keep legacy `platform` column untouched (dropped in a follow-up plan).
8
- *
9
- * Mapping (case-insensitive on legacy `platform`):
10
- * facebook | fb -> fb
11
- * tiktok | tt -> tt
12
- * snapchat | snap | snp -> snp
13
- * else -> fb (safe default)
14
- */
15
- module.exports = {
16
- up: async (queryInterface, Sequelize) => {
17
- // 1. Add the new column as nullable so we can backfill before enforcing NOT NULL.
18
- await queryInterface.addColumn("Pixels", "platform_code", {
19
- type: Sequelize.ENUM("fb", "tt", "snp"),
20
- allowNull: true,
21
- comment: "Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
22
- });
23
-
24
- // 2. Backfill from legacy `platform` column (idempotent on platform_code IS NULL).
25
- await queryInterface.sequelize.query(`
26
- UPDATE "Pixels"
27
- SET platform_code = CASE
28
- WHEN LOWER(platform) IN ('facebook', 'fb') THEN 'fb'::"enum_Pixels_platform_code"
29
- WHEN LOWER(platform) IN ('tiktok', 'tt') THEN 'tt'::"enum_Pixels_platform_code"
30
- WHEN LOWER(platform) IN ('snapchat', 'snap', 'snp') THEN 'snp'::"enum_Pixels_platform_code"
31
- ELSE 'fb'::"enum_Pixels_platform_code"
32
- END
33
- WHERE platform_code IS NULL;
34
- `);
35
-
36
- // 3. Enforce NOT NULL + default now that every row has a value.
37
- await queryInterface.changeColumn("Pixels", "platform_code", {
38
- type: Sequelize.ENUM("fb", "tt", "snp"),
39
- allowNull: false,
40
- defaultValue: "fb",
41
- comment: "Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
42
- });
43
-
44
- // 4. Index for filter performance.
45
- await queryInterface.addIndex("Pixels", ["platform_code"]);
46
- },
47
-
48
- down: async (queryInterface) => {
49
- await queryInterface.removeIndex("Pixels", ["platform_code"]);
50
- await queryInterface.removeColumn("Pixels", "platform_code");
51
- await queryInterface.sequelize.query(
52
- 'DROP TYPE IF EXISTS "enum_Pixels_platform_code";'
53
- );
54
- },
55
- };
1
+ "use strict";
2
+
3
+ /**
4
+ * Pixels normalization (Phase 1):
5
+ * - Add canonical `platform_code` ENUM column ('fb' | 'tt' | 'snp').
6
+ * - Backfill from legacy VARCHAR `platform` column using case-insensitive mapping.
7
+ * - Keep legacy `platform` column untouched (dropped in a follow-up plan).
8
+ *
9
+ * Mapping (case-insensitive on legacy `platform`):
10
+ * facebook | fb -> fb
11
+ * tiktok | tt -> tt
12
+ * snapchat | snap | snp -> snp
13
+ * else -> fb (safe default)
14
+ */
15
+ module.exports = {
16
+ up: async (queryInterface, Sequelize) => {
17
+ // 1. Add the new column as nullable so we can backfill before enforcing NOT NULL.
18
+ await queryInterface.addColumn("Pixels", "platform_code", {
19
+ type: Sequelize.ENUM("fb", "tt", "snp"),
20
+ allowNull: true,
21
+ comment: "Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
22
+ });
23
+
24
+ // 2. Backfill from legacy `platform` column (idempotent on platform_code IS NULL).
25
+ await queryInterface.sequelize.query(`
26
+ UPDATE "Pixels"
27
+ SET platform_code = CASE
28
+ WHEN LOWER(platform) IN ('facebook', 'fb') THEN 'fb'::"enum_Pixels_platform_code"
29
+ WHEN LOWER(platform) IN ('tiktok', 'tt') THEN 'tt'::"enum_Pixels_platform_code"
30
+ WHEN LOWER(platform) IN ('snapchat', 'snap', 'snp') THEN 'snp'::"enum_Pixels_platform_code"
31
+ ELSE 'fb'::"enum_Pixels_platform_code"
32
+ END
33
+ WHERE platform_code IS NULL;
34
+ `);
35
+
36
+ // 3. Enforce NOT NULL + default now that every row has a value.
37
+ await queryInterface.changeColumn("Pixels", "platform_code", {
38
+ type: Sequelize.ENUM("fb", "tt", "snp"),
39
+ allowNull: false,
40
+ defaultValue: "fb",
41
+ comment: "Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
42
+ });
43
+
44
+ // 4. Index for filter performance.
45
+ await queryInterface.addIndex("Pixels", ["platform_code"]);
46
+ },
47
+
48
+ down: async (queryInterface) => {
49
+ await queryInterface.removeIndex("Pixels", ["platform_code"]);
50
+ await queryInterface.removeColumn("Pixels", "platform_code");
51
+ await queryInterface.sequelize.query(
52
+ 'DROP TYPE IF EXISTS "enum_Pixels_platform_code";'
53
+ );
54
+ },
55
+ };
@@ -1,55 +1,55 @@
1
- "use strict";
2
-
3
- /**
4
- * rsoc_feed_campaigns normalization (Phase 1):
5
- * - Add canonical `platform_code` ENUM column ('fb' | 'tt' | 'snp').
6
- * - Backfill from legacy VARCHAR `platform` column using case-insensitive mapping.
7
- * - Keep legacy `platform` column untouched (dropped in a follow-up plan).
8
- *
9
- * Mapping (case-insensitive on legacy `platform`):
10
- * facebook | fb -> fb
11
- * tiktok | tt -> tt
12
- * snapchat | snap | snp -> snp
13
- * else -> fb (safe default)
14
- */
15
- module.exports = {
16
- up: async (queryInterface, Sequelize) => {
17
- // 1. Add the new column as nullable so we can backfill before enforcing NOT NULL.
18
- await queryInterface.addColumn("rsoc_feed_campaigns", "platform_code", {
19
- type: Sequelize.ENUM("fb", "tt", "snp"),
20
- allowNull: true,
21
- comment: "Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
22
- });
23
-
24
- // 2. Backfill from legacy `platform` column (idempotent on platform_code IS NULL).
25
- await queryInterface.sequelize.query(`
26
- UPDATE "rsoc_feed_campaigns"
27
- SET platform_code = CASE
28
- WHEN LOWER(platform) IN ('facebook', 'fb') THEN 'fb'::"enum_rsoc_feed_campaigns_platform_code"
29
- WHEN LOWER(platform) IN ('tiktok', 'tt') THEN 'tt'::"enum_rsoc_feed_campaigns_platform_code"
30
- WHEN LOWER(platform) IN ('snapchat', 'snap', 'snp') THEN 'snp'::"enum_rsoc_feed_campaigns_platform_code"
31
- ELSE 'fb'::"enum_rsoc_feed_campaigns_platform_code"
32
- END
33
- WHERE platform_code IS NULL;
34
- `);
35
-
36
- // 3. Enforce NOT NULL + default now that every row has a value.
37
- await queryInterface.changeColumn("rsoc_feed_campaigns", "platform_code", {
38
- type: Sequelize.ENUM("fb", "tt", "snp"),
39
- allowNull: false,
40
- defaultValue: "fb",
41
- comment: "Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
42
- });
43
-
44
- // 4. Index for filter performance.
45
- await queryInterface.addIndex("rsoc_feed_campaigns", ["platform_code"]);
46
- },
47
-
48
- down: async (queryInterface) => {
49
- await queryInterface.removeIndex("rsoc_feed_campaigns", ["platform_code"]);
50
- await queryInterface.removeColumn("rsoc_feed_campaigns", "platform_code");
51
- await queryInterface.sequelize.query(
52
- 'DROP TYPE IF EXISTS "enum_rsoc_feed_campaigns_platform_code";'
53
- );
54
- },
55
- };
1
+ "use strict";
2
+
3
+ /**
4
+ * rsoc_feed_campaigns normalization (Phase 1):
5
+ * - Add canonical `platform_code` ENUM column ('fb' | 'tt' | 'snp').
6
+ * - Backfill from legacy VARCHAR `platform` column using case-insensitive mapping.
7
+ * - Keep legacy `platform` column untouched (dropped in a follow-up plan).
8
+ *
9
+ * Mapping (case-insensitive on legacy `platform`):
10
+ * facebook | fb -> fb
11
+ * tiktok | tt -> tt
12
+ * snapchat | snap | snp -> snp
13
+ * else -> fb (safe default)
14
+ */
15
+ module.exports = {
16
+ up: async (queryInterface, Sequelize) => {
17
+ // 1. Add the new column as nullable so we can backfill before enforcing NOT NULL.
18
+ await queryInterface.addColumn("rsoc_feed_campaigns", "platform_code", {
19
+ type: Sequelize.ENUM("fb", "tt", "snp"),
20
+ allowNull: true,
21
+ comment: "Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
22
+ });
23
+
24
+ // 2. Backfill from legacy `platform` column (idempotent on platform_code IS NULL).
25
+ await queryInterface.sequelize.query(`
26
+ UPDATE "rsoc_feed_campaigns"
27
+ SET platform_code = CASE
28
+ WHEN LOWER(platform) IN ('facebook', 'fb') THEN 'fb'::"enum_rsoc_feed_campaigns_platform_code"
29
+ WHEN LOWER(platform) IN ('tiktok', 'tt') THEN 'tt'::"enum_rsoc_feed_campaigns_platform_code"
30
+ WHEN LOWER(platform) IN ('snapchat', 'snap', 'snp') THEN 'snp'::"enum_rsoc_feed_campaigns_platform_code"
31
+ ELSE 'fb'::"enum_rsoc_feed_campaigns_platform_code"
32
+ END
33
+ WHERE platform_code IS NULL;
34
+ `);
35
+
36
+ // 3. Enforce NOT NULL + default now that every row has a value.
37
+ await queryInterface.changeColumn("rsoc_feed_campaigns", "platform_code", {
38
+ type: Sequelize.ENUM("fb", "tt", "snp"),
39
+ allowNull: false,
40
+ defaultValue: "fb",
41
+ comment: "Canonical ad platform identifier: fb=Facebook, tt=TikTok, snp=Snapchat",
42
+ });
43
+
44
+ // 4. Index for filter performance.
45
+ await queryInterface.addIndex("rsoc_feed_campaigns", ["platform_code"]);
46
+ },
47
+
48
+ down: async (queryInterface) => {
49
+ await queryInterface.removeIndex("rsoc_feed_campaigns", ["platform_code"]);
50
+ await queryInterface.removeColumn("rsoc_feed_campaigns", "platform_code");
51
+ await queryInterface.sequelize.query(
52
+ 'DROP TYPE IF EXISTS "enum_rsoc_feed_campaigns_platform_code";'
53
+ );
54
+ },
55
+ };
@@ -1,16 +1,16 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- up: async (queryInterface) => {
5
- await queryInterface.addIndex("AdPerformance", ["platform", "Date"], {
6
- name: "AdPerformance_platform_Date_idx",
7
- });
8
- },
9
-
10
- down: async (queryInterface) => {
11
- await queryInterface.removeIndex(
12
- "AdPerformance",
13
- "AdPerformance_platform_Date_idx"
14
- );
15
- },
16
- };
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ up: async (queryInterface) => {
5
+ await queryInterface.addIndex("AdPerformance", ["platform", "Date"], {
6
+ name: "AdPerformance_platform_Date_idx",
7
+ });
8
+ },
9
+
10
+ down: async (queryInterface) => {
11
+ await queryInterface.removeIndex(
12
+ "AdPerformance",
13
+ "AdPerformance_platform_Date_idx"
14
+ );
15
+ },
16
+ };
@@ -1,16 +1,16 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- up: async (queryInterface) => {
5
- await queryInterface.addIndex("AdSetPerformance", ["platform", "Date"], {
6
- name: "AdSetPerformance_platform_Date_idx",
7
- });
8
- },
9
-
10
- down: async (queryInterface) => {
11
- await queryInterface.removeIndex(
12
- "AdSetPerformance",
13
- "AdSetPerformance_platform_Date_idx"
14
- );
15
- },
16
- };
1
+ "use strict";
2
+
3
+ module.exports = {
4
+ up: async (queryInterface) => {
5
+ await queryInterface.addIndex("AdSetPerformance", ["platform", "Date"], {
6
+ name: "AdSetPerformance_platform_Date_idx",
7
+ });
8
+ },
9
+
10
+ down: async (queryInterface) => {
11
+ await queryInterface.removeIndex(
12
+ "AdSetPerformance",
13
+ "AdSetPerformance_platform_Date_idx"
14
+ );
15
+ },
16
+ };
@@ -1,36 +1,36 @@
1
- "use strict";
2
-
3
- /**
4
- * Additive migration: add review_status + pending_review_since to Ad.
5
- *
6
- * Used by SnapchatStrategy.updateAd to optimistically flip an ad to
7
- * PENDING_REVIEW immediately after editing copy/URL fields (brand_name,
8
- * headline, url, landing_page_url) — Snapchat resends those ads to review
9
- * upstream, and we want the UI to reflect that without waiting for the
10
- * next status sync cycle.
11
- *
12
- * Backward compatible — both columns nullable, no default value, no
13
- * destructive operations.
14
- */
15
-
16
- module.exports = {
17
- up: async (queryInterface, Sequelize) => {
18
- await queryInterface.addColumn("Ad", "review_status", {
19
- type: Sequelize.STRING,
20
- allowNull: true,
21
- comment:
22
- "Local review status mirror (e.g. PENDING_REVIEW after copy/URL edit on Snap). Cleared by status sync.",
23
- });
24
- await queryInterface.addColumn("Ad", "pending_review_since", {
25
- type: Sequelize.DATE,
26
- allowNull: true,
27
- comment:
28
- "Timestamp when ad was optimistically flipped to PENDING_REVIEW after a triggering edit. Cleared when upstream review settles.",
29
- });
30
- },
31
-
32
- down: async (queryInterface) => {
33
- await queryInterface.removeColumn("Ad", "pending_review_since");
34
- await queryInterface.removeColumn("Ad", "review_status");
35
- },
36
- };
1
+ "use strict";
2
+
3
+ /**
4
+ * Additive migration: add review_status + pending_review_since to Ad.
5
+ *
6
+ * Used by SnapchatStrategy.updateAd to optimistically flip an ad to
7
+ * PENDING_REVIEW immediately after editing copy/URL fields (brand_name,
8
+ * headline, url, landing_page_url) — Snapchat resends those ads to review
9
+ * upstream, and we want the UI to reflect that without waiting for the
10
+ * next status sync cycle.
11
+ *
12
+ * Backward compatible — both columns nullable, no default value, no
13
+ * destructive operations.
14
+ */
15
+
16
+ module.exports = {
17
+ up: async (queryInterface, Sequelize) => {
18
+ await queryInterface.addColumn("Ad", "review_status", {
19
+ type: Sequelize.STRING,
20
+ allowNull: true,
21
+ comment:
22
+ "Local review status mirror (e.g. PENDING_REVIEW after copy/URL edit on Snap). Cleared by status sync.",
23
+ });
24
+ await queryInterface.addColumn("Ad", "pending_review_since", {
25
+ type: Sequelize.DATE,
26
+ allowNull: true,
27
+ comment:
28
+ "Timestamp when ad was optimistically flipped to PENDING_REVIEW after a triggering edit. Cleared when upstream review settles.",
29
+ });
30
+ },
31
+
32
+ down: async (queryInterface) => {
33
+ await queryInterface.removeColumn("Ad", "pending_review_since");
34
+ await queryInterface.removeColumn("Ad", "review_status");
35
+ },
36
+ };