Closed josephmc5 closed 9 years ago
Updated the error to include more.
I've isolated the cause of the error. organization.id is a bigint but the FK in organizationmember gets created as an int. When the alter statement to create the constraint gets called MySQL fails because the two columns are a different type.
sentry_organization
CREATE TABLE `sentry_organization` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
`owner_id` int(11) NOT NULL,
`status` int(10) unsigned NOT NULL,
`date_added` datetime NOT NULL,
PRIMARY KEY (`id`)
)
sentry_organizationmember
CREATE TABLE `sentry_organizationmember` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`organization_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`type` int(10) unsigned NOT NULL,
`date_added` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `sentry_organizationmember_organization_id_404770fc5e3a794_uniq` (`organization_id`,`user_id`)
)
Running migrations for sentry:
- Migrating forwards to 0148_auto__add_helppage.
> sentry:0131_auto__add_organizationmember__add_unique_organizationmember_organizati
= SET FOREIGN_KEY_CHECKS=0; []
= CREATE TABLE `sentry_organizationmember` (`id` bigint AUTO_INCREMENT NOT NULL PRIMARY KEY, `organization_id` integer NOT NULL, `user_id` integer NOT NULL, `type` integer UNSIGNED NOT NULL, `date_added` datetime NOT NULL) []
= ALTER TABLE `sentry_organizationmember` ADD CONSTRAINT `sentry_organizationmember_organization_id_404770fc5e3a794_uniq` UNIQUE (`organization_id`, `user_id`) []
= CREATE TABLE `sentry_organization` (`id` bigint AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(64) NOT NULL, `owner_id` integer NOT NULL, `status` integer UNSIGNED NOT NULL, `date_added` datetime NOT NULL) []
= ALTER TABLE `sentry_team` ADD COLUMN `organization_id` integer NULL; []
- no dry run output for alter_column() due to dynamic DDL, sorry
= ALTER TABLE `sentry_organizationmember` ADD CONSTRAINT `organization_id_refs_id_42dc8e8f` FOREIGN KEY (`organization_id`) REFERENCES `sentry_organization` (`id`); []
= CREATE INDEX `sentry_organizationmember_de772da3` ON `sentry_organizationmember` (`organization_id`); []
= ALTER TABLE `sentry_organizationmember` ADD CONSTRAINT `user_id_refs_id_be455e60` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`); []
= CREATE INDEX `sentry_organizationmember_6340c63c` ON `sentry_organizationmember` (`user_id`); []
= ALTER TABLE `sentry_organization` ADD CONSTRAINT `owner_id_refs_id_92f97975` FOREIGN KEY (`owner_id`) REFERENCES `auth_user` (`id`); []
= CREATE INDEX `sentry_organization_cb902d83` ON `sentry_organization` (`owner_id`); []
= ALTER TABLE `sentry_team` ADD CONSTRAINT `organization_id_refs_id_61038a42` FOREIGN KEY (`organization_id`) REFERENCES `sentry_organization` (`id`); []
= CREATE INDEX `sentry_team_de772da3` ON `sentry_team` (`organization_id`); []
and replicated problem
mysql> ALTER TABLE `sentry_organizationmember` ADD CONSTRAINT `organization_id_refs_id_42dc8e8f` FOREIGN KEY (`organization_id`) REFERENCES `sentry_organization` (`id`);
ERROR 1005 (HY000): Can't create table 'sentry.#sql-7684_7e2b' (errno: 150)
I've been trying so hard to make it run but I just can't with my limited knowledge of South. ANY help would be hugely appreciated.
@josephmc5 thanks for debugging this!
I'm going to dig into it a bit now they identified the root cause. Seems it might be non trivial but we can for sure fix it.
https://groups.google.com/forum/#!topic/south-users/X1_8ezSaLAI
My ego convinced me I could solve this in 5m, and it turns out its become quite the pain. If this is a new install, I'd highly suggest Postgres, but if you can't, you can:
$ sentry sql sentry
We do a shitty job at indexes, but this will dump the raw SQL (which you may want to tweak).
Once thats done you can:
$ sentry migrate sentry --fake
That said, I'll probably have a solution for this today, as now I'm convinced its solvable.
@josephmc5 feel like trying out f34cf31 ?
Thank you for looking into it and providing a solution! It's not a new install but I'm installing from scratch on my dev box to do testing. Ok So the migrations didn't finish with that changeset! My only problem now is that the static assets aren't getting delivered right and I'm getting a page not found from sentry. That seems unrelated to these issues though.
Which static assets are 404'ing? Also keep in mind that if you're installing from master we now require node.js be installed in order to build assets.
It appears that all of them are. I do have node.js installed. Is there a way I can verify that the assets were generated or try to regenerate them?
I should note that I'm installing with pip install "repo tarball"
@dcramer ok I think it's just because python setup.py install doesn't build static. I got it working now by doing a
python setup.py sdist --formats=gztar
then installing that gzip
pip install --force-reinstall dist/sentry-7.1.0.dev0.tar.gz
@josephmc5 was this an install from source? You're right that it doesn't. I forgot we killed it for reasons.
I think in general what we are going to need to do is just make it smarter.
Here's the rules I'm thinking:
@dcramer yeah I have my own fork to add ldap support. It basically just adds a hook on login to add all users to all projects except sentry.
I agree it should at least give a warning. Perhaps some documentation too. Although the the develop setup.py option did work.
Fresh database against master at b4ce969a8432dae4b42dae16dd90fc1dbcabe84a.
I know you guys don't use MySQL yourself but I thought I would mention it to see if you had any ideas. I'm looking into it myself.