[GH-ISSUE #255] initial "syncdb --migrate" not working on PostgreSQL #240

Closed
opened 2026-02-27 11:10:45 +03:00 by kerem · 5 comments
Owner

Originally created by @tonioo on GitHub (Dec 4, 2013).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/255

Originally assigned to: @tonioo on GitHub.

Originally created by Hervé Cauwelier on 2012-05-26T20:51:29Z

Hi,

I'm trying Modoboa but I can't install it.

Here is my configuration:

Cython==0.16
Django==1.3.1
South==0.7.5
django-ckeditorfiles==1.0
ipdb==0.6.1
ipython==0.12.1
lxml==2.3.4
psycopg2==2.4.5
py-rrdtool==0.2.1
pycrypto==2.6
sievelib==0.4
wsgiref==0.1.2

I first followed INSTALL but I got an error, see "first syncdb.txt" for the traceback and "first syncdb postgresql log.txt".

I then determined PostgreSQL was not recovering from a DatabaseError as you expected so I patched admin/init.py.

See "db_table_exists.patch", the "db_table_exists" functions comes from here: https://gist.github.com/527113/307c2dec09ceeb647b8fa1d6d49591f3352cb034

But then, as the migrations were running smoothly, it failed again, see "second syncdb.txt" and "second syncdb postgresql log.txt".

I continue looking for the cause of the error but your lights are welcome.

Originally created by @tonioo on GitHub (Dec 4, 2013). Original GitHub issue: https://github.com/modoboa/modoboa/issues/255 Originally assigned to: @tonioo on GitHub. **Originally created by Hervé Cauwelier on 2012-05-26T20:51:29Z** Hi, I'm trying Modoboa but I can't install it. Here is my configuration: Cython==0.16 Django==1.3.1 South==0.7.5 django-ckeditorfiles==1.0 ipdb==0.6.1 ipython==0.12.1 lxml==2.3.4 psycopg2==2.4.5 py-rrdtool==0.2.1 pycrypto==2.6 sievelib==0.4 wsgiref==0.1.2 I first followed INSTALL but I got an error, see "first syncdb.txt" for the traceback and "first syncdb postgresql log.txt". I then determined PostgreSQL was not recovering from a DatabaseError as you expected so I patched admin/**init**.py. See "db_table_exists.patch", the "db_table_exists" functions comes from here: https://gist.github.com/527113/307c2dec09ceeb647b8fa1d6d49591f3352cb034 But then, as the migrations were running smoothly, it failed again, see "second syncdb.txt" and "second syncdb postgresql log.txt". I continue looking for the cause of the error but your lights are welcome.
kerem 2026-02-27 11:10:45 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@tonioo commented on GitHub (Dec 4, 2013):

Posted by Antoine Nguyen on 2012-05-27T07:26:42Z

Hi, thanks for your feedback.

I've already encountered the first issue in a previous version. I'm not a postgres user and it's true I haven't tested that Modoboa works with it for a while :p

Anyway, the 'db_table_exists' function is already available into Modoboa (see lib/dbutils.py). The second issue is different, I need to investigate.

<!-- gh-comment-id:29815197 --> @tonioo commented on GitHub (Dec 4, 2013): **Posted by Antoine Nguyen on 2012-05-27T07:26:42Z** Hi, thanks for your feedback. I've already encountered the first issue in a previous version. I'm not a postgres user and it's true I haven't tested that Modoboa works with it for a while :p Anyway, the 'db_table_exists' function is already available into Modoboa (see lib/dbutils.py). The second issue is different, I need to investigate.
Author
Owner

@tonioo commented on GitHub (Dec 4, 2013):

Posted by Antoine Nguyen on 2012-05-27T09:12:47Z

Applied in changeset commit:4eb8e69b3c28.

<!-- gh-comment-id:29815200 --> @tonioo commented on GitHub (Dec 4, 2013): **Posted by Antoine Nguyen on 2012-05-27T09:12:47Z** Applied in changeset commit:4eb8e69b3c28.
Author
Owner

@tonioo commented on GitHub (Dec 4, 2013):

Posted by Antoine Nguyen on 2012-05-27T09:13:23Z

Can you confirm this fix is working for you?

<!-- gh-comment-id:29815201 --> @tonioo commented on GitHub (Dec 4, 2013): **Posted by Antoine Nguyen on 2012-05-27T09:13:23Z** Can you confirm this fix is working for you?
Author
Owner

@tonioo commented on GitHub (Dec 4, 2013):

Posted by Hervé Cauwelier on 2012-05-27T14:00:47Z

Thanks, changing the migration worked. But I wonder why it would not work for me. Could it be a regression in South 0.7.5?

I applied a slightly different patch to admin/init.py:

diff --git a/modoboa/admin/init.py b/modoboa/admin/init.py
index f5581eb..73f3bec 100644
--- a/modoboa/admin/init.py
+++ b/modoboa/admin/init.py
@@ -1,6 +1,7 @@

-- coding: utf-8 --

from modoboa.lib import parameters, events
+from modoboa.lib.dbutils import db_table_exists
from django.utils.translation import ugettext as _, ugettext_lazy
from django.db.utils import DatabaseError
from models import Extension
@@ -41,11 +42,9 @@ def enabled_applications():
:return: a list
"""
result = [("admin", "admin"), ("userprefs", "userprefs")]

  • try:

  • if db_table_exists("admin_extension"):
    exts = Extension.objects.filter(enabled=True)
    result += [(ext.name, ext.name) for ext in exts]

  • except DatabaseError:

  •    pass
    

    return sorted(result, key=lambda e: e[0])

    parameters.register_admin("DEFAULT_TOP_REDIRECTION", type="list", deflt="admin",

I don't like imports inside functions (expect for circular imports), and I prefer not to ignore any DatabaseError that are now legitimate.

<!-- gh-comment-id:29815202 --> @tonioo commented on GitHub (Dec 4, 2013): **Posted by Hervé Cauwelier on 2012-05-27T14:00:47Z** Thanks, changing the migration worked. But I wonder why it would not work for me. Could it be a regression in South 0.7.5? I applied a slightly different patch to admin/**init**.py: diff --git a/modoboa/admin/**init**.py b/modoboa/admin/**init**.py index f5581eb..73f3bec 100644 --- a/modoboa/admin/**init**.py +++ b/modoboa/admin/**init**.py @@ -1,6 +1,7 @@ # -_\- coding: utf-8 -_- from modoboa.lib import parameters, events +from modoboa.lib.dbutils import db_table_exists from django.utils.translation import ugettext as _, ugettext_lazy from django.db.utils import DatabaseError from models import Extension @@ -41,11 +42,9 @@ def enabled_applications(): :return: a list """ result = [("admin", "admin"), ("userprefs", "userprefs")] - try: - if db_table_exists("admin_extension"): exts = Extension.objects.filter(enabled=True) result += [(ext.name, ext.name) for ext in exts] - except DatabaseError: - ``` pass ``` return sorted(result, key=lambda e: e[0]) parameters.register_admin("DEFAULT_TOP_REDIRECTION", type="list", deflt="admin", I don't like imports inside functions (expect for circular imports), and I prefer not to ignore any DatabaseError that are now legitimate.
Author
Owner

@tonioo commented on GitHub (Dec 4, 2013):

Posted by Antoine Nguyen on 2012-05-27T17:56:32Z

You're right, I can remove the exception catching now.

About the import statement, as we are inside a init.py file, it is better to keep it inside the function to avoid a potential circular import.

<!-- gh-comment-id:29815203 --> @tonioo commented on GitHub (Dec 4, 2013): **Posted by Antoine Nguyen on 2012-05-27T17:56:32Z** You're right, I can remove the exception catching now. About the import statement, as we are inside a **init**.py file, it is better to keep it inside the function to avoid a potential circular import.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#240
No description provided.