diff --git a/CHANGELOG.md b/CHANGELOG.md index 050f3a5..b5ba679 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project attempts to adhere to [Semantic Versioning](https://semver.org/ ## [Unreleased] +### Fixed + +- Migration 0002 was not being applied to the `default` database, which is the norm when running the relay in Docker. + ## [0.2.0] **This release involves migrations.** Please read below for more information. diff --git a/src/email_relay/migrations/0002_auto_20231030_1304.py b/src/email_relay/migrations/0002_auto_20231030_1304.py index 4f279e5..fcd19d5 100644 --- a/src/email_relay/migrations/0002_auto_20231030_1304.py +++ b/src/email_relay/migrations/0002_auto_20231030_1304.py @@ -2,8 +2,6 @@ from django.db import migrations -from email_relay.conf import EMAIL_RELAY_DATABASE_ALIAS - def migrate_message_data_to_new_schema(apps, schema_editor): """Migrate the JSON data from the old schema to the new schema. @@ -20,9 +18,6 @@ def migrate_message_data_to_new_schema(apps, schema_editor): - "extra_headers" - "alternatives" """ - if schema_editor.connection.alias != EMAIL_RELAY_DATABASE_ALIAS: - return - Message = apps.get_model("email_relay", "Message") for message in Message.objects.all(): diff --git a/tests/test_migrations.py b/tests/test_migrations.py index 646f348..7705ba6 100644 --- a/tests/test_migrations.py +++ b/tests/test_migrations.py @@ -61,47 +61,3 @@ class MockSchemaEditor: assert message.data["alternatives"] == [ ["

HTML

", "text/html"], ] - - -@pytest.mark.django_db(databases=["default", EMAIL_RELAY_DATABASE_ALIAS]) -def test_migrate_message_data_to_new_schema_default_not_applied( - migrate_message_data_to_new_schema, -): - class MockSchemaEditor: - connection = connections["default"] - - baker.make( - "email_relay.Message", - data={ - "message": "Here is the message.", - "recipient_list": ["to@example.com"], - "html_message": "

HTML

", - }, - _quantity=3, - ) - - for message in Message.objects.all(): - assert message.data["message"] == "Here is the message." - assert message.data["recipient_list"] == ["to@example.com"] - assert message.data["html_message"] == "

HTML

" - assert not message.data.get("to") - assert not message.data.get("cc") - assert not message.data.get("bcc") - assert not message.data.get("reply_to") - assert not message.data.get("extra_headers") - assert not message.data.get("alternatives") - - migrate_message_data_to_new_schema(apps, MockSchemaEditor()) - - assert Message.objects.count() == 3 - - for message in Message.objects.all(): - assert message.data["message"] == "Here is the message." - assert message.data["recipient_list"] == ["to@example.com"] - assert message.data["html_message"] == "

HTML

" - assert not message.data.get("to") - assert not message.data.get("cc") - assert not message.data.get("bcc") - assert not message.data.get("reply_to") - assert not message.data.get("extra_headers") - assert not message.data.get("alternatives")