Ticket #23030: spatialite_migrations_fix.patch

File spatialite_migrations_fix.patch, 1.2 KB (added by Lucio Asnaghi, 6 years ago)

This works with migrations

  • django/contrib/gis/db/backends/spatialite/schema.py

    a b  
    66    sql_add_spatial_index = "SELECT CreateSpatialIndex(%(table)s, %(column)s)"
    77    sql_drop_spatial_index = "DROP TABLE idx_%(table)s_%(column)s"
    88    sql_remove_geometry_metadata = "SELECT DiscardGeometryColumn(%(table)s, %(column)s)"
    9     sql_update_geometry_columns = "UPDATE geometry_columns SET f_table_name = %(new_table)s WHERE f_table_name = %(old_table)s"
    109
    1110    def __init__(self, *args, **kwargs):
    1211        super(SpatialiteSchemaEditor, self).__init__(*args, **kwargs)
     
    8685        if isinstance(field, GeometryField):
    8786            self.remove_geometry_metadata(model, field)
    8887        super(SpatialiteSchemaEditor, self).remove_field(model, field)
    89 
    90     def alter_db_table(self, model, old_db_table, new_db_table):
    91         super(SpatialiteSchemaEditor, self).alter_db_table(model, old_db_table, new_db_table)
    92         self.execute(
    93             self.sql_update_geometry_columns % {
    94                 "old_table": self.quote_name(old_db_table),
    95                 "new_table": self.quote_name(new_db_table),
    96             }
    97         )
Back to Top