public inbox for [email protected]  
help / color / mirror / Atom feed
From: Célestin Matte <[email protected]>
To: [email protected]
To: Magnus Hagander <[email protected]>
Subject: Re: [PATCHES] pgarchives: merge schema.sql into Django's model
Date: Wed, 22 Mar 2023 10:32:00 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

Adding a patch to this series to fix an issue with this migration: default value set in django is not taken account in load_messages.py because django's ORM is not used there, which leads to crashes.

On 03/02/2022 14:30, Célestin Matte wrote:
> As discussed in previous threads before [1, 2], database creations file are currently split between the Django model and a SQL file. Discrepancy in the database's definition exists between them. As a consequence, the database cannot be created easily.
> This series of patches merge schema.sql into Django's model, and adds specific postgres components that cannot be handled by Django's ORM using RunSQL() in a migration file.
> 
> Please also note that I integrated several other patches to avoid multiple migration files:
> - I allowed message.parentid to be null, as discussed in [1]. This can cause Internal Server Errors in views.py, which are fixed by the second patch.
> - I used BinaryFields for bytea columns (message.rawtxt and attachments.attachment), which seems to be the way to integrate bytea into Django
> 
> It may be a good opportunity to remove all mentions of pg_dict, pg_stop and associated file. I'm not sure of the consequences of this. According to [2], these are the remains of an aborted idea.
> Also, what does tsparer bring? Can the installation of pgarchives be simplified by replacing it with pg_catalog.english?
> 
> 
> [1]: https://www.postgresql.org/message-id/CABUevEyFpYPEHh0AAyTAsgymRKOOVA1SY_pDHPCbBQQ9BawfTA%40mail.gma...
> [2]: https://www.postgresql.org/message-id/CABUevEy_i1xAKscMv4KZ0%3DbE8050bBcQfWaNyjwZZBofZx7JgQ%40mail.g...

-- 
Célestin Matte


Attachments:

  [text/x-patch] 0003-Bugfix-set-a-default-value-for-loaderror-column-dat.patch (1.4K, 2-0003-Bugfix-set-a-default-value-for-loaderror-column-dat.patch)
  download | inline diff:
From 3e365324fdb718afa614ee39c5cfb590955b9a4c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9lestin=20Matte?= <[email protected]>
Date: Wed, 22 Mar 2023 10:25:41 +0100
Subject: [PATCH 3/3] Bugfix: set a default value for loaderror column "dat"

A default value for this column is set in django with auto_now_add, but this
default is not taken into account when django's ORM is not used, such as in
load_message.py, which leads to crashes
---
 django/archives/mailarchives/migrations/0005_merge_schema.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/django/archives/mailarchives/migrations/0005_merge_schema.py b/django/archives/mailarchives/migrations/0005_merge_schema.py
index b5ce31f..ef38743 100644
--- a/django/archives/mailarchives/migrations/0005_merge_schema.py
+++ b/django/archives/mailarchives/migrations/0005_merge_schema.py
@@ -100,6 +100,7 @@ class Migration(migrations.Migration):
         migrations.RunSQL("CREATE UNIQUE INDEX idx_unresolved_msgid_message ON unresolved_messages(msgid, message);"),
         migrations.RunSQL("CREATE INDEX list_threads_listid_idx ON list_threads(listid);"),
         migrations.RunSQL("CREATE INDEX idx_attachments_msg ON attachments(message);"),
+        migrations.RunSQL("ALTER TABLE loaderrors ALTER COLUMN dat SET DEFAULT NOW();"),
         migrations.RunSQL("""
 CREATE TEXT SEARCH CONFIGURATION pg (COPY = pg_catalog.english);
 
-- 
2.39.2



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: [PATCHES] pgarchives: merge schema.sql into Django's model
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox