ergo / ziggurat_foundations

Framework agnostic set of sqlalchemy classes that make building applications that require permissions an easy task.
BSD 3-Clause "New" or "Revised" License
71 stars 22 forks source link

Unable to do initial alembic migration: fails on 'groups pkey change' #34

Closed mike-perdide closed 8 years ago

mike-perdide commented 8 years ago

Hi,

Using Python 3.5 in a virtualenv with the following distribs installed: mysqlclient==1.3.7 bcrypt==2.0.0 ziggurat_foundations==0.6.2 SQLAlchemy==1.0.12

I'm having an error when doing the initial alembic migration:

$ alembic upgrade head
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> 2bb1ba973f0b, initial table layout
[...]
INFO  [alembic.runtime.migration] Running upgrade 53927300c277 -> 3cfc41c4a5f0, groups pkey change
/home/mike/.virtualenvs/tiime-backend/lib/python3.5/site-packages/alembic/util/langhelpers.py:122: UserWarning: Argument 'cols' is now named 'columns' for method create_primary_key().
  oldname, newname, fn_name
Traceback (most recent call last):
  File "/home/mike/.virtualenvs/tiime-backend/lib/python3.5/site-packages/SQLAlchemy-1.0.12-py3.5.egg/sqlalchemy/engine/base.py", line 1139, in _execute_context
  File "/home/mike/.virtualenvs/tiime-backend/lib/python3.5/site-packages/SQLAlchemy-1.0.12-py3.5.egg/sqlalchemy/engine/default.py", line 450, in do_execute
  File "/home/mike/.virtualenvs/tiime-backend/lib/python3.5/site-packages/mysqlclient-1.3.7-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 226, in execute
    self.errorhandler(self, exc, value)
  File "/home/mike/.virtualenvs/tiime-backend/lib/python3.5/site-packages/mysqlclient-1.3.7-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorvalue
  File "/home/mike/.virtualenvs/tiime-backend/lib/python3.5/site-packages/mysqlclient-1.3.7-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 217, in execute
    res = self._query(query)
  File "/home/mike/.virtualenvs/tiime-backend/lib/python3.5/site-packages/mysqlclient-1.3.7-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
    rowcount = self._do_query(q)
  File "/home/mike/.virtualenvs/tiime-backend/lib/python3.5/site-packages/mysqlclient-1.3.7-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 341, in _do_query
    db.query(q)
  File "/home/mike/.virtualenvs/tiime-backend/lib/python3.5/site-packages/mysqlclient-1.3.7-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
    _mysql.connection.query(self, query)
_mysql_exceptions.OperationalError: (1833, "Cannot change column 'group_name': used in a foreign key constraint 'fk_groups_permissions_group_name_groups' of table 'testdb.groups_permissions'")

The DB I'm doing my test on was dropped and recreated prior to the test.

mike-perdide commented 8 years ago

Migration works fine on PostgreSQL database. Also, as seen in the main documentation page (sorry didn't properly read through), this project aims at postgresql. Sadly the project I'm working on is currently aimed to work with MySQL.

ergo commented 8 years ago

hey @mike-perdide - everything should be working on mysql too - right now I don't use any pg specific functionality that would disqualify mysql. This should be something easly fixable - I'll take a look. Not long ago all tests passed on mysql too.

ergo commented 8 years ago

@mike-perdide I've fixed migrations, my heart was bleeding when i was hacking the code but i worked around mysql issues. Migrations should work correctly now, can you try to use trunk version and confirm this is fixed for you?

mike-perdide commented 8 years ago

Works fine now! Thanks a lot! (my Mysql version is 5.6 by the way)