class TestTable(self.base): date = Column(types.Date, primary_key=True) x = Column(types.Int32) y = Column(types.String) version = Column(types.Int32) __table_args__ = (engines.ReplicatedReplacingMergeTree( '/table/path', 'name', version='version', partition_by='date', order_by=('date', 'x')), )
def patch_alembic_version(context, **kwargs): migration_context = context._proxy._migration_context version = migration_context._version dt = Column('dt', types.DateTime, server_default=func.now()) version_num = Column('version_num', types.String, primary_key=True) version.append_column(dt) version.append_column(version_num) if 'cluster' in kwargs: cluster = kwargs['cluster'] version.engine = engines.ReplicatedReplacingMergeTree( kwargs['table_path'], kwargs['replica_name'], version=dt, order_by=func.tuple()) version.kwargs['clickhouse_cluster'] = cluster else: version.engine = engines.ReplacingMergeTree(version=dt, order_by=func.tuple())