Skip to content

Commit

Permalink
fix: db views generation
Browse files Browse the repository at this point in the history
  • Loading branch information
zeeshanakram3 committed Jul 16, 2024
1 parent c49ecb7 commit 732ddc2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
7 changes: 7 additions & 0 deletions db/generateViewsMigration.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ module.exports = class ${className} {
name = '${className}'
async up(db) {
// these two queries will be invoked and the cleaned up by the squid itself
// we only do this to be able to reference processor height in mappings
await db.query(\`CREATE SCHEMA IF NOT EXISTS squid_processor;\`)
await db.query(\`CREATE TABLE IF NOT EXISTS squid_processor.status (
id SERIAL PRIMARY KEY,
height INT
);\`)
const viewDefinitions = getViewDefinitions(db);
for (const [tableName, viewConditions] of Object.entries(viewDefinitions)) {
if (Array.isArray(viewConditions)) {
Expand Down
13 changes: 0 additions & 13 deletions db/migrations/1719855101866-Data.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
module.exports = class Data1721051247791 {
name = 'Data1721051247791'
module.exports = class Data1721138354177 {
name = 'Data1721138354177'

async up(db) {
await db.query(`CREATE TABLE "admin"."user_interaction_count" ("id" character varying NOT NULL, "type" text, "entity_id" text, "day_timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "count" integer NOT NULL, CONSTRAINT "PK_8e334a51febcf02c54dff48147d" PRIMARY KEY ("id"))`)
await db.query(`CREATE INDEX "IDX_b5261af5f3fe48d77086ebc602" ON "admin"."user_interaction_count" ("day_timestamp") `)
await db.query(`CREATE TABLE "admin"."marketplace_token" ("liquidity" integer, "market_cap" numeric, "cumulative_revenue" numeric, "amm_volume" numeric, "price_change" numeric, "liquidity_change" numeric, "id" character varying NOT NULL, "status" character varying(6) NOT NULL, "avatar" jsonb, "total_supply" numeric NOT NULL, "is_featured" boolean NOT NULL, "symbol" text, "is_invite_only" boolean NOT NULL, "annual_creator_reward_permill" integer NOT NULL, "revenue_share_ratio_permill" integer NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "channel_id" text, "description" text, "whitelist_applicant_note" text, "whitelist_applicant_link" text, "accounts_num" integer NOT NULL, "number_of_revenue_share_activations" integer NOT NULL, "deissued" boolean NOT NULL, "current_amm_sale_id" text, "current_sale_id" text, "current_revenue_share_id" text, "number_of_vested_transfer_issued" integer NOT NULL, "last_price" numeric, CONSTRAINT "PK_d836a8c3d907b67099c140c4d84" PRIMARY KEY ("id"))`)
await db.query(`CREATE INDEX "IDX_1268fd020cf195b2e8d5d85093" ON "admin"."marketplace_token" ("symbol") `)
await db.query(`CREATE INDEX "IDX_b99bb1ecee77f23016f6ef687c" ON "admin"."marketplace_token" ("created_at") `)
}

async down(db) {
await db.query(`DROP TABLE "admin"."user_interaction_count"`)
await db.query(`DROP INDEX "admin"."IDX_b5261af5f3fe48d77086ebc602"`)
await db.query(`DROP TABLE "admin"."marketplace_token"`)
await db.query(`DROP INDEX "admin"."IDX_1268fd020cf195b2e8d5d85093"`)
await db.query(`DROP INDEX "admin"."IDX_b99bb1ecee77f23016f6ef687c"`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@

const { getViewDefinitions } = require('../viewDefinitions')

module.exports = class Views1721051247895 {
name = 'Views1721051247895'
module.exports = class Views1721138354291 {
name = 'Views1721138354291'

async up(db) {
// these two queries will be invoked and the cleaned up by the squid itself
// these two queries will be invoked and the cleaned up by the squid itself
// we only do this to be able to reference processor height in mappings
await db.query(`
CREATE SCHEMA IF NOT EXISTS squid_processor;
`)
await db.query(`CREATE SCHEMA IF NOT EXISTS squid_processor;`)
await db.query(`CREATE TABLE IF NOT EXISTS squid_processor.status (
id SERIAL PRIMARY KEY,
height INT
);`)

id SERIAL PRIMARY KEY,
height INT
);`)
const viewDefinitions = getViewDefinitions(db);
for (const [tableName, viewConditions] of Object.entries(viewDefinitions)) {
if (Array.isArray(viewConditions)) {
Expand Down

0 comments on commit 732ddc2

Please sign in to comment.