[ 
https://issues.apache.org/jira/browse/AIRFLOW-3138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16647785#comment-16647785
 ] 

ASF GitHub Bot commented on AIRFLOW-3138:
-----------------------------------------

ashb closed pull request #3985: [AIRFLOW-3138] Use current data type for 
migrations
URL: https://github.com/apache/incubator-airflow/pull/3985
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/airflow/migrations/versions/cc1e65623dc7_add_max_tries_column_to_task_instance.py
 
b/airflow/migrations/versions/cc1e65623dc7_add_max_tries_column_to_task_instance.py
index 6155a40c81..03195a7536 100644
--- 
a/airflow/migrations/versions/cc1e65623dc7_add_max_tries_column_to_task_instance.py
+++ 
b/airflow/migrations/versions/cc1e65623dc7_add_max_tries_column_to_task_instance.py
@@ -29,7 +29,6 @@
 import sqlalchemy as sa
 from airflow import settings
 from airflow.models import DagBag
-from airflow.utils.sqlalchemy import UtcDateTime
 
 from sqlalchemy import Column, Integer, String
 from sqlalchemy.engine.reflection import Inspector
@@ -51,7 +50,7 @@ class TaskInstance(Base):
 
     task_id = Column(String(ID_LEN), primary_key=True)
     dag_id = Column(String(ID_LEN), primary_key=True)
-    execution_date = Column(UtcDateTime, primary_key=True)
+    execution_date = Column(sa.DateTime, primary_key=True)
     max_tries = Column(Integer)
     try_number = Column(Integer, default=0)
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Migration cc1e65623dc7 creates issues with postgres
> ---------------------------------------------------
>
>                 Key: AIRFLOW-3138
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-3138
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: db
>    Affects Versions: 1.10.0
>            Reporter: M Noronha
>            Priority: Major
>             Fix For: 1.10.1
>
>
> When trying to upgrade from 1.8.0 to 1.10.0, migration 
> cc1e65623dc7_add_max_tries_column_to_task_instance.py results in error:
> sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table 'task_instance' 
> expected to update 1 row(s); 0 were matched.
> That's due to a datatype mismatch between the database (TIMESTAMP before 
> migration 0e2a74e0fc9f) and the UtcDateTime.
> Changing 
> 55c54
> < execution_date = Column(UtcDateTime, primary_key=True)
> ---
> > execution_date = Column(sa.DateTime(), primary_key=True)
> Seems to be enough to work in postgres. This also works in sqlite.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to