-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix-revenue-chart' into 'dev'
fix revenue chart See merge request ergo/rosen-bridge/watcher!207
- Loading branch information
Showing
8 changed files
with
227 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { WatcherMigration1700710099334 } from './postgres/1700710099334-watcherMigration'; | ||
import { WatcherMigration1703244656364 } from './postgres/1703244656364-watcherMigration'; | ||
import { WatcherMigration1700641198429 } from './sqlite/1700641198429-watcherMigration'; | ||
import { WatcherMigration1703244614956 } from './sqlite/1703244614956-watcherMigration'; | ||
|
||
export default { | ||
sqlite: [WatcherMigration1700641198429], | ||
postgres: [WatcherMigration1700710099334], | ||
sqlite: [WatcherMigration1700641198429, WatcherMigration1703244614956], | ||
postgres: [WatcherMigration1700710099334, WatcherMigration1703244656364], | ||
}; |
94 changes: 94 additions & 0 deletions
94
services/watcher/src/database/migrations/postgres/1703244656364-watcherMigration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class WatcherMigration1703244656364 implements MigrationInterface { | ||
name = 'WatcherMigration1703244656364'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
` | ||
DELETE FROM "typeorm_metadata" | ||
WHERE "type" = ? | ||
AND "name" = ? | ||
`, | ||
['VIEW', 'revenue_chart_data'] | ||
); | ||
await queryRunner.query(` | ||
DROP VIEW "revenue_chart_data" | ||
`); | ||
await queryRunner.query(` | ||
CREATE VIEW "revenue_chart_data" AS | ||
SELECT "pe"."WID" AS "wid", | ||
"be"."year" AS "year", | ||
"be"."month" AS "month", | ||
"be"."day" AS "day", | ||
re."tokenId" AS "tokenId", | ||
re."amount" AS "amount", | ||
be."timestamp" AS "timestamp" | ||
FROM "revenue_entity" "re" | ||
INNER JOIN "permit_entity" "pe" ON re."permitId" = "pe"."id" | ||
INNER JOIN "block_entity" "be" ON "pe"."block" = "be"."hash" | ||
`); | ||
await queryRunner.query( | ||
` | ||
INSERT INTO "typeorm_metadata"( | ||
"database", | ||
"schema", | ||
"table", | ||
"type", | ||
"name", | ||
"value" | ||
) | ||
VALUES (NULL, NULL, NULL, ?, ?, ?) | ||
`, | ||
[ | ||
'VIEW', | ||
'revenue_chart_data', | ||
'SELECT "pe"."WID" AS "wid", "be"."year" AS "year", "be"."month" AS "month", "be"."day" AS "day", re."tokenId" AS "tokenId", re."amount" AS "amount", be."timestamp" AS "timestamp" FROM "revenue_entity" "re" INNER JOIN "permit_entity" "pe" ON re."permitId" = "pe"."id" INNER JOIN "block_entity" "be" ON "pe"."block" = "be"."hash"', | ||
] | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
` | ||
DELETE FROM "typeorm_metadata" | ||
WHERE "type" = ? | ||
AND "name" = ? | ||
`, | ||
['VIEW', 'revenue_chart_data'] | ||
); | ||
await queryRunner.query(` | ||
DROP VIEW "revenue_chart_data" | ||
`); | ||
await queryRunner.query(` | ||
CREATE VIEW "revenue_chart_data" AS | ||
SELECT "be"."year" AS "year", | ||
"be"."month" AS "month", | ||
"be"."day" AS "day", | ||
re."tokenId" AS "tokenId", | ||
re."amount" AS "amount", | ||
be."timestamp" AS "timestamp" | ||
FROM "revenue_entity" "re" | ||
INNER JOIN "permit_entity" "pe" ON re."permitId" = "pe"."id" | ||
INNER JOIN "block_entity" "be" ON "pe"."block" = "be"."hash" | ||
`); | ||
await queryRunner.query( | ||
` | ||
INSERT INTO "typeorm_metadata"( | ||
"database", | ||
"schema", | ||
"table", | ||
"type", | ||
"name", | ||
"value" | ||
) | ||
VALUES (NULL, NULL, NULL, ?, ?, ?) | ||
`, | ||
[ | ||
'VIEW', | ||
'revenue_chart_data', | ||
'SELECT "be"."year" AS "year", "be"."month" AS "month", "be"."day" AS "day", re."tokenId" AS "tokenId", re."amount" AS "amount", be."timestamp" AS "timestamp" FROM "revenue_entity" "re" INNER JOIN "permit_entity" "pe" ON re."permitId" = "pe"."id" INNER JOIN "block_entity" "be" ON "pe"."block" = "be"."hash"', | ||
] | ||
); | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
services/watcher/src/database/migrations/sqlite/1703244614956-watcherMigration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class WatcherMigration1703244614956 implements MigrationInterface { | ||
name = 'WatcherMigration1703244614956'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
` | ||
DELETE FROM "typeorm_metadata" | ||
WHERE "type" = ? | ||
AND "name" = ? | ||
`, | ||
['VIEW', 'revenue_chart_data'] | ||
); | ||
await queryRunner.query(` | ||
DROP VIEW "revenue_chart_data" | ||
`); | ||
await queryRunner.query(` | ||
CREATE VIEW "revenue_chart_data" AS | ||
SELECT "pe"."WID" AS "wid", | ||
"be"."year" AS "year", | ||
"be"."month" AS "month", | ||
"be"."day" AS "day", | ||
re."tokenId" AS "tokenId", | ||
re."amount" AS "amount", | ||
be."timestamp" AS "timestamp" | ||
FROM "revenue_entity" "re" | ||
INNER JOIN "permit_entity" "pe" ON re."permitId" = "pe"."id" | ||
INNER JOIN "block_entity" "be" ON "pe"."block" = "be"."hash" | ||
`); | ||
await queryRunner.query( | ||
` | ||
INSERT INTO "typeorm_metadata"( | ||
"database", | ||
"schema", | ||
"table", | ||
"type", | ||
"name", | ||
"value" | ||
) | ||
VALUES (NULL, NULL, NULL, ?, ?, ?) | ||
`, | ||
[ | ||
'VIEW', | ||
'revenue_chart_data', | ||
'SELECT "pe"."WID" AS "wid", "be"."year" AS "year", "be"."month" AS "month", "be"."day" AS "day", re."tokenId" AS "tokenId", re."amount" AS "amount", be."timestamp" AS "timestamp" FROM "revenue_entity" "re" INNER JOIN "permit_entity" "pe" ON re."permitId" = "pe"."id" INNER JOIN "block_entity" "be" ON "pe"."block" = "be"."hash"', | ||
] | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
` | ||
DELETE FROM "typeorm_metadata" | ||
WHERE "type" = ? | ||
AND "name" = ? | ||
`, | ||
['VIEW', 'revenue_chart_data'] | ||
); | ||
await queryRunner.query(` | ||
DROP VIEW "revenue_chart_data" | ||
`); | ||
await queryRunner.query(` | ||
CREATE VIEW "revenue_chart_data" AS | ||
SELECT "be"."year" AS "year", | ||
"be"."month" AS "month", | ||
"be"."day" AS "day", | ||
re."tokenId" AS "tokenId", | ||
re."amount" AS "amount", | ||
be."timestamp" AS "timestamp" | ||
FROM "revenue_entity" "re" | ||
INNER JOIN "permit_entity" "pe" ON re."permitId" = "pe"."id" | ||
INNER JOIN "block_entity" "be" ON "pe"."block" = "be"."hash" | ||
`); | ||
await queryRunner.query( | ||
` | ||
INSERT INTO "typeorm_metadata"( | ||
"database", | ||
"schema", | ||
"table", | ||
"type", | ||
"name", | ||
"value" | ||
) | ||
VALUES (NULL, NULL, NULL, ?, ?, ?) | ||
`, | ||
[ | ||
'VIEW', | ||
'revenue_chart_data', | ||
'SELECT "be"."year" AS "year", "be"."month" AS "month", "be"."day" AS "day", re."tokenId" AS "tokenId", re."amount" AS "amount", be."timestamp" AS "timestamp" FROM "revenue_entity" "re" INNER JOIN "permit_entity" "pe" ON re."permitId" = "pe"."id" INNER JOIN "block_entity" "be" ON "pe"."block" = "be"."hash"', | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters