boardinghouse.backends.postgres.schema module¶
-
class
boardinghouse.backends.postgres.schema.
DatabaseSchemaEditor
(connection, collect_sql=False, atomic=True)[source]¶ Bases:
django.db.backends.postgresql.schema.DatabaseSchemaEditor
This Schema Editor alters behaviour in three ways.
- Remove duplicates of deferred sql statements. These are executed using self.execute() anyway, so they will get applied to all schemata as appropriate.
- Fire a signal during self.execute() so that listeners may choose to apply this statement to all schemata. This signal only fires for objects that are private objects.
- Change the mechanism for grabbing constraint names to also look in the template schema (instead of just public, as is hard-coded in the original method).
-
boardinghouse.backends.postgres.schema.
get_constraints
(cursor, table_name, schema_name=None)[source]¶ Return all constraints for a given table
This function looks in the settings.PUBLIC_SCHEMA, and the supplied schema (defaulting to __template__ if none supplied) for all constraints that exist on the provided table name. The assumption is made that the same table will not exist in both schemata: if so, and the constraints differ between the two tables in any way, then the union of constraints will be returned.
This is an improvement on the django implementation in two ways: it runs in a single query, rather than three. It also allows for a different schema than public, which is hardcoded.