Skip to content

create_all failing with data type bigint has no default operator class for access method "gist" #44

@tomthorogood

Description

@tomthorogood

I am trying to integrate my application with postgresql-audit, but when my tests run sqlalchemy's create_all on our test database instance, I get the following error:

E       sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedObject) data type bigint has no default operator class for access method "gist"
E       HINT:  You must specify an operator class for the index or define a default operator class for the data type.
E       
E       [SQL: 
E       CREATE TABLE transaction (
E               id BIGSERIAL NOT NULL, 
E               native_transaction_id BIGINT, 
E               issued_at TIMESTAMP WITHOUT TIME ZONE, 
E               client_addr INET, 
E               PRIMARY KEY (id), 
E               CONSTRAINT transaction_unique_native_tx_id EXCLUDE USING gist (native_transaction_id WITH =, tsrange(issued_at - INTERVAL '1 hour', issued_at) WITH &&)
E       )
E       
E       ]
E       (Background on this error at: http://sqlalche.me/e/f405)

I made sure that our test DB is creating the btree_gist extension:

@pytest.fixture(scope='session', autouse=True)
def database(db_proc, _app_with_context):
    """
    Create a Postgres database for the tests, and drop it when the tests are done.
    """
    jan = janitor.DatabaseJanitor(DB_USER, DB_HOST, DB_PORT, DB_NAME, DB_VERSION)
    jan.init()
    app.db.session.execute('CREATE EXTENSION IF NOT EXISTS btree_gist')  # This exectes
    app.db.create_all()  # This fails with the above error
    yield
    jan.drop()

There is no mention of any additional requirements in the README for this package, so I'm not sure what could be wrong. It feels like every audit history plugin is a dead end, and I was really hopeful this would provide a solution for us.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions