You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/09/30 11:14:34 UTC

[GitHub] [incubator-superset] dpgaspar opened a new pull request #11115: fix: alembic migration fails by deleting constraint on tables

dpgaspar opened a new pull request #11115:
URL: https://github.com/apache/incubator-superset/pull/11115


   ### SUMMARY
   Alembic migration fails with:
   
   ```
   INFO  [alembic.runtime.migration] Running upgrade e5ef6828ac4e -> 18532d70ab98, Delete table_name unique constraint in mysql
   (psycopg2.errors.UndefinedObject) constraint "table_name" of relation "tables" does not exist
   [SQL: ALTER TABLE tables DROP CONSTRAINT table_name]
   ```
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Changes UI
   - [ ] Requires DB Migration.
   - [ ] Confirm DB Migration upgrade and downgrade tested.
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] bkyryliuk commented on a change in pull request #11115: fix: alembic migration error msg trying to delete constraint on tables

Posted by GitBox <gi...@apache.org>.
bkyryliuk commented on a change in pull request #11115:
URL: https://github.com/apache/incubator-superset/pull/11115#discussion_r497630746



##########
File path: superset/migrations/versions/18532d70ab98_fix_table_unique_constraint_in_mysql.py
##########
@@ -27,16 +27,20 @@
 down_revision = "3fbbc6e8d654"
 
 from alembic import op
+from sqlalchemy.dialects.mysql.base import MySQLDialect
 
 
 def upgrade():
-    try:
+    bind = op.get_bind()
+    if isinstance(bind.dialect, MySQLDialect):
         # index only exists in mysql db
         with op.get_context().autocommit_block():
             op.drop_constraint("table_name", "tables", type_="unique")
-    except Exception as ex:
-        print(ex)
 
 
 def downgrade():
-    pass
+    bind = op.get_bind()
+    if isinstance(bind.dialect, MySQLDialect):
+        # index only exists in mysql db
+        with op.get_context().autocommit_block():
+            op.add_constraint("table_name", "tables", type_="unique")

Review comment:
       AttributeError: module 'alembic.op' has no attribute 'add_constraint'
   
   I would say - let's pass on the downgrade. That constraint was never needed




----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dpgaspar commented on pull request #11115: fix: alembic migration error msg trying to delete constraint on tables

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on pull request #11115:
URL: https://github.com/apache/incubator-superset/pull/11115#issuecomment-701467928


   > LGTM. I think this migration shows that we could do with some migration squashing for Superset 1.0, as there's obviously some divergence even between Postgres and MySQL.
   
   Totally!


----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] dpgaspar merged pull request #11115: fix: alembic migration error msg trying to delete constraint on tables

Posted by GitBox <gi...@apache.org>.
dpgaspar merged pull request #11115:
URL: https://github.com/apache/incubator-superset/pull/11115


   


----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org