diff -ruN django.branch/core/management.py django/core/management.py
old
|
new
|
|
273 | 273 | def get_sql_delete(app): |
274 | 274 | "Returns a list of the DROP TABLE SQL statements for the given app." |
275 | 275 | from django.db import backend, connection, models, get_introspection_module |
| 276 | from django.db.backends.util import truncate_name |
276 | 277 | introspection = get_introspection_module() |
277 | 278 | |
278 | 279 | # This should work even if a connecton isn't available |
… |
… |
|
319 | 320 | col = f.column |
320 | 321 | r_table = model._meta.db_table |
321 | 322 | r_col = model._meta.get_field(f.rel.field_name).column |
| 323 | r_name = '%s_refs_%s_%s_%s' % (col, r_col, table, r_table) |
322 | 324 | output.append('%s %s %s %s;' % \ |
323 | 325 | (style.SQL_KEYWORD('ALTER TABLE'), |
324 | 326 | style.SQL_TABLE(backend.quote_name(table)), |
325 | 327 | style.SQL_KEYWORD(backend.get_drop_foreignkey_sql()), |
326 | | style.SQL_FIELD(backend.quote_name('%s_refs_%s_%x' % (col, r_col, abs(hash((table, r_table)))))))) |
| 328 | style.SQL_FIELD(truncate_name(r_name, backend.get_max_name_length())))) |
327 | 329 | del references_to_delete[model] |
| 330 | if hasattr(backend, 'get_drop_sequence'): |
| 331 | output.append(backend.get_drop_sequence(model._meta.db_table)) |
328 | 332 | |
329 | 333 | # Output DROP TABLE statements for many-to-many tables. |
330 | 334 | for model in app_models: |
… |
… |
|
333 | 337 | if cursor and table_name_converter(f.m2m_db_table()) in table_names: |
334 | 338 | output.append("%s %s;" % (style.SQL_KEYWORD('DROP TABLE'), |
335 | 339 | style.SQL_TABLE(backend.quote_name(f.m2m_db_table())))) |
| 340 | if hasattr(backend, 'get_drop_sequence'): |
| 341 | output.append(backend.get_drop_sequence("%s_%s"%(model._meta.db_table, f.column))) |
336 | 342 | |
337 | 343 | app_label = app_models[0]._meta.app_label |
338 | 344 | |
diff -ruN django.branch/db/backends/oracle/base.py django/db/backends/oracle/base.py
old
|
new
|
|
144 | 144 | raise NotImplementedError |
145 | 145 | |
146 | 146 | def get_drop_foreignkey_sql(): |
147 | | return "DROP FOREIGN KEY" |
| 147 | return "DROP CONSTRAINT" |
148 | 148 | |
149 | 149 | def get_pk_default_value(): |
150 | 150 | return "DEFAULT" |
… |
… |
|
168 | 168 | END;\n""" % (tr_name, quote_name(table), sq_name) |
169 | 169 | return sequence_sql, trigger_sql |
170 | 170 | |
| 171 | def get_drop_sequence(table): |
| 172 | name_length = get_max_name_length() - 3 |
| 173 | sq_name = '%s_sq' % util.truncate_name(table, name_length) |
| 174 | drop_sequence_sql = 'DROP SEQUENCE %s;' % sq_name |
| 175 | return drop_sequence_sql |
| 176 | |
171 | 177 | OPERATOR_MAPPING = { |
172 | 178 | 'exact': '= %s', |
173 | 179 | 'iexact': "LIKE %s ESCAPE '\\'", |