[damned-lies] Convert Vertimus tables to utf8mb4 charset
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Convert Vertimus tables to utf8mb4 charset
- Date: Sat, 5 Aug 2017 14:25:03 +0000 (UTC)
commit 1a880ae78b35e75647a025fd0c89d31f206ef827
Author: Claude Paroz <claude 2xlibre net>
Date: Sat Aug 5 16:06:45 2017 +0200
Convert Vertimus tables to utf8mb4 charset
This adds 4-bytes unicode support on MySQL, combined with the DATABASES
OPTIONS setting 'charset': 'utf8mb4'.
Fixes bug #780227.
vertimus/migrations/0004_tables_to_utf8mb4.py | 25 +++++++++++++++++++++++++
vertimus/tests/tests.py | 2 +-
2 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/vertimus/migrations/0004_tables_to_utf8mb4.py b/vertimus/migrations/0004_tables_to_utf8mb4.py
new file mode 100644
index 0000000..68882e4
--- /dev/null
+++ b/vertimus/migrations/0004_tables_to_utf8mb4.py
@@ -0,0 +1,25 @@
+from django.db import migrations
+
+
+def to_utf8mb4(apps, schema_editor):
+ if not schema_editor.connection.vendor == 'mysql':
+ return
+ tables = [
+ apps.get_model("vertimus", "Action")._meta.db_table,
+ apps.get_model("vertimus", "ActionArchived")._meta.db_table,
+ apps.get_model("vertimus", "State")._meta.db_table,
+ ]
+ for table_name in tables:
+ schema_editor.execute(
+ 'ALTER TABLE %s CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci' % table_name,
+ params=None
+ )
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('vertimus', '0003_add_action_sent_to_ml'),
+ ]
+
+ operations = [migrations.RunPython(to_utf8mb4, migrations.RunPython.noop, atomic=False)]
diff --git a/vertimus/tests/tests.py b/vertimus/tests/tests.py
index 3e78079..d024229 100644
--- a/vertimus/tests/tests.py
+++ b/vertimus/tests/tests.py
@@ -243,7 +243,7 @@ class VertimusTest(TeamsAndRolesTests):
prev_updated = state.updated
action = Action.new_by_name('WC', person=self.pt)
- action.apply_on(state, {'send_to_ml': action.send_mail_to_ml, 'comment': "Hi!"})
+ action.apply_on(state, {'send_to_ml': action.send_mail_to_ml, 'comment': "Hi 😉"})
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].recipients(), [self.l.team.get_coordinators()[0].email])
self.assertEqual(mail.outbox[0].extra_headers, {settings.EMAIL_HEADER_NAME: 'Inactive'})
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]