I'm on my last hurdle with implementing Alembic with our SqlAlchemy models,
and the issue is I can't get Alembic to implement my id column with
BIGSERIAL, it always defaults to SERIAL. I implemented a TypeDecorator on
each of the primary key columns that I want to be BIGSERIAL, the
implementation is below. Note that I need to work with SQLLITE for in
memory tests that run which is why i'm using a decorator. From looking at
the source code in base.py for postgres, this should work. However, when I
set a print statement in the source where you do check (as below), it
appears that the impl_type is BIGINT and falls through to SERIAL.
if isinstance(impl_type, sqltypes.BigInteger):
colspec += " BIGSERIAL"
elif isinstance(impl_type, sqltypes.SmallInteger):
colspec += " SMALLSERIAL"
else:
colspec += " SERIAL"
from sqlalchemy.types import (
TypeDecorator, CHAR, Numeric, Float,
Integer, BigInteger)
class SafeBigInteger(Types.TypeDecorator):
impl = BigInteger
def load_dialect_impl(self, dialect):
if dialect.name == 'postgresql':
return dialect.type_descriptor(BigInteger)
else:
return dialect.type_descriptor(Integer)
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.