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: