1UP_SQL = """ 2CREATE TABLE afe_shards ( 3 id INT NOT NULL AUTO_INCREMENT PRIMARY KEY 4) ENGINE=innodb; 5 6ALTER TABLE afe_jobs ADD COLUMN shard_id INT NULL; 7ALTER TABLE afe_jobs ADD CONSTRAINT jobs_to_shard_ibfk 8 FOREIGN KEY (shard_id) REFERENCES afe_shards(id); 9 10CREATE TABLE afe_shards_labels ( 11 id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 12 shard_id INT NOT NULL, 13 label_id INT NOT NULL 14) ENGINE=InnoDB; 15 16ALTER TABLE `afe_shards_labels` ADD CONSTRAINT shard_shard_id_fk 17 FOREIGN KEY (`shard_id`) REFERENCES `afe_shards` (`id`); 18ALTER TABLE `afe_shards_labels` ADD CONSTRAINT shard_label_id_fk 19 FOREIGN KEY (`label_id`) REFERENCES `afe_labels` (`id`); 20""" 21 22DOWN_SQL = """ 23ALTER TABLE afe_jobs DROP FOREIGN KEY jobs_to_shard_ibfk; 24ALTER TABLE afe_jobs DROP COLUMN shard_id; 25 26ALTER TABLE afe_shards_labels DROP FOREIGN KEY shard_label_id_fk; 27ALTER TABLE afe_shards_labels DROP FOREIGN KEY shard_shard_id_fk; 28DROP TABLE afe_shards_labels; 29 30DROP TABLE afe_shards; 31""" 32