Skip to content

Commit abd1560

Browse files
committed
Fix unique constraint error on ccc_changes_unique_index2 when deposits are included in a block
1 parent c222511 commit abd1560

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"use strict";
2+
3+
const TABLE_NAME = "CCCChanges";
4+
module.exports = {
5+
up: async (queryInterface, _Sequelize) => {
6+
await queryInterface.removeIndex(
7+
TABLE_NAME,
8+
"ccc_changes_unique_index2"
9+
);
10+
await queryInterface.addIndex(
11+
TABLE_NAME,
12+
["address", "blockNumber", "reason"],
13+
{
14+
unique: true,
15+
name: "ccc_changes_unique_index2",
16+
where: {
17+
reason: [
18+
"author",
19+
"stake",
20+
"initial_distribution",
21+
"validator"
22+
]
23+
}
24+
}
25+
);
26+
},
27+
down: async (queryInterface, _Sequelize) => {
28+
await queryInterface.removeIndex(
29+
TABLE_NAME,
30+
"ccc_changes_unique_index2"
31+
);
32+
await queryInterface.addIndex(
33+
TABLE_NAME,
34+
["address", "blockNumber", "reason"],
35+
{
36+
unique: true,
37+
name: "ccc_changes_unique_index2",
38+
where: {
39+
reason: [
40+
"author",
41+
"stake",
42+
"initial_distribution",
43+
"deposit",
44+
"validator"
45+
]
46+
}
47+
}
48+
);
49+
}
50+
};

0 commit comments

Comments
 (0)