Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql key length #459

Merged
merged 2 commits into from
May 12, 2016
Merged

Mysql key length #459

merged 2 commits into from
May 12, 2016

Conversation

x4base
Copy link
Contributor

@x4base x4base commented May 11, 2016

Attempt to fix #449

@landscape-bot
Copy link

Code Health
Code quality remained the same when pulling d4c3ffa on x4base:mysql_key_length into 6c333d5 on airbnb:master.

@coveralls
Copy link

coveralls commented May 11, 2016

Coverage Status

Coverage remained the same at 81.627% when pulling d4c3ffa on x4base:mysql_key_length into 6c333d5 on airbnb:master.

@mistercrunch
Copy link
Member

Looks good, though I don't think you should alter the previous migration scripts.

@x4base
Copy link
Contributor Author

x4base commented May 12, 2016

For clean install, Alembic will iterate through all the migration scripts, from the oldest to the newest. If I don't alter the previous ones, The migration will crash on the very first migration script "4e6a06bad7a8_init.py" (see traceback below).
So I altered the previous scripts and created the new script because:

  1. For clean install: It prevents the migration from crashing.
  2. For those who are upgrading there existing SQLite: Alembic starts the iteration from the current version of the SQLite according to version_num in the alembic_versions table, so the previous migration scripts that I altered won't do any harm to the existing database.
    So I think it's ok to alter the previous ones.

Traceback:

caravel db upgrade head
....
INFO [alembic.runtime.migration] Running upgrade -> 4e6a06bad7a8, Init
Traceback (most recent call last):
File "/Users/clu/.pyenv/versions/druid/bin/caravel", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/projects/druid/panoramix/caravel/bin/caravel", line 113, in <module>
manager.run()
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/Flask_Script-2.0.5-py2.7.egg/flask_script/__init__.py", line 412, in run
result = self.handle(sys.argv[0], sys.argv[1:])
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/Flask_Script-2.0.5-py2.7.egg/flask_script/__init__.py", line 383, in handle
res = handle(*args, **config)
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/Flask_Script-2.0.5-py2.7.egg/flask_script/commands.py", line 216, in __call__
return self.run(*args, **kwargs)
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/Flask_Migrate-1.8.0-py2.7.egg/flask_migrate/__init__.py", line 235, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/alembic-0.8.5-py2.7.egg/alembic/command.py", line 174, in upgrade
script.run_env()
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/alembic-0.8.5-py2.7.egg/alembic/script/base.py", line 397, in run_env
util.load_python_file(self.dir, 'env.py')
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/alembic-0.8.5-py2.7.egg/alembic/util/pyfiles.py", line 81, in load_python_file
module = load_module_py(module_id, path)
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/alembic-0.8.5-py2.7.egg/alembic/util/compat.py", line 79, in load_module_py
mod = imp.load_source(module_id, path, fp)
File "/projects/druid/panoramix/caravel/migrations/env.py", line 91, in <module>
run_migrations_online()
File "/projects/druid/panoramix/caravel/migrations/env.py", line 84, in run_migrations_online
context.run_migrations()
File "<string>", line 8, in run_migrations
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/alembic-0.8.5-py2.7.egg/alembic/runtime/environment.py", line 797, in run_migrations
self.get_context().run_migrations(**kw)
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/alembic-0.8.5-py2.7.egg/alembic/runtime/migration.py", line 312, in run_migrations
step.migration_fn(* *kw)
File "/projects/druid/panoramix/caravel/migrations/versions/4e6a06bad7a8_init.py", line 71, in upgrade
sa.UniqueConstraint('datasource_name')
File "<string>", line 8, in create_table
File "<string>", line 3, in create_table
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/alembic-0.8.5-py2.7.egg/alembic/operations/ops.py", line 1098, in create_table
return operations.invoke(op)
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/alembic-0.8.5-py2.7.egg/alembic/operations/base.py", line 318, in invoke
return fn(self, operation)
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/alembic-0.8.5-py2.7.egg/alembic/operations/toimpl.py", line 101, in create_table
operations.impl.create_table(table)
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/alembic-0.8.5-py2.7.egg/alembic/ddl/impl.py", line 194, in create_table
self._exec(schema.CreateTable(table))
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/alembic-0.8.5-py2.7.egg/alembic/ddl/impl.py", line 118, in _exec
return conn.execute(construct, *multiparams, **params)
File "build/bdist.macosx-10.9-x86_64/egg/sqlalchemy/engine/base.py", line 914, in execute
File "build/bdist.macosx-10.9-x86_64/egg/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
File "build/bdist.macosx-10.9-x86_64/egg/sqlalchemy/engine/base.py", line 968, in _execute_ddl
File "build/bdist.macosx-10.9-x86_64/egg/sqlalchemy/engine/base.py", line 1146, in _execute_context
File "build/bdist.macosx-10.9-x86_64/egg/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
File "build/bdist.macosx-10.9-x86_64/egg/sqlalchemy/util/compat.py", line 200, in raise_from_cause
File "build/bdist.macosx-10.9-x86_64/egg/sqlalchemy/engine/base.py", line 1139, in _execute_context
File "build/bdist.macosx-10.9-x86_64/egg/sqlalchemy/engine/default.py", line 450, in do_execute
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/MySQLdb/cursors.py", line 226, in execute
self.errorhandler(self, exc, value)
File "/Users/clu/.pyenv/versions/druid/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorvalue
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1071, 'Specified key was too long; max key length is 767 bytes') [SQL: u'\nCREATE TABLE datasources (\n\tcreated_on DATETIME NOT NULL, \n\tchanged_on DATETIME NOT NULL, \n\tid INTEGER NOT NULL AUTO_INCREMENT, \n\tdatasource_name VARCHAR(256), \n\tis_featured BOOL, \n\tis_hidden BOOL, \n\tdescription TEXT, \n\tdefault_endpoint TEXT, \n\tuser_id INTEGER, \n\tcluster_name VARCHAR(250), \n\tcreated_by_fk INTEGER, \n\tchanged_by_fk INTEGER, \n\tPRIMARY KEY (id), \n\tUNIQUE (datasource_name), \n\tCHECK (is_featured IN (0, 1)), \n\tCHECK (is_hidden IN (0, 1)), \n\tFOREIGN KEY(user_id) REFERENCES ab_user (id), \n\tFOREIGN KEY(cluster_name) REFERENCES clusters (cluster_name), \n\tFOREIGN KEY(created_by_fk) REFERENCES ab_user (id), \n\tFOREIGN KEY(changed_by_fk) REFERENCES ab_user (id)\n)\n\n']

@mistercrunch
Copy link
Member

Ok, let's roll with it then!

@mistercrunch mistercrunch merged commit 5a870fe into apache:master May 12, 2016
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 17, 2021
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 24, 2021
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 25, 2021
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this pull request Nov 26, 2021
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.9.1 labels Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.9.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Key length limitation in Mysql
4 participants