Skip to content

Commit 8b0c80b

Browse files
committed
Add the migration script
1 parent 6dbdbfd commit 8b0c80b

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

src/migrations/20191118055749-create-asset-address-log.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
const networkId = require("config").get("codechain.networkId");
23
const tableName = "AssetAddressLogs";
34
module.exports = {
45
up: (queryInterface, DataTypes) => {
@@ -90,7 +91,39 @@ module.exports = {
9091
["transactionHash", "address", "assetType"],
9192
{ type: "unique" }
9293
)
93-
);
94+
)
95+
.then(() => {
96+
return queryInterface.sequelize.query(`
97+
INSERT INTO "${tableName}"
98+
(
99+
"transactionHash",
100+
"transactionTracker",
101+
"transactionType",
102+
"blockNumber",
103+
"transactionIndex",
104+
"isPending",
105+
"address",
106+
"assetType",
107+
"createdAt",
108+
"updatedAt"
109+
)
110+
SELECT
111+
"A"."transactionHash",
112+
"A"."transactionTracker",
113+
"A"."transactionType",
114+
"A"."blockNumber",
115+
"A"."transactionIndex",
116+
"A"."isPending",
117+
"address",
118+
"assetType",
119+
"A"."createdAt",
120+
"A"."updatedAt"
121+
FROM
122+
"AddressLogs" as "A" INNER JOIN "AssetTypeLogs" as "B"
123+
ON "A"."transactionHash" = "B"."transactionHash"
124+
WHERE address LIKE '${networkId}a%'
125+
`);
126+
});
94127
},
95128
down: (queryInterface, Sequelize) => {
96129
return queryInterface.dropTable(tableName, { force: true });

0 commit comments

Comments
 (0)