agrs-sequelize-sdk 1.2.86 → 1.2.88
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/models/CampaignCreationLog.js +31 -2
- package/models/MineChannel.js +43 -0
- package/package.json +1 -1
|
@@ -139,6 +139,16 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
139
139
|
allowNull: true,
|
|
140
140
|
comment: "Campaign domain",
|
|
141
141
|
},
|
|
142
|
+
page_id: {
|
|
143
|
+
type: DataTypes.UUID,
|
|
144
|
+
allowNull: true,
|
|
145
|
+
comment: "Facebook Page ID (UUID from Pages table)",
|
|
146
|
+
},
|
|
147
|
+
page_code: {
|
|
148
|
+
type: DataTypes.STRING(100),
|
|
149
|
+
allowNull: true,
|
|
150
|
+
comment: "Page code (unique identifier from Pages table)",
|
|
151
|
+
},
|
|
142
152
|
},
|
|
143
153
|
{
|
|
144
154
|
tableName: "CampaignCreationLogs",
|
|
@@ -151,7 +161,7 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
151
161
|
},
|
|
152
162
|
// JSON search optimization for account ID filtering
|
|
153
163
|
{
|
|
154
|
-
name: "idx_campaign_logs_details_gin",
|
|
164
|
+
name: "idx_campaign_logs_details_gin",
|
|
155
165
|
fields: ["details"],
|
|
156
166
|
using: "gin",
|
|
157
167
|
},
|
|
@@ -240,7 +250,17 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
240
250
|
{
|
|
241
251
|
name: "idx_campaign_logs_account_process",
|
|
242
252
|
fields: ["account_id", "process_id"],
|
|
243
|
-
comment: "For process-level account filtering v2"
|
|
253
|
+
comment: "For process-level account filtering v2",
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
name: "idx_campaign_logs_page_id",
|
|
257
|
+
fields: ["page_id"],
|
|
258
|
+
comment: "For page filtering",
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "idx_campaign_logs_page_code",
|
|
262
|
+
fields: ["page_code"],
|
|
263
|
+
comment: "For page code filtering",
|
|
244
264
|
},
|
|
245
265
|
{
|
|
246
266
|
fields: ["process_id"],
|
|
@@ -274,6 +294,15 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
274
294
|
constraints: false,
|
|
275
295
|
});
|
|
276
296
|
}
|
|
297
|
+
|
|
298
|
+
if (models.Pages) {
|
|
299
|
+
CampaignCreationLog.belongsTo(models.Pages, {
|
|
300
|
+
foreignKey: "page_code",
|
|
301
|
+
targetKey: "code",
|
|
302
|
+
as: "Page",
|
|
303
|
+
constraints: false,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
277
306
|
};
|
|
278
307
|
|
|
279
308
|
return CampaignCreationLog;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const MineChannel = sequelize.define(
|
|
3
|
+
"MineChannel",
|
|
4
|
+
{
|
|
5
|
+
channelId: {
|
|
6
|
+
type: DataTypes.STRING,
|
|
7
|
+
allowNull: false,
|
|
8
|
+
// Not setting as primary key or unique since duplicates are allowed
|
|
9
|
+
},
|
|
10
|
+
status: {
|
|
11
|
+
type: DataTypes.STRING,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
defaultValue: "free",
|
|
14
|
+
validate: {
|
|
15
|
+
isIn: [["free", "used", "archived"]],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
connectedCampaigns: {
|
|
19
|
+
type: DataTypes.JSONB, // Use JSONB for better querying capabilities
|
|
20
|
+
allowNull: false,
|
|
21
|
+
defaultValue: [],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
tableName: "mine_channels",
|
|
26
|
+
timestamps: true,
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// Define associations without enforcing constraints
|
|
31
|
+
MineChannel.associate = (models) => {
|
|
32
|
+
if (models.RSOCFeedCampaign) {
|
|
33
|
+
MineChannel.hasMany(models.RSOCFeedCampaign, {
|
|
34
|
+
foreignKey: "channelId",
|
|
35
|
+
sourceKey: "channelId",
|
|
36
|
+
as: "RSOCFeedCampaigns",
|
|
37
|
+
constraints: false, // Disable FK constraint
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return MineChannel;
|
|
43
|
+
};
|