Skip to content

Commit

Permalink
add graphql query to get storage squid package version
Browse files Browse the repository at this point in the history
  • Loading branch information
zeeshanakram3 committed Jan 15, 2024
1 parent 7ca5a1c commit 18516d4
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ lib
# Autogenerated stuff
src/types
src/model/generated
db/migrations/*.js
db/migrations/*-Data.js
schema.graphql
/db/export
/db/export
13 changes: 0 additions & 13 deletions db/migrations/1702466370902-Operator.js

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions db/migrations/2100000000000-Indexes.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module.exports = class Indexes2000000000000 {
name = 'Indexes2000000000000'
module.exports = class Indexes2100000000000 {
name = 'Indexes2100000000000'

async up(db) {
await db.query(`CREATE INDEX "events_type" ON "event" USING BTREE (("data"->>'isTypeOf'));`)
await db.query(`CREATE INDEX "events_dataObjectId" ON "event" USING BTREE (("data"->>'dataObjectId'));`)
await db.query(
`CREATE INDEX "events_dataObjectId" ON "event" USING BTREE (("data"->>'dataObjectId'));`
)
}

async down(db) {
Expand Down
29 changes: 29 additions & 0 deletions db/migrations/2200000000000-Operator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const fs = require('fs')
const path = require('path')

module.exports = class Operator2200000000000 {
name = 'Operator2200000000000'

async up(db) {
// Path to your package.json file
const packageJsonPath = path.join(__dirname, '../../package.json')

// Read the package.json file synchronously
const data = fs.readFileSync(packageJsonPath, 'utf8')

// Parse the JSON data
const packageJson = JSON.parse(data)

await db.query(
`INSERT INTO "squid_version" ("id", "version")
VALUES ('${packageJson.name}' ,'${packageJson.version}');`
)

// Create pg_stat_statements extension for analyzing query stats
await db.query(`CREATE EXTENSION pg_stat_statements;`)
}

async down(db) {
await db.query(`DROP EXTENSION pg_stat_statements;`)
}
}
4 changes: 4 additions & 0 deletions schema/misc.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type SquidVersion @entity {
"Current version of the storage squid package"
version: String!
}

0 comments on commit 18516d4

Please sign in to comment.