You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/05/29 17:01:12 UTC

[GitHub] [airflow] deodeveloper commented on a change in pull request #5255: [AIRFLOW-4462] Fix incorrect datetime column types when using MSSQL backend

deodeveloper commented on a change in pull request #5255: [AIRFLOW-4462] Fix incorrect datetime column types when using MSSQL backend
URL: https://github.com/apache/airflow/pull/5255#discussion_r288671746
 
 

 ##########
 File path: airflow/migrations/versions/464861dc0797_change_execution_date_from_datetime_to_.py
 ##########
 @@ -0,0 +1,294 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""change execution_date from datetime to datetime2(6) for mssql
+
+Revision ID: 464861dc0797
+Revises: 939bb1e647c8
+Create Date: 2019-05-07 10:43:08.610996
+
+"""
+
+from alembic import op
+from sqlalchemy.dialects import mssql
+from collections import defaultdict
+
+# revision identifiers, used by Alembic.
+revision = '464861dc0797'
+down_revision = '939bb1e647c8'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+    conn = op.get_bind()
+    if conn.dialect.name == "mssql":
+        result = conn.execute(
+            """SELECT CASE WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion'))
+            like '8%' THEN '2000' WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('productversion'))
+            like '9%' THEN '2005' ELSE '2005Plus' END AS MajorVersion""").fetchone()
+        mssql_version = result[0]
+        if mssql_version in ("2000", "2005"):
+            return
+
+        with op.batch_alter_table('task_reschedule') as task_reschedule_batch_op:
+            task_reschedule_batch_op.drop_index('idx_task_reschedule_dag_task_date')
+
+            task_reschedule_batch_op.drop_constraint(
 
 Review comment:
   Yes, we are recreating this at line no. 79.
   https://github.com/apache/airflow/pull/5255/files/09b22e97e1fdb4e7bdca0d31ccb766e8a2079ccb#diff-e887f8103d940732ec15b84a92f1dfdfR79
   

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


With regards,
Apache Git Services