Skip to content

Commit

Permalink
Fix errant migration 95 and the test that let it slip through.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikrose committed Apr 13, 2011
1 parent 97affba commit b60f21d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/sumo/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,16 @@ def test_unique(self):

def test_innodb_and_utf8(self):
"""Make sure each created table uses the InnoDB engine and UTF-8."""
# Migrations are immutable, so just skip known failures:
KNOWN_FAILURES = set(['95-group-dashboards.sql'])

# Heuristic: make sure there are at least as many "ENGINE=InnoDB"s as
# "CREATE TABLE"s. (There might be additional "InnoDB"s in ALTER TABLE
# statements, which are fine.)
path = self._migrations_path()
# The ones before 66 have known failures.
for filename in sorted(listdir(path))[66:]:
for filename in sorted(listdir(path)):
if filename in KNOWN_FAILURES:
continue
with open(join(path, filename)) as f:
contents = f.read()
creates = contents.count('CREATE TABLE')
Expand Down
13 changes: 13 additions & 0 deletions migrations/96-group-dashboard-fix.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Largely supersede migration 95.
-- Fix `dashboard` column width, engine, and charset.

DROP TABLE dashboards_groupdashboard;

CREATE TABLE `dashboards_groupdashboard` (
`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
`group_id` integer NOT NULL,
`dashboard` varchar(10) NOT NULL,
`parameters` varchar(255) NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `dashboards_groupdashboard` ADD CONSTRAINT `group_id_refs_id_142d6845` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`);
CREATE INDEX `dashboards_groupdashboard_bda51c3c` ON `dashboards_groupdashboard` (`group_id`);

0 comments on commit b60f21d

Please sign in to comment.