diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2020-04-15 02:20:46 -0700 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-04-17 11:57:24 +0200 |
| commit | 75410228dfd16e49eb3c0ea30b59b4c0d2ea6b03 (patch) | |
| tree | cb9e6532b57cf60f8eaebcb3860241094e6a5588 /django/core/management/sql.py | |
| parent | 8005829bb9d9e0a14d73c9375bb55eb05daa46e1 (diff) | |
Fixed #31473 -- Made sql_flush() use RESTART IDENTITY to reset sequences on PostgreSQL.
The sql_flush() positional argument sequences is replaced by the boolean
keyword-only argument reset_sequences. This ensures that the old
function signature can't be used by mistake when upgrading Django. When
the new argument is True, the sequences of the truncated tables will
reset. Using a single boolean value, rather than a list, allows making a
binary yes/no choice as to whether to reset all sequences rather than a
working on a completely different set.
Diffstat (limited to 'django/core/management/sql.py')
| -rw-r--r-- | django/core/management/sql.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/core/management/sql.py b/django/core/management/sql.py index 0d54f9b220..27113dbbbe 100644 --- a/django/core/management/sql.py +++ b/django/core/management/sql.py @@ -13,8 +13,12 @@ def sql_flush(style, connection, only_django=False, reset_sequences=True, allow_ tables = connection.introspection.django_table_names(only_existing=True, include_views=False) else: tables = connection.introspection.table_names(include_views=False) - seqs = connection.introspection.sequence_list() if reset_sequences else () - return connection.ops.sql_flush(style, tables, seqs, allow_cascade) + return connection.ops.sql_flush( + style, + tables, + reset_sequences=reset_sequences, + allow_cascade=allow_cascade, + ) def emit_pre_migrate_signal(verbosity, interactive, db, **kwargs): |
