
DROP TABLE itfprofiles_production;
DROP TABLE itfprofiles_production_languages;
#DROP TABLE itfprofiles_award;

CREATE TABLE `itfprofiles_production_languages` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `production_id` integer NOT NULL,
    `language_id` integer NOT NULL,
    UNIQUE (`production_id`, `language_id`)
)
;

CREATE TABLE `itfprofiles_production` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `changed` datetime,
    `created` datetime,
    `added_by_id` integer NOT NULL,
    `script_id` integer,
    `name` varchar(255) NOT NULL,
    `synopsis` longtext NOT NULL,
    `group_id` integer,
    `director_id` integer,
    `playwright_id` integer,
    `anecdotes` longtext NOT NULL,
    `debut_date` date
)
;
ALTER TABLE `itfprofiles_production` ADD CONSTRAINT `director_id_refs_id_9fefbcbd` FOREIGN KEY (`director_id`) REFERENCES `itfprofiles_person` (`id`);
ALTER TABLE `itfprofiles_production` ADD CONSTRAINT `playwright_id_refs_id_9fefbcbd` FOREIGN KEY (`playwright_id`) REFERENCES `itfprofiles_person` (`id`);
ALTER TABLE `itfprofiles_production` ADD CONSTRAINT `added_by_id_refs_id_f98027a3` FOREIGN KEY (`added_by_id`) REFERENCES `auth_user` (`id`);
ALTER TABLE `itfprofiles_production` ADD CONSTRAINT `script_id_refs_id_499256c2` FOREIGN KEY (`script_id`) REFERENCES `scriptbank_script` (`id`);
ALTER TABLE `itfprofiles_production` ADD CONSTRAINT `group_id_refs_id_1047a1d6` FOREIGN KEY (`group_id`) REFERENCES `itfprofiles_theatregroup` (`id`);
ALTER TABLE `itfprofiles_production_languages` ADD CONSTRAINT `production_id_refs_id_493fa045` FOREIGN KEY (`production_id`) REFERENCES `itfprofiles_production` (`id`);


CREATE TABLE `itfprofiles_award` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `title` varchar(255) NOT NULL,
    `year` integer NOT NULL,
    `link` varchar(200),
    `content_type_id` integer NOT NULL,
    `object_id` integer UNSIGNED NOT NULL
)
;
ALTER TABLE `itfprofiles_award` ADD CONSTRAINT `content_type_id_refs_id_8eb1850a` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`);



CREATE INDEX `itfprofiles_production_8d09cb1e` ON `itfprofiles_production` (`added_by_id`);
CREATE INDEX `itfprofiles_production_c0ece17f` ON `itfprofiles_production` (`script_id`);
CREATE INDEX `itfprofiles_production_52094d6e` ON `itfprofiles_production` (`name`);
CREATE INDEX `itfprofiles_production_bda51c3c` ON `itfprofiles_production` (`group_id`);
CREATE INDEX `itfprofiles_production_81c0b88c` ON `itfprofiles_production` (`director_id`);
CREATE INDEX `itfprofiles_production_824a300b` ON `itfprofiles_production` (`playwright_id`);
CREATE INDEX `itfprofiles_personproduction_21b911c5` ON `itfprofiles_personproduction` (`person_id`);
CREATE INDEX `itfprofiles_personproduction_55f55d25` ON `itfprofiles_personproduction` (`production_id`);
