Changeset 6013
- Timestamp:
- 08/25/07 14:32:30 (1 year ago)
- Files:
-
- django/trunk/django/core/management/commands/flush.py (modified) (1 diff)
- django/trunk/django/core/management/commands/sqlflush.py (modified) (1 diff)
- django/trunk/django/core/management/sql.py (modified) (2 diffs)
- django/trunk/docs/django-admin.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management/commands/flush.py
r5903 r6013 25 25 pass 26 26 27 sql_list = sql_flush(self.style )27 sql_list = sql_flush(self.style, only_django=True) 28 28 29 29 if interactive: django/trunk/django/core/management/commands/sqlflush.py
r5903 r6013 8 8 def handle_noargs(self, **options): 9 9 from django.core.management.sql import sql_flush 10 return '\n'.join(sql_flush(self.style ))10 return '\n'.join(sql_flush(self.style, only_django=True)) django/trunk/django/core/management/sql.py
r5980 r6013 13 13 cursor = connection.cursor() 14 14 return get_introspection_module().get_table_list(cursor) 15 16 def django_table_list(only_existing=False): 17 """ 18 Returns a list of all table names that have associated Django models and 19 are in INSTALLED_APPS. 20 21 If only_existing is True, the resulting list will only include the tables 22 that actually exist in the database. 23 """ 24 from django.db import models 25 tables = [] 26 for app in models.get_apps(): 27 for model in models.get_models(app): 28 tables.append(model._meta.db_table) 29 tables.extend([f.m2m_db_table() for f in model._meta.many_to_many]) 30 if only_existing: 31 existing = table_list() 32 tables = [t for t in tables if t in existing] 33 return tables 15 34 16 35 def installed_models(table_list): … … 182 201 return sql_delete(app, style) + sql_all(app, style) 183 202 184 def sql_flush(style): 185 "Returns a list of the SQL statements used to flush the database." 203 def sql_flush(style, only_django=False): 204 """ 205 Returns a list of the SQL statements used to flush the database. 206 207 If only_django is True, then only table names that have associated Django 208 models and are in INSTALLED_APPS will be included. 209 """ 186 210 from django.db import connection 187 statements = connection.ops.sql_flush(style, table_list(), sequence_list()) 211 if only_django: 212 tables = django_table_list() 213 else: 214 tables = table_list() 215 statements = connection.ops.sql_flush(style, tables, sequence_list()) 188 216 return statements 189 217 django/trunk/docs/django-admin.txt
r5929 r6013 124 124 post-synchronization handlers will be re-executed, and the ``initial_data`` 125 125 fixture will be re-installed. 126 127 The behavior of this command has changed in the Django development version. 128 Previously, this command cleared *every* table in the database, including any 129 table that Django didn't know about (i.e., tables that didn't have associated 130 models and/or weren't in ``INSTALLED_APPS``). Now, the command only clears 131 tables that are represented by Django models and are activated in 132 ``INSTALLED_APPS``. 126 133 127 134 inspectdb … … 241 248 runfcgi [options] 242 249 ----------------- 250 243 251 Starts a set of FastCGI processes suitable for use with any web server 244 252 which supports the FastCGI protocol. See the `FastCGI deployment … … 338 346 339 347 sqlclear [appname appname ...] 340 ------------------------------ --------348 ------------------------------ 341 349 342 350 Prints the DROP TABLE SQL statements for the given appnames. … … 361 369 Note that the order in which the SQL files are processed is undefined. 362 370 371 sqlflush 372 -------- 373 374 Prints the SQL statements that would be executed for the `flush`_ command. 375 363 376 sqlindexes [appname appname ...] 364 -------------------------------- --------377 -------------------------------- 365 378 366 379 Prints the CREATE INDEX SQL statements for the given appnames. 367 380 368 381 sqlreset [appname appname ...] 382 ------------------------------ 383 384 Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given appnames. 385 386 sqlsequencereset [appname appname ...] 369 387 -------------------------------------- 370 371 Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given appnames.372 373 sqlsequencereset [appname appname ...]374 ----------------------------------------------375 388 376 389 Prints the SQL statements for resetting sequences for the given
