Skip to content

Instantly share code, notes, and snippets.

View matheusmb's full-sized avatar
🏠
Working from home

Matheus Müller Borges matheusmb

🏠
Working from home
  • Some cool place in the world
View GitHub Profile
# Support timezone field
Use func.now() to support timezone as utctime.now doesn't has this info
Note: postgress always store in UTC time and send the converted timezone value according to client configurations `-c timezone=America/Sao_Paulo`
`date_created = db.Column(db.DateTime(timezone=True), nullable=True, default=func.now())`
# Column default value server_side
Use `server_default`, useful when running migrations that creates non-nullable columns
```
op.add_column(
'execution_orders', sa.Column('total', sa.Integer(), nullable=False, server_default='0')