django.contrib.postgres.operations 源代码

from django.contrib.postgres.signals import (
    get_citext_oids, get_hstore_oids, register_type_handlers,
)
from django.db.migrations.operations.base import Operation


[文档]class CreateExtension(Operation): reversible = True def __init__(self, name): self.name = name def state_forwards(self, app_label, state): pass def database_forwards(self, app_label, schema_editor, from_state, to_state): if schema_editor.connection.vendor != 'postgresql': return schema_editor.execute("CREATE EXTENSION IF NOT EXISTS %s" % schema_editor.quote_name(self.name)) # Clear cached, stale oids. get_hstore_oids.cache_clear() get_citext_oids.cache_clear() # Registering new type handlers cannot be done before the extension is # installed, otherwise a subsequent data migration would use the same # connection. register_type_handlers(schema_editor.connection) def database_backwards(self, app_label, schema_editor, from_state, to_state): schema_editor.execute("DROP EXTENSION %s" % schema_editor.quote_name(self.name)) # Clear cached, stale oids. get_hstore_oids.cache_clear() get_citext_oids.cache_clear() def describe(self): return "Creates extension %s" % self.name
[文档]class BtreeGinExtension(CreateExtension): def __init__(self): self.name = 'btree_gin'
[文档]class BtreeGistExtension(CreateExtension): def __init__(self): self.name = 'btree_gist'
[文档]class CITextExtension(CreateExtension): def __init__(self): self.name = 'citext'
[文档]class CryptoExtension(CreateExtension): def __init__(self): self.name = 'pgcrypto'
[文档]class HStoreExtension(CreateExtension): def __init__(self): self.name = 'hstore'
[文档]class TrigramExtension(CreateExtension): def __init__(self): self.name = 'pg_trgm'
[文档]class UnaccentExtension(CreateExtension): def __init__(self): self.name = 'unaccent'
Back to Top