Mike,
fist of all thank you a lot for your answers - it works for me now,
but I found issue case (it was necessary to test more thoroughly and describe the libraries, I use latest sqlalchemy and alembic)
so problem was when I had UniqueConstraint instead of PrimaryKeyConstraint.
# UniqueConstraint case NOK
outputs = Table(
"outputs",
de_db.metadata,
Column("id", sa.BIGINT, autoincrement=True, nullable=False),
Column("run_id", sa.Integer, nullable=False),
Column("hotel", Integer, nullable=False),
# sa.PrimaryKeyConstraint("id", "hotel", "run_id"),
UniqueConstraint('id', 'hotel', 'run_id'),
)
NOK ->
CREATE TABLE outputs (
id BIGINT NOT NULL,
run_id INTEGER NOT NULL,
hotel INTEGER NOT NULL,
UNIQUE (id, hotel, run_id)
)
# PrimaryKeyConstraint OK
outputs = Table(
"outputs",
de_db.metadata,
Column("id", sa.BIGINT, autoincrement=True, nullable=False),
Column("run_id", sa.Integer, nullable=False),
Column("hotel", Integer, nullable=False),
sa.PrimaryKeyConstraint("id", "hotel", "run_id"),
# UniqueConstraint('id', 'hotel', 'run_id'),
)
OK ->
CREATE TABLE outputs (
id BIGSERIAL NOT NULL,
run_id INTEGER NOT NULL,
hotel INTEGER NOT NULL,
PRIMARY KEY (id, hotel, run_id)
)
But anyway, your example with custom type works independently from anything, as expected:
class BIGSERIAL(sa.types.UserDefinedType):
def get_col_spec(self, *args, **kwargs):
return "BIGSERIAL"
outputs = Table(
"outputs",
de_db.metadata,
Column("id", BIGSERIAL, nullable=False),
)
OK ->
CREATE TABLE outputs (
id BIGSERIAL NOT NULL
thanks again for the solution,
Pavel
среда, 30 сентября 2020 г. в 16:56:50 UTC+4, Mike Bayer: