-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MySQL: Staat stil op: "Stats: Missing consumption data for: ..." #909
- Loading branch information
1 parent
d6900a6
commit fb62707
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Generated by Django 3.0.3 on 2020-03-03 18:24 | ||
|
||
from django.db import migrations, connection | ||
from django.utils.translation import ugettext_lazy | ||
|
||
|
||
def migrate_forward(apps, schema_editor): | ||
import dsmr_frontend.services | ||
|
||
if connection.vendor != 'mysql': | ||
return | ||
|
||
with connection.cursor() as cursor: | ||
cursor.execute("SELECT 1 FROM mysql.time_zone_name LIMIT 1") | ||
|
||
if cursor.rowcount > 0: | ||
return | ||
|
||
Notification = apps.get_model('dsmr_frontend', 'Notification') | ||
Notification.objects.create( | ||
message=dsmr_frontend.services.get_translated_string(text=ugettext_lazy( | ||
'You are using a MySQL database without timezone support. This may cause bugs. Please enable timezone ' | ||
'support in your database, see: https://dev.mysql.com/doc/refman/en/mysql-tzinfo-to-sql.html' | ||
)) | ||
) | ||
|
||
|
||
def migrate_backward(apps, schema_editor): | ||
pass | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
operations = [ | ||
migrations.RunPython(migrate_forward, migrate_backward), | ||
] | ||
|
||
dependencies = [ | ||
('dsmr_frontend', '0033_django_colorfield_update'), | ||
] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters