diff options
| author | Aurélien Bompard | 2015-04-22 11:38:59 +0200 |
|---|---|---|
| committer | Aurélien Bompard | 2015-04-22 11:38:59 +0200 |
| commit | f198542db42e5532bdb1d6699832fa15e2e22e43 (patch) | |
| tree | c29ff99e4940442eea3135736d6133723c0f98fe /src/mailman/database/postgresql.py | |
| parent | 185198936bbcd45057f43241c70e45d5cdae818d (diff) | |
| download | mailman-f198542db42e5532bdb1d6699832fa15e2e22e43.tar.gz mailman-f198542db42e5532bdb1d6699832fa15e2e22e43.tar.zst mailman-f198542db42e5532bdb1d6699832fa15e2e22e43.zip | |
Diffstat (limited to 'src/mailman/database/postgresql.py')
| -rw-r--r-- | src/mailman/database/postgresql.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/mailman/database/postgresql.py b/src/mailman/database/postgresql.py index 9877f110d..e56ddaf38 100644 --- a/src/mailman/database/postgresql.py +++ b/src/mailman/database/postgresql.py @@ -24,6 +24,7 @@ __all__ = [ from mailman.database.base import SABaseDatabase from mailman.database.model import Model +from sqlalchemy import Integer @@ -42,8 +43,11 @@ class PostgreSQLDatabase(SABaseDatabase): # http://stackoverflow.com/questions/544791/ # django-postgresql-how-to-reset-primary-key for table in tables: - store.execute("""\ - SELECT setval('"{0}_id_seq"', coalesce(max("id"), 1), - max("id") IS NOT null) - FROM "{0}"; - """.format(table)) + for column in table.primary_key: + if column.autoincrement and isinstance(column.type, Integer) \ + and not column.foreign_keys: + store.execute("""\ + SELECT setval('"{0}_{1}_seq"', coalesce(max("{1}"), 1), + max("{1}") IS NOT null) + FROM "{0}"; + """.format(table, column.name)) |
