﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
9253	auto-generated db identifiers (eg. constraint names) should be of consistent length	crucialfelix	krzych	"where hashes are used to create auto-generated db identifier names, the hash should produce a string of consistent length regardless of the environment or OS.

otherwise SQL generated on one system may work, while generating it on another system won't (mysql does not allow identifiers longer than 64 chars).

eg.
in django.db.creation.backends.py line 127

{{{
r_name = '%s_refs_%s_%x' % (r_col, col, abs(hash((r_table, table))))
}}}


and all other places like that


{{{
# mac
ALTER TABLE `website_artistmailout_lists` ADD CONSTRAINT artistmailout_id_refs_absmail_ptr_id_1347fdf FOREIGN KEY (`artistmailout_id`) REFERENCES `website_artistmailout` (`absmail_ptr_id`);
ALTER TABLE `website_artistmailout_lists` ADD CONSTRAINT accountlist_id_refs_id_7f9cd4c6 FOREIGN KEY (`accountlist_id`) REFERENCES `mailings_accountlist` (`id`);
CREATE TABLE `website_artistmailout_users` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `artistmailout_id` integer NOT NULL,
    `user_id` integer NOT NULL,
    UNIQUE (`artistmailout_id`, `user_id`)
)

#ubuntu
ALTER TABLE `website_artistmailout_lists` ADD CONSTRAINT artistmailout_id_refs_absmail_ptr_id_607b768a01347fdf FOREIGN KEY (`artistmailout_id`) REFERENCES `website_artistmailout` (`absmail_ptr_id`);
ALTER TABLE `website_artistmailout_lists` ADD CONSTRAINT accountlist_id_refs_id_695205280632b3a FOREIGN KEY (`accountlist_id`) REFERENCES `mailings_accountlist` (`id`);
CREATE TABLE `website_artistmailout_users` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `artistmailout_id` integer NOT NULL,
    `user_id` integer NOT NULL,
    UNIQUE (`artistmailout_id`, `user_id`)
)

}}}

note: in this particular case the contraint name is below 64 chars, but only because I changed the names of the models to avoid the problem.
the ouch was that it previously worked on the dev server but not the deployment.




"		closed	Database layer (models, ORM)	1.0		fixed		crucialfelix@…	Accepted	1	0	1	0	0	0
