question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

superset db upgrade returns foreign key constraint is incorrectly formed

See original GitHub issue

superset db upgrade returns foreign key constraint is incorrectly formed. here is the log:

sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1005, 'Can\'t create table `apache_superset`.`tab_state` (errno: 150 "Foreign key constraint is incorrectly formed")')
[SQL: 
CREATE TABLE tab_state (
	created_on DATETIME, 
	changed_on DATETIME, 
	extra_json TEXT, 
	id INTEGER NOT NULL AUTO_INCREMENT, 
	user_id INTEGER, 
	label VARCHAR(256), 
	active BOOL, 
	database_id INTEGER, 
	`schema` VARCHAR(256), 
	`sql` TEXT, 
	query_limit INTEGER, 
	latest_query_id VARCHAR(11), 
	autorun BOOL NOT NULL, 
	template_params TEXT, 
	created_by_fk INTEGER, 
	changed_by_fk INTEGER, 
	PRIMARY KEY (id), 
	FOREIGN KEY(changed_by_fk) REFERENCES ab_user (id), 
	FOREIGN KEY(created_by_fk) REFERENCES ab_user (id), 
	FOREIGN KEY(database_id) REFERENCES dbs (id), 
	FOREIGN KEY(latest_query_id) REFERENCES query (client_id), 
	FOREIGN KEY(user_id) REFERENCES ab_user (id), 
	CHECK (active IN (0, 1)), 
	CHECK (autorun IN (0, 1))
)

]
(Background on this error at: http://sqlalche.me/e/e3q8)

Expected results

what you expected to happen.

Actual results

what actually happens.

Screenshots

If applicable, add screenshots to help explain your problem.

How to reproduce the bug

  1. Go to ‘…’
  2. Click on ‘…’
  3. Scroll down to ‘…’
  4. See error

Environment

(please complete the following information):

  • superset version: superset version
  • python version: python --version
  • node.js version: node -v
  • npm version: npm -v

Checklist

Make sure these boxes are checked before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven’t found one similar.

Additional context

Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:22 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
issue-label-bot[bot]commented, Dec 11, 2019

Issue-Label Bot is automatically applying the label #bug to this issue, with a confidence of 0.93. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

0reactions
gregmazurcommented, Mar 19, 2021

SHOW CREATE TABLE query; check the charset Also might be useful for someone "mysql+pymysql://user:pass@host:3306/db?charset=<your query table charset>

Read more comments on GitHub >

github_iconTop Results From Across the Web

superset db upgrade returns foreign key constraint is ... - GitHub
superset db upgrade returns foreign key constraint is incorrectly formed. here is the log: sqlalchemy.exc.OperationalError: (MySQLdb.
Read more >
subject:"\[GitHub\] \[incubator\-superset\] digitalfox ... - The Mail Archive
[GitHub] [incubator-superset] digitalfox commented on issue #8808: superset db upgrade returns foreign key constraint is incorrectly formed.
Read more >
mysql Foreign key constraint is incorrectly formed error
For anyone facing this problem, just run SHOW ENGINE INNODB STATUS and see the LATEST FOREIGN KEY ERROR section ...
Read more >
MySQL FOREIGN KEY constraint is incorrectly formed
Both the referencing and referenced columns must be of the same type (and same in this case includes the unsigned attribute).
Read more >
Frequently Asked Questions - Apache Superset
Superset acts as a thin layer above your underlying databases or data engines. As mentioned above, the main criteria is whether your database...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found