structure.sql revision 84502d8379a4d40e9a647be8990402060e85b249
CREATE TABLE `comments` (
`commentable_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CREATE TABLE `entities` (
`ontology_version_id` int(11) NOT NULL,
`range` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CONSTRAINT `entities_ontology_version_id_fk` FOREIGN KEY (`ontology_version_id`) REFERENCES `ontology_versions` (`id`) ON DELETE CASCADE
CREATE TABLE `entity_mappings` (
`link_version_id` int(11) NOT NULL,
`source_id` int(11) NOT NULL,
`target_id` int(11) NOT NULL,
`confidence` int(11) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CONSTRAINT `entity_mappings_target_id_fk` FOREIGN KEY (`target_id`) REFERENCES `entities` (`id`) ON DELETE CASCADE,
CONSTRAINT `entity_mappings_link_version_id_fk` FOREIGN KEY (`link_version_id`) REFERENCES `link_versions` (`id`) ON DELETE CASCADE,
CONSTRAINT `entity_mappings_source_id_fk` FOREIGN KEY (`source_id`) REFERENCES `entities` (`id`) ON DELETE CASCADE
CREATE TABLE `language_adjoints` (
`translation_id` int(11) NOT NULL,
`projection_id` int(11) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CONSTRAINT `language_adjoints_projection_id_fk` FOREIGN KEY (`projection_id`) REFERENCES `language_mappings` (`id`) ON DELETE CASCADE,
CONSTRAINT `language_adjoints_translation_id_fk` FOREIGN KEY (`translation_id`) REFERENCES `language_mappings` (`id`) ON DELETE CASCADE
CREATE TABLE `language_mappings` (
`source_id` int(11) NOT NULL,
`target_id` int(11) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CONSTRAINT `language_mappings_target_id_fk` FOREIGN KEY (`target_id`) REFERENCES `languages` (`id`) ON DELETE CASCADE,
CONSTRAINT `language_mappings_source_id_fk` FOREIGN KEY (`source_id`) REFERENCES `languages` (`id`) ON DELETE CASCADE
CREATE TABLE `languages` (
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CREATE TABLE `link_versions` (
`link_id` int(11) NOT NULL,
`source_id` int(11) NOT NULL,
`target_id` int(11) NOT NULL,
`version_number` int(11) DEFAULT NULL,
`current` tinyint(1) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CONSTRAINT `link_versions_target_id_fk` FOREIGN KEY (`target_id`) REFERENCES `ontology_versions` (`id`) ON DELETE CASCADE,
CONSTRAINT `link_versions_link_id_fk` FOREIGN KEY (`link_id`) REFERENCES `links` (`id`) ON DELETE CASCADE,
CONSTRAINT `link_versions_source_id_fk` FOREIGN KEY (`source_id`) REFERENCES `ontology_versions` (`id`) ON DELETE CASCADE
CREATE TABLE `links` (
`source_id` int(11) NOT NULL,
`target_id` int(11) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CREATE TABLE `logic_adjoints` (
`translation_id` int(11) NOT NULL,
`projection_id` int(11) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CONSTRAINT `logic_adjoints_projection_id_fk` FOREIGN KEY (`projection_id`) REFERENCES `logic_mappings` (`id`) ON DELETE CASCADE,
CONSTRAINT `logic_adjoints_translation_id_fk` FOREIGN KEY (`translation_id`) REFERENCES `logic_mappings` (`id`) ON DELETE CASCADE
CREATE TABLE `logic_mappings` (
`source_id` int(11) NOT NULL,
`target_id` int(11) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CONSTRAINT `logic_mappings_target_id_fk` FOREIGN KEY (`target_id`) REFERENCES `logics` (`id`) ON DELETE CASCADE,
CONSTRAINT `logic_mappings_source_id_fk` FOREIGN KEY (`source_id`) REFERENCES `logics` (`id`) ON DELETE CASCADE
CREATE TABLE `logics` (
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CREATE TABLE `members` (
`ontology_version_id` int(11) NOT NULL,
`distributed_ontology_version_id` int(11) NOT NULL
CREATE TABLE `metadata` (
`metadatable_id` int(11) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
`value` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CREATE TABLE `ontologies` (
`language_id` int(11) DEFAULT NULL,
`entities_count` int(11) DEFAULT NULL,
`axioms_count` int(11) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CREATE TABLE `ontology_versions` (
`user_id` int(11) NOT NULL,
`ontology_id` int(11) NOT NULL,
`previous_version_id` int(11) DEFAULT NULL,
`number` int(11) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CONSTRAINT `ontology_versions_previous_version_id_fk` FOREIGN KEY (`previous_version_id`) REFERENCES `ontology_versions` (`id`),
CONSTRAINT `ontology_versions_ontology_id_fk` FOREIGN KEY (`ontology_id`) REFERENCES `ontologies` (`id`) ON DELETE CASCADE,
CREATE TABLE `permissions` (
`subject_id` int(11) NOT NULL,
`item_id` int(11) NOT NULL,
`creator_id` int(11) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
UNIQUE KEY `index_permissions_on_item_and_subject` (`item_id`,`item_type`,`subject_id`,`subject_type`),
CONSTRAINT `permissions_creator_id_fk` FOREIGN KEY (`creator_id`) REFERENCES `users` (`id`) ON DELETE SET NULL
CREATE TABLE `schema_migrations` (
CREATE TABLE `sentence_has_entities` (
`sentence_id` int(11) NOT NULL,
`entity_id` int(11) NOT NULL,
`ontology_version_id` int(11) NOT NULL,
CONSTRAINT `sentence_has_entities_sentence_id_fk` FOREIGN KEY (`sentence_id`) REFERENCES `sentences` (`id`) ON DELETE CASCADE,
CONSTRAINT `sentence_has_entities_entity_id_fk` FOREIGN KEY (`entity_id`) REFERENCES `entities` (`id`) ON DELETE CASCADE
CREATE TABLE `sentences` (
`ontology_version_id` int(11) NOT NULL,
`range` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CONSTRAINT `sentences_ontology_version_id_fk` FOREIGN KEY (`ontology_version_id`) REFERENCES `ontology_versions` (`id`) ON DELETE CASCADE
CREATE TABLE `serializations` (
`language_id` int(11) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CONSTRAINT `serializations_language_id_fk` FOREIGN KEY (`language_id`) REFERENCES `languages` (`id`)
CREATE TABLE `supports` (
`language_id` int(11) DEFAULT NULL,
`logic_id` int(11) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
CREATE TABLE `team_users` (
`team_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`creator_id` int(11) DEFAULT NULL,
CONSTRAINT `team_users_creator_id_fk` FOREIGN KEY (`creator_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
CONSTRAINT `team_users_team_id_fk` FOREIGN KEY (`team_id`) REFERENCES `teams` (`id`) ON DELETE CASCADE,
CONSTRAINT `team_users_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
CREATE TABLE `teams` (
CREATE TABLE `users` (
`reset_password_sent_at` datetime DEFAULT NULL,
`remember_created_at` datetime DEFAULT NULL,
`current_sign_in_at` datetime DEFAULT NULL,
`last_sign_in_at` datetime DEFAULT NULL,
`confirmed_at` datetime DEFAULT NULL,
`confirmation_sent_at` datetime DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`deleted_at` datetime DEFAULT NULL,