Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bmatzelle/238114 to your computer and use it in GitHub Desktop.
Save bmatzelle/238114 to your computer and use it in GitHub Desktop.
Fixes teh FogBugz 7 MySQL primary key export
-- FogBugz 7 MySQL Export Primary Key and Index Fix Script
--
-- The FogBugz 7 MySQL data export does not create a database with the primary
-- keys created. When the export is imported and you run FogBugz you will
-- see an error like the one below on FogBugz:
--
-- Dynamic SQL generation for the UpdateCommand is not supported against
-- a SelectCommand that does not return any key column information
--
-- Running the script below creates the necessary primary keys and also removes
-- the duplicate indexes (to preserve disk space) that the export script creates.
--
-- Use this script at your own risk. Fog Creek may have fixed these problems
-- already or changed the table structure enough that this script will be out
-- of date or missing new tables.
--
-- Date: 2009-11-18
ALTER TABLE `Area` ADD PRIMARY KEY (ixArea);
ALTER TABLE `Area` DROP INDEX AreaPrimaryKey;
ALTER TABLE `Attachment` ADD PRIMARY KEY (ixAttachment);
ALTER TABLE `Attachment` DROP INDEX AttachmentPrimaryKey;
ALTER TABLE `AutoResponseRecord` ADD PRIMARY KEY (ixAutoResponseRecord);
ALTER TABLE `AutoResponseRecord` DROP INDEX AutoResponseRecordPrimaryKey;
ALTER TABLE `Bug` ADD PRIMARY KEY (ixBug);
ALTER TABLE `Bug` DROP INDEX BugPrimaryKey;
ALTER TABLE `BugEmail` ADD PRIMARY KEY (ixBugEmail);
ALTER TABLE `BugEmail` DROP INDEX BugEmailPrimaryKey;
ALTER TABLE `BugEvent` ADD PRIMARY KEY (ixBugEvent);
ALTER TABLE `BugEvent` DROP INDEX BugEventPrimaryKey;
ALTER TABLE `BugView` ADD PRIMARY KEY (ixBugView);
ALTER TABLE `BugView` DROP INDEX BugViewPrimaryKey;
ALTER TABLE `BugViewPinnedField` ADD PRIMARY KEY (ixBugViewPinnedField);
ALTER TABLE `BugViewPinnedField` DROP INDEX BugViewPinnedFieldPrimaryKey;
ALTER TABLE `Category` ADD PRIMARY KEY (ixCategory);
ALTER TABLE `Category` DROP INDEX CategoryPrimaryKey;
ALTER TABLE `CVS` ADD PRIMARY KEY (ixCVS);
ALTER TABLE `CVS` DROP INDEX CVSPrimaryKey;
ALTER TABLE `DBCopier` ADD PRIMARY KEY (ixDBCopier);
ALTER TABLE `DBCopier` DROP INDEX DBCopierPrimaryKey;
ALTER TABLE `DbSession` ADD PRIMARY KEY (ixDbSession);
ALTER TABLE `DbSession` DROP INDEX DbSessionPrimaryKey;
ALTER TABLE `DbSessionData` ADD PRIMARY KEY (ixDbSessionData);
ALTER TABLE `DbSessionData` DROP INDEX DbSessionDataPrimaryKey;
ALTER TABLE `DBUpdate` ADD PRIMARY KEY (ixDBUpdate);
ALTER TABLE `DBUpdate` DROP INDEX DBUpdatePrimaryKey;
ALTER TABLE `Dictionary` ADD PRIMARY KEY (ixDictionary);
ALTER TABLE `DiscussGroup` ADD PRIMARY KEY (ixDiscussGroup);
ALTER TABLE `DiscussGroup` DROP INDEX DiscussGroupPrimaryKey;
ALTER TABLE `DiscussLayout` ADD PRIMARY KEY (ixDiscussLayout);
ALTER TABLE `DiscussLayout` DROP INDEX DiscussLayoutPrimaryKey;
ALTER TABLE `DiscussTopic` ADD PRIMARY KEY (ixDiscussTopic);
ALTER TABLE `DiscussTopic` DROP INDEX DiscussTopicPrimaryKey;
ALTER TABLE `DiscussTopicView` ADD PRIMARY KEY (ixDiscussTopicView);
ALTER TABLE `DiscussTopicView` DROP INDEX DiscussTopicViewPrimaryKey;
ALTER TABLE `DocList` ADD PRIMARY KEY (ixDocList);
ALTER TABLE `DocList` DROP INDEX DocListPrimaryKey;
ALTER TABLE `DocListItem` ADD PRIMARY KEY (ixDocListItem);
ALTER TABLE `DocListItem` DROP INDEX DocListItemPrimaryKey;
ALTER TABLE `Draft` ADD PRIMARY KEY (ixDraft);
ALTER TABLE `Draft` DROP INDEX DraftPrimaryKey;
ALTER TABLE `EmailWildcard` ADD PRIMARY KEY (ixEmailWildcard);
ALTER TABLE `EmailWildcard` DROP INDEX EmailWildcardPrimaryKey;
ALTER TABLE `FBLanguage` ADD PRIMARY KEY (ixLanguage);
ALTER TABLE `FBLanguage` DROP INDEX FBLanguagePrimaryKey;
ALTER TABLE `FBLock` ADD PRIMARY KEY (ixFBLock);
ALTER TABLE `FBLock` DROP INDEX FBLockPrimaryKey;
ALTER TABLE `Filter` ADD PRIMARY KEY (ixFilter);
ALTER TABLE `Filter` DROP INDEX FilterPrimaryKey;
ALTER TABLE `FixFor` ADD PRIMARY KEY (ixFixFor);
ALTER TABLE `FixFor` DROP INDEX FixForPrimaryKey;
ALTER TABLE `FixForDependency` ADD PRIMARY KEY (ixFixForDependency);
ALTER TABLE `FixForDependency` DROP INDEX FixForDependencyPrimaryKey;
ALTER TABLE `Groups` ADD PRIMARY KEY (ixGroup);
ALTER TABLE `Holiday` ADD PRIMARY KEY (ixHoliday);
ALTER TABLE `Holiday` DROP INDEX HolidayPrimaryKey;
ALTER TABLE `ID` ADD PRIMARY KEY (id);
ALTER TABLE `IgnoredWord` ADD PRIMARY KEY (ixIgnoredWord);
ALTER TABLE `IndexDelta` ADD PRIMARY KEY (ixIndexDelta);
ALTER TABLE `IndexDelta` DROP INDEX IndexDeltaPrimaryKey;
ALTER TABLE `IndexFile` ADD PRIMARY KEY (ixIndexFile);
ALTER TABLE `IndexFile` DROP INDEX IndexFilePrimaryKey;
ALTER TABLE `IndexFilePage` ADD PRIMARY KEY (ixIndexFilePage);
ALTER TABLE `IndexFilePage` DROP INDEX IndexFilePagePrimaryKey;
ALTER TABLE `Licenses` ADD PRIMARY KEY (ixLicense);
ALTER TABLE `Licenses` DROP INDEX LicensesPrimaryKey;
ALTER TABLE `Mailbox` ADD PRIMARY KEY (ixMailbox);
ALTER TABLE `Mailbox` DROP INDEX MailboxPrimaryKey;
ALTER TABLE `MailQueue` ADD PRIMARY KEY (ixMailQueue);
ALTER TABLE `MailQueue` DROP INDEX MailQueuePrimaryKey;
ALTER TABLE `Notification` ADD PRIMARY KEY (ixNotification);
ALTER TABLE `Notification` DROP INDEX NotificationPrimaryKey;
ALTER TABLE `PasswordResetCode` ADD PRIMARY KEY (ixPasswordResetCode);
ALTER TABLE `PasswordResetCode` DROP INDEX PasswordResetCodePrimaryKey;
ALTER TABLE `Person` ADD PRIMARY KEY (ixPerson);
ALTER TABLE `Person` DROP INDEX PersonPrimaryKey;
ALTER TABLE `Plugin` ADD PRIMARY KEY (ixPlugin);
ALTER TABLE `Plugin` DROP INDEX PluginPrimaryKey;
ALTER TABLE `Plugin_6_Backlog` ADD PRIMARY KEY (ixBacklog);
ALTER TABLE `Plugin_6_Backlog` DROP INDEX Plugin_6_BacklogPrimaryKey;
ALTER TABLE `Prediction` ADD PRIMARY KEY (ixPrediction);
ALTER TABLE `Prediction` DROP INDEX PredictionPrimaryKey;
ALTER TABLE `Priority` ADD PRIMARY KEY (ixPriority);
ALTER TABLE `Priority` DROP INDEX PriorityPrimaryKey;
ALTER TABLE `Project` ADD PRIMARY KEY (ixProject);
ALTER TABLE `Project` DROP INDEX ProjectPrimaryKey;
ALTER TABLE `ProjectPercentTime` ADD PRIMARY KEY (ixProjectPercentTime);
ALTER TABLE `ProjectPercentTime` DROP INDEX ProjectPercentTimePrimaryKey;
ALTER TABLE `ProjectView` ADD PRIMARY KEY (ixProjectView);
ALTER TABLE `ProjectView` DROP INDEX ProjectViewPrimaryKey;
ALTER TABLE `Repository` ADD PRIMARY KEY (ixRepository);
ALTER TABLE `Repository` DROP INDEX RepositoryPrimaryKey;
ALTER TABLE `Revision` ADD PRIMARY KEY (ixRevision);
ALTER TABLE `Revision` DROP INDEX RevisionPrimaryKey;
ALTER TABLE `SearchLog` ADD PRIMARY KEY (ixSearchLog);
ALTER TABLE `SearchLog` DROP INDEX SearchLogPrimaryKey;
ALTER TABLE `ShipDate` ADD PRIMARY KEY (ixShipDate);
ALTER TABLE `ShipDate` DROP INDEX ShipDatePrimaryKey;
ALTER TABLE `Snippet` ADD PRIMARY KEY (ixSnippet);
ALTER TABLE `Snippet` DROP INDEX SnippetPrimaryKey;
ALTER TABLE `SorterToken` ADD PRIMARY KEY (ixToken);
ALTER TABLE `SorterToken` DROP INDEX SorterTokenPrimaryKey;
ALTER TABLE `Status` ADD PRIMARY KEY (ixStatus);
ALTER TABLE `Status` DROP INDEX StatusPrimaryKey;
ALTER TABLE `Subscriptions` ADD PRIMARY KEY (ixSubscription);
ALTER TABLE `Subscriptions` DROP INDEX SubscriptionsPrimaryKey;
ALTER TABLE `Tag` ADD PRIMARY KEY (ixTag);
ALTER TABLE `Tag` DROP INDEX TagPrimaryKey;
ALTER TABLE `TagAssociation` ADD PRIMARY KEY (ixTagAssociation);
ALTER TABLE `TagAssociation` DROP INDEX TagAssociationPrimaryKey;
ALTER TABLE `TagEvent` ADD PRIMARY KEY (ixTagEvent);
ALTER TABLE `TagEvent` DROP INDEX TagEventPrimaryKey;
ALTER TABLE `Template` ADD PRIMARY KEY (ixTemplate);
ALTER TABLE `Template` DROP INDEX TemplatePrimaryKey;
ALTER TABLE `TimeInterval` ADD PRIMARY KEY (ixInterval);
ALTER TABLE `TimeInterval` DROP INDEX TimeIntervalPrimaryKey;
ALTER TABLE `Tokens` ADD PRIMARY KEY (ixToken);
ALTER TABLE `TrainingRequest` ADD PRIMARY KEY (ixRequest);
ALTER TABLE `TrainingRequest` DROP INDEX TrainingRequestPrimaryKey;
ALTER TABLE `Version` ADD PRIMARY KEY (ixVersion);
ALTER TABLE `Wiki` ADD PRIMARY KEY (ixWiki);
ALTER TABLE `Wiki` DROP INDEX WikiPrimaryKey;
ALTER TABLE `WikiExternalLink` ADD PRIMARY KEY (ixWikiExternalLink);
ALTER TABLE `WikiExternalLink` DROP INDEX WikiExternalLinkPrimaryKey;
ALTER TABLE `WikiLink` ADD PRIMARY KEY (ixWikiLink);
ALTER TABLE `WikiLink` DROP INDEX WikiLinkPrimaryKey;
ALTER TABLE `WikiPage` ADD PRIMARY KEY (ixWikiPage);
ALTER TABLE `WikiPage` DROP INDEX WikiPagePrimaryKey;
ALTER TABLE `WikiPageView` ADD PRIMARY KEY (ixWikiPageView);
ALTER TABLE `WikiPageView` DROP INDEX WikiPageViewPrimaryKey;
ALTER TABLE `Word` ADD PRIMARY KEY (ixWord);
ALTER TABLE `Word` DROP INDEX WordPrimaryKey;
ALTER TABLE `Workflow` ADD PRIMARY KEY (ixWorkflow);
ALTER TABLE `Workflow` DROP INDEX WorkflowPrimaryKey;
ALTER TABLE `WorkflowRule` ADD PRIMARY KEY (ixWorkflowRule);
ALTER TABLE `WorkflowRule` DROP INDEX WorkflowRulePrimaryKey;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment