agrs-sequelize-sdk 1.2.61 → 1.2.63
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/Ad.js +5 -0
- package/models/FrontStoryChannel.js +55 -0
- package/package.json +1 -1
package/models/Ad.js
CHANGED
|
@@ -134,6 +134,11 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
134
134
|
{
|
|
135
135
|
fields: ["AdSetID"], // Index on AdSetID for faster join
|
|
136
136
|
},
|
|
137
|
+
{
|
|
138
|
+
name: "idx_ad_policy_agrs_cid_status",
|
|
139
|
+
fields: ["AGRS_CID", "policy_status"],
|
|
140
|
+
comment: "Critical index for policy filtering queries"
|
|
141
|
+
},
|
|
137
142
|
],
|
|
138
143
|
}
|
|
139
144
|
);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module.exports = (sequelize, DataTypes) => {
|
|
2
|
+
const FrontStoryChannel = sequelize.define(
|
|
3
|
+
"FrontStoryChannel",
|
|
4
|
+
{
|
|
5
|
+
channelId: {
|
|
6
|
+
type: DataTypes.STRING,
|
|
7
|
+
allowNull: false,
|
|
8
|
+
// Not setting as primary key or unique since duplicates are allowed
|
|
9
|
+
},
|
|
10
|
+
styleId: {
|
|
11
|
+
type: DataTypes.STRING,
|
|
12
|
+
allowNull: false,
|
|
13
|
+
},
|
|
14
|
+
status: {
|
|
15
|
+
type: DataTypes.STRING,
|
|
16
|
+
allowNull: false,
|
|
17
|
+
defaultValue: "free",
|
|
18
|
+
validate: {
|
|
19
|
+
isIn: [["free", "used", "archived"]],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
connectedCampaigns: {
|
|
23
|
+
type: DataTypes.JSONB, // Use JSONB for better querying capabilities
|
|
24
|
+
allowNull: false,
|
|
25
|
+
defaultValue: [],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
tableName: "front_story_channels",
|
|
30
|
+
timestamps: true,
|
|
31
|
+
indexes: [
|
|
32
|
+
// Add a composite unique index on channelId and styleId if needed
|
|
33
|
+
{
|
|
34
|
+
unique: true,
|
|
35
|
+
fields: ["channelId", "styleId"],
|
|
36
|
+
name: "unique_channel_style",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// Define associations without enforcing constraints
|
|
43
|
+
FrontStoryChannel.associate = (models) => {
|
|
44
|
+
if (models.RSOCFeedCampaign) {
|
|
45
|
+
FrontStoryChannel.hasMany(models.RSOCFeedCampaign, {
|
|
46
|
+
foreignKey: "channelId",
|
|
47
|
+
sourceKey: "channelId",
|
|
48
|
+
as: "RSOCFeedCampaigns",
|
|
49
|
+
constraints: false, // Disable FK constraint
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return FrontStoryChannel;
|
|
55
|
+
};
|