Fork of github.com/did-method-plc/did-method-plc
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add missing index on (did, createdAt) (#58)

* Add index on (did, createdAt)

* rename

* style

authored by

Daniel Holmgren and committed by
GitHub
47675375 f8d26845

+25 -8
+11 -8
packages/server/service/index.js
··· 6 6 const main = async () => { 7 7 const version = process.env.PLC_VERSION 8 8 const dbCreds = JSON.parse(process.env.DB_CREDS_JSON) 9 - const dbMigrateCreds = JSON.parse(process.env.DB_MIGRATE_CREDS_JSON) 10 9 const dbSchema = process.env.DB_SCHEMA || undefined 11 - // Migrate using credentialed user 12 - const migrateDb = Database.postgres({ 13 - url: pgUrl(dbMigrateCreds), 14 - schema: dbSchema, 15 - }) 16 - await migrateDb.migrateToLatestOrThrow() 17 - await migrateDb.close() 10 + const enableMigrations = process.env.ENABLE_MIGRATIONS === 'true' 11 + if (enableMigrations) { 12 + const dbMigrateCreds = JSON.parse(process.env.DB_MIGRATE_CREDS_JSON) 13 + // Migrate using credentialed user 14 + const migrateDb = Database.postgres({ 15 + url: pgUrl(dbMigrateCreds), 16 + schema: dbSchema, 17 + }) 18 + await migrateDb.migrateToLatestOrThrow() 19 + await migrateDb.close() 20 + } 18 21 // Use lower-credentialed user to run the app 19 22 const db = Database.postgres({ 20 23 url: pgUrl(dbCreds),
+13
packages/server/src/migrations/20231128T203323431Z-did-createdat-idx.ts
··· 1 + import { Kysely } from 'kysely' 2 + 3 + export async function up(db: Kysely<unknown>): Promise<void> { 4 + await db.schema 5 + .createIndex('operations_did_createdat_idx') 6 + .on('operations') 7 + .columns(['did', 'createdAt']) 8 + .execute() 9 + } 10 + 11 + export async function down(db: Kysely<unknown>): Promise<void> { 12 + await db.schema.dropIndex('operations_did_createdat_idx').execute() 13 + }
+1
packages/server/src/migrations/index.ts
··· 5 5 export * as _20221020T204908820Z from './20221020T204908820Z-operations-init' 6 6 export * as _20230223T215019669Z from './20230223T215019669Z-refactor' 7 7 export * as _20230406T174552885Z from './20230406T174552885Z-did-locks' 8 + export * as _20231128T203323431Z from './20231128T203323431Z-did-createdat-idx'