Skip to content

Commit

Permalink
feat(1.7): update pg_stat_extension if it is not of the correct version
Browse files Browse the repository at this point in the history
  • Loading branch information
uptickmetachu committed Jan 17, 2024
1 parent baf0a60 commit c232faa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ print(e.slowest.visualize(title=f"Fetching {url}"))

```

# TODO
- [ ] Add migration to ensure pg_stats_statement_info is correct
- [ ] Do not crash when its not available
- [ ] Add explain tab
= [ ] Add index suggester

# Disclaimer

Credit goes to Pierre Giraud (@pgiraud) for PEV2 and Alex Tatiyants (@AlexTatiyants) for the original pev tool.
Expand Down
24 changes: 24 additions & 0 deletions django_pev/migrations/0002_update_extension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.9 on 2024-01-17 03:19
import logging

from django.db import OperationalError, connection, migrations


def create_extension(apps, schema_editor):
try:
with connection.cursor() as cursor:
cursor.execute("select extversion from pg_extension where extname = 'pg_stat_statements'")
version = float(cursor.fetchone()[0])
if version < 1.9:
cursor.execute("alter extension pg_stat_statements update to '1.9'")
cursor.execute("alter extension pg_stat_statements update to '1.10'")
except OperationalError:
logging.error("Could not update extension `pg_stat_statements`.")


class Migration(migrations.Migration):
dependencies = [
("django_pev", "0001_enable_extensions"),
]

operations = []
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "django-pev"
version = "0.1.6"
version = "0.1.7"
description = "Context manager to upload explain plans to https://explain.dalibo.com/"
authors = ["william chu <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit c232faa

Please sign in to comment.