Skip to content

Commit

Permalink
feat(0.1.6): add migration to enable statements
Browse files Browse the repository at this point in the history
  • Loading branch information
uptickmetachu committed Jan 17, 2024
1 parent fd9c0b4 commit 9bab7b4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test: postgres
poetry run python manage.py test

publish: ci
# poetry config pypi-token.pypi your-api-token
poetry publish --build

ci: test lint
Expand Down
20 changes: 20 additions & 0 deletions django_pev/migrations/0001_enable_extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.9 on 2024-01-17 01:46
import logging

from django.db import OperationalError, connection, migrations


def create_extension(apps, schema_editor):
try:
with connection.cursor() as cursor:
cursor.execute("CREATE EXTENSION IF NOT EXISTS pg_stat_statements")
except OperationalError:
logging.error("Could not install extension `pg_stat_statements`.")


class Migration(migrations.Migration):
dependencies = []

operations = [
migrations.RunPython(create_extension, migrations.RunPython.noop),
]
4 changes: 4 additions & 0 deletions django_pev/templates/django_pev/queries.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<div>
<h4 class="card-title mb-0">Slow Queries</h4>
This page shows queries that consumed the most time in the database.
<p>
{% if not is_pg_stat_statements %}
<span class="bg-warning"> <b>PG Stat Statements extension is not enabled.</b></span>
{% endif %}
</div>
</div>
<nav>
Expand Down
1 change: 1 addition & 0 deletions example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_pev",
]

MIDDLEWARE = [
Expand Down
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.5"
version = "0.1.6"
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 9bab7b4

Please sign in to comment.