Hi John -
"onupdate" is a Python side directive that does not impact the DDL of
the column as created in the database, so it is not relevant to the
ALTER TABLE directive. The equivalent to "server side ON UPDATE" for
Postgresql would be a database trigger which is out of scope here.
- mike
On 03/07/2017 02:17 PM, John Robson wrote:
Hi Mike, you did an awesome tool, thank you very much!!!
I started to use Alembic today, excellent tool, tutorial and
"autogenerate" option ;)
Up to now, everything is working well, except by this very small problem:
class:
created = Column(DateTime, server_default=func.now())
updated = Column(DateTime, server_default=func.now(), onupdate=func.now())
from: http://docs.sqlalchemy.org/en/latest/core/defaults.html
generated:
op.add_column('users', sa.Column('created', sa.DateTime(),
server_default=sa.text('now()'), nullable=True))
op.add_column('users', sa.Column('updated', sa.DateTime(),
server_default=sa.text('now()'), nullable=True))
postgresql table:
created timestamp without time zone DEFAULT now(),
updated timestamp without time zone DEFAULT now(),
None "onupdate" function was created, in PostgreSQL or SQLite databases.
But even the SQLalchemy won't create the function, it will generate the
same SQL than Alembic (in PostgreSQL).
Overall, this tool is very useful, saved my life!!!
Thank you again,
John
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.