From 24b07934ff0f7d55427b9561e5ab159fe53e7e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nu=C5=A1a=20Puk=C5=A1i=C4=8D?= Date: Sun, 5 Oct 2025 12:06:44 +0200 Subject: [PATCH] Migration, idxs --- migrations/Version20250927120000.php | 46 ++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 migrations/Version20250927120000.php diff --git a/migrations/Version20250927120000.php b/migrations/Version20250927120000.php new file mode 100644 index 0000000..2e51fb7 --- /dev/null +++ b/migrations/Version20250927120000.php @@ -0,0 +1,46 @@ +addSql('CREATE INDEX CONCURRENTLY IF NOT EXISTS IDX_EVENT_KIND ON event (kind)'); + + // Add composite index on event.kind and created_at for sorted magazine queries + $this->addSql('CREATE INDEX CONCURRENTLY IF NOT EXISTS IDX_EVENT_KIND_CREATED ON event (kind, created_at DESC)'); + + // Add index on article.slug for efficient article lookups + $this->addSql('CREATE INDEX CONCURRENTLY IF NOT EXISTS IDX_ARTICLE_SLUG ON article (slug)'); + + // Add index on event.pubkey for author-based queries + $this->addSql('CREATE INDEX CONCURRENTLY IF NOT EXISTS IDX_EVENT_PUBKEY ON event (pubkey)'); + + // Add GIN index on tags JSON column for efficient JSON queries + $this->addSql('CREATE INDEX CONCURRENTLY IF NOT EXISTS IDX_EVENT_TAGS_GIN ON event USING GIN (tags)'); + } + + public function down(Schema $schema): void + { + $this->addSql('DROP INDEX CONCURRENTLY IF EXISTS IDX_EVENT_KIND'); + $this->addSql('DROP INDEX CONCURRENTLY IF EXISTS IDX_EVENT_KIND_CREATED'); + $this->addSql('DROP INDEX CONCURRENTLY IF EXISTS IDX_ARTICLE_SLUG'); + $this->addSql('DROP INDEX CONCURRENTLY IF EXISTS IDX_EVENT_PUBKEY'); + $this->addSql('DROP INDEX CONCURRENTLY IF EXISTS IDX_EVENT_TAGS_GIN'); + } +}