text: # MySQL script to create database for Canvas Data schema version 4.2.2
  SET default_storage_engine=InnoDB;
  SET GLOBAL innodb_file_per_table=1;
  DROP DATABASE IF EXISTS canvas_data;
  CREATE DATABASE IF NOT EXISTS canvas_data DEFAULT CHARACTER SET utf8mb4;
  USE canvas_data;
  SET NAMES utf8mb4;
  CREATE TABLE IF NOT EXISTS course_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `root_account_id` BIGINT,
    `account_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `name` VARCHAR(256),
    `code` VARCHAR(256),
    `type` VARCHAR(256),
    `created_at` DATETIME,
    `start_at` DATETIME,
    `conclude_at` DATETIME,
    `publicly_visible` ENUM('false','true'),
    `sis_source_id` VARCHAR(256),
    `workflow_state` ENUM('completed', 'created', 'deleted', 'available', 'claimed'),
    `wiki_id` BIGINT,
    `syllabus_body` LONGTEXT,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX root_account_id (root_account_id),
  INDEX account_id (account_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX sis_source_id (sis_source_id),
  INDEX workflow_state (workflow_state),
  INDEX wiki_id (wiki_id)
  );
  CREATE TABLE IF NOT EXISTS account_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `name` VARCHAR(256),
    `depth` INTEGER UNSIGNED,
    `workflow_state` ENUM('active', 'deleted'),
    `parent_account` VARCHAR(256),
    `parent_account_id` BIGINT,
    `grandparent_account` VARCHAR(256),
    `grandparent_account_id` BIGINT,
    `root_account` VARCHAR(256),
    `root_account_id` BIGINT,
    `subaccount1` VARCHAR(256),
    `subaccount1_id` BIGINT,
    `subaccount2` VARCHAR(256),
    `subaccount2_id` BIGINT,
    `subaccount3` VARCHAR(256),
    `subaccount3_id` BIGINT,
    `subaccount4` VARCHAR(256),
    `subaccount4_id` BIGINT,
    `subaccount5` VARCHAR(256),
    `subaccount5_id` BIGINT,
    `subaccount6` VARCHAR(256),
    `subaccount6_id` BIGINT,
    `subaccount7` VARCHAR(256),
    `subaccount7_id` BIGINT,
    `subaccount8` VARCHAR(256),
    `subaccount8_id` BIGINT,
    `subaccount9` VARCHAR(256),
    `subaccount9_id` BIGINT,
    `subaccount10` VARCHAR(256),
    `subaccount10_id` BIGINT,
    `subaccount11` VARCHAR(256),
    `subaccount11_id` BIGINT,
    `subaccount12` VARCHAR(256),
    `subaccount12_id` BIGINT,
    `subaccount13` VARCHAR(256),
    `subaccount13_id` BIGINT,
    `subaccount14` VARCHAR(256),
    `subaccount14_id` BIGINT,
    `subaccount15` VARCHAR(256),
    `subaccount15_id` BIGINT,
    `sis_source_id` VARCHAR(256),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX workflow_state (workflow_state),
  INDEX parent_account_id (parent_account_id),
  INDEX grandparent_account_id (grandparent_account_id),
  INDEX root_account_id (root_account_id),
  INDEX subaccount1_id (subaccount1_id),
  INDEX subaccount2_id (subaccount2_id),
  INDEX subaccount3_id (subaccount3_id),
  INDEX subaccount4_id (subaccount4_id),
  INDEX subaccount5_id (subaccount5_id),
  INDEX subaccount6_id (subaccount6_id),
  INDEX subaccount7_id (subaccount7_id),
  INDEX subaccount8_id (subaccount8_id),
  INDEX subaccount9_id (subaccount9_id),
  INDEX subaccount10_id (subaccount10_id),
  INDEX subaccount11_id (subaccount11_id),
  INDEX subaccount12_id (subaccount12_id),
  INDEX subaccount13_id (subaccount13_id),
  INDEX subaccount14_id (subaccount14_id),
  INDEX subaccount15_id (subaccount15_id),
  INDEX sis_source_id (sis_source_id)
  );
  CREATE TABLE IF NOT EXISTS user_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `root_account_id` BIGINT,
    `name` VARCHAR(256),
    `time_zone` VARCHAR(256),
    `created_at` DATETIME,
    `visibility` VARCHAR(256),
    `school_name` VARCHAR(256),
    `school_position` VARCHAR(256),
    `gender` VARCHAR(256),
    `locale` VARCHAR(256),
    `public` VARCHAR(256),
    `birthdate` DATETIME,
    `country_code` VARCHAR(256),
    `workflow_state` ENUM('creation_pending', 'deleted', 'pre_registered', 'registered'),
    `sortable_name` VARCHAR(256),
    `global_canvas_id` VARCHAR(256),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX root_account_id (root_account_id),
  INDEX workflow_state (workflow_state),
  INDEX global_canvas_id (global_canvas_id)
  );
  CREATE TABLE IF NOT EXISTS pseudonym_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `user_id` BIGINT,
    `account_id` BIGINT,
    `workflow_state` ENUM('active', 'deleted'),
    `last_request_at` DATETIME,
    `last_login_at` DATETIME,
    `current_login_at` DATETIME,
    `last_login_ip` VARCHAR(256),
    `current_login_ip` VARCHAR(256),
    `position` INTEGER UNSIGNED,
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `password_auto_generated` ENUM('false','true'),
    `deleted_at` DATETIME,
    `sis_user_id` VARCHAR(256),
    `unique_name` VARCHAR(256),
    `integration_id` VARCHAR(256),
    `authentication_provider_id` BIGINT,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX user_id (user_id),
  INDEX account_id (account_id),
  INDEX workflow_state (workflow_state),
  INDEX sis_user_id (sis_user_id),
  INDEX integration_id (integration_id),
  INDEX authentication_provider_id (authentication_provider_id)
  );
  CREATE TABLE IF NOT EXISTS pseudonym_fact (
    `pseudonym_id` BIGINT,
    `user_id` BIGINT,
    `account_id` BIGINT,
    `login_count` INTEGER UNSIGNED,
    `failed_login_count` INTEGER UNSIGNED,
  PRIMARY KEY (pseudonym_id),
  INDEX user_id (user_id),
  INDEX account_id (account_id)
  );
  CREATE TABLE IF NOT EXISTS assignment_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `course_id` BIGINT,
    `title` VARCHAR(256),
    `description` LONGTEXT,
    `due_at` DATETIME,
    `unlock_at` DATETIME,
    `lock_at` DATETIME,
    `points_possible` DOUBLE,
    `grading_type` VARCHAR(256),
    `submission_types` VARCHAR(256),
    `workflow_state` ENUM('unpublished', 'published', 'deleted'),
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `peer_review_count` INTEGER UNSIGNED,
    `peer_reviews_due_at` DATETIME,
    `peer_reviews_assigned` ENUM('false','true'),
    `peer_reviews` ENUM('false','true'),
    `automatic_peer_reviews` ENUM('false','true'),
    `all_day` ENUM('false','true'),
    `all_day_date` DATE,
    `could_be_locked` ENUM('false','true'),
    `grade_group_students_individually` ENUM('false','true'),
    `anonymous_peer_reviews` ENUM('false','true'),
    `muted` ENUM('false','true'),
    `assignment_group_id` BIGINT,
    `position` INTEGER UNSIGNED,
    `visibility` ENUM('everyone', 'only_visible_to_overrides'),
    `external_tool_id` BIGINT,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX course_id (course_id),
  INDEX workflow_state (workflow_state),
  INDEX assignment_group_id (assignment_group_id),
  INDEX external_tool_id (external_tool_id)
  );
  CREATE TABLE IF NOT EXISTS assignment_fact (
    `assignment_id` BIGINT,
    `course_id` BIGINT,
    `course_account_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `points_possible` DOUBLE,
    `peer_review_count` INTEGER UNSIGNED,
    `assignment_group_id` BIGINT,
    `external_tool_id` BIGINT,
  PRIMARY KEY (assignment_id),
  INDEX course_id (course_id),
  INDEX course_account_id (course_account_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX assignment_group_id (assignment_group_id),
  INDEX external_tool_id (external_tool_id)
  );
  CREATE TABLE IF NOT EXISTS assignment_rule_dim (
    `assignment_id` BIGINT,
    `drop_rule` VARCHAR(256),
  PRIMARY KEY (assignment_id)
  );
  CREATE TABLE IF NOT EXISTS submission_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `body` LONGTEXT,
    `url` VARCHAR(256),
    `grade` VARCHAR(256),
    `submitted_at` DATETIME,
    `submission_type` ENUM('discussion_topic', 'external_tool', 'media_recording', 'online_file_upload', 'online_quiz', 'online_text_entry', 'online_upload', 'online_url'),
    `workflow_state` ENUM('graded', 'pending_review', 'submitted', 'unsubmitted'),
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `processed` ENUM('false','true'),
    `process_attempts` INTEGER UNSIGNED,
    `grade_matches_current_submission` ENUM('false','true'),
    `published_grade` VARCHAR(256),
    `graded_at` DATETIME,
    `has_rubric_assessment` ENUM('false','true'),
    `attempt` INTEGER UNSIGNED,
    `has_admin_comment` ENUM('false','true'),
    `assignment_id` BIGINT,
    `excused` ENUM('excused_submission', 'regular_submission'),
    `graded_anonymously` ENUM('graded_anonymously', 'not_graded_anonymously'),
    `grader_id` BIGINT,
    `group_id` BIGINT,
    `quiz_submission_id` BIGINT,
    `user_id` BIGINT,
    `grade_state` ENUM('auto_graded', 'human_graded', 'not_graded'),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX workflow_state (workflow_state),
  INDEX assignment_id (assignment_id),
  INDEX grader_id (grader_id),
  INDEX group_id (group_id),
  INDEX quiz_submission_id (quiz_submission_id),
  INDEX user_id (user_id)
  );
  CREATE TABLE IF NOT EXISTS submission_fact (
    `submission_id` BIGINT,
    `assignment_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `user_id` BIGINT,
    `grader_id` BIGINT,
    `course_account_id` BIGINT,
    `enrollment_rollup_id` BIGINT,
    `score` DOUBLE,
    `published_score` DOUBLE,
    `what_if_score` DOUBLE,
    `submission_comments_count` INTEGER UNSIGNED,
    `account_id` BIGINT,
    `assignment_group_id` BIGINT,
    `group_id` BIGINT,
    `quiz_id` BIGINT,
    `quiz_submission_id` BIGINT,
    `wiki_id` BIGINT,
  PRIMARY KEY (submission_id),
  INDEX assignment_id (assignment_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX user_id (user_id),
  INDEX grader_id (grader_id),
  INDEX course_account_id (course_account_id),
  INDEX enrollment_rollup_id (enrollment_rollup_id),
  INDEX account_id (account_id),
  INDEX assignment_group_id (assignment_group_id),
  INDEX group_id (group_id),
  INDEX quiz_id (quiz_id),
  INDEX quiz_submission_id (quiz_submission_id),
  INDEX wiki_id (wiki_id)
  );
  CREATE TABLE IF NOT EXISTS submission_comment_fact (
    `submission_comment_id` BIGINT,
    `submission_id` BIGINT,
    `recipient_id` BIGINT,
    `author_id` BIGINT,
    `assignment_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `course_account_id` BIGINT,
    `message_size_bytes` INTEGER UNSIGNED,
    `message_character_count` INTEGER UNSIGNED,
    `message_word_count` INTEGER UNSIGNED,
    `message_line_count` INTEGER UNSIGNED,
  PRIMARY KEY (submission_comment_id),
  INDEX submission_id (submission_id),
  INDEX recipient_id (recipient_id),
  INDEX author_id (author_id),
  INDEX assignment_id (assignment_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX course_account_id (course_account_id)
  );
  CREATE TABLE IF NOT EXISTS submission_comment_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `submission_id` BIGINT,
    `recipient_id` BIGINT,
    `author_id` BIGINT,
    `assessment_request_id` BIGINT,
    `group_comment_id` VARCHAR(256),
    `comment` LONGTEXT,
    `author_name` VARCHAR(256),
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `anonymous` ENUM('false','true'),
    `teacher_only_comment` ENUM('false','true'),
    `hidden` ENUM('false','true'),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX submission_id (submission_id),
  INDEX recipient_id (recipient_id),
  INDEX author_id (author_id),
  INDEX assessment_request_id (assessment_request_id),
  INDEX group_comment_id (group_comment_id)
  );
  CREATE TABLE IF NOT EXISTS assignment_group_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `course_id` BIGINT,
    `name` VARCHAR(256),
    `default_assignment_name` VARCHAR(256),
    `workflow_state` ENUM('available', 'deleted'),
    `position` INTEGER UNSIGNED,
    `created_at` DATETIME,
    `updated_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX course_id (course_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS assignment_group_fact (
    `assignment_group_id` BIGINT,
    `course_id` BIGINT,
    `group_weight` DOUBLE,
  PRIMARY KEY (assignment_group_id),
  INDEX course_id (course_id)
  );
  CREATE TABLE IF NOT EXISTS assignment_group_rule_dim (
    `assignment_group_id` BIGINT,
    `drop_lowest` INTEGER UNSIGNED,
    `drop_highest` INTEGER UNSIGNED,
  PRIMARY KEY (assignment_group_id)
  );
  CREATE TABLE IF NOT EXISTS assignment_override_user_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `assignment_id` BIGINT,
    `assignment_override_id` BIGINT,
    `quiz_id` BIGINT,
    `user_id` BIGINT,
    `created_at` DATETIME,
    `updated_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX assignment_id (assignment_id),
  INDEX assignment_override_id (assignment_override_id),
  INDEX quiz_id (quiz_id),
  INDEX user_id (user_id)
  );
  CREATE TABLE IF NOT EXISTS assignment_override_user_fact (
    `assignment_override_user_id` BIGINT,
    `account_id` BIGINT,
    `assignment_group_id` BIGINT,
    `assignment_id` BIGINT,
    `assignment_override_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `quiz_id` BIGINT,
    `user_id` BIGINT,
  PRIMARY KEY (assignment_override_user_id),
  INDEX account_id (account_id),
  INDEX assignment_group_id (assignment_group_id),
  INDEX assignment_id (assignment_id),
  INDEX assignment_override_id (assignment_override_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX quiz_id (quiz_id),
  INDEX user_id (user_id)
  );
  CREATE TABLE IF NOT EXISTS assignment_override_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `assignment_id` BIGINT,
    `course_section_id` BIGINT,
    `group_id` BIGINT,
    `quiz_id` BIGINT,
    `all_day` ENUM('new_all_day', 'same_all_day'),
    `all_day_date` DATE,
    `assignment_version` INTEGER UNSIGNED,
    `created_at` DATETIME,
    `due_at` DATETIME,
    `due_at_overridden` ENUM('new_due_at', 'same_due_at'),
    `lock_at` DATETIME,
    `lock_at_overridden` ENUM('new_lock_at', 'same_lock_at'),
    `set_type` ENUM('course_section', 'group', 'adhoc'),
    `title` LONGTEXT,
    `unlock_at` DATETIME,
    `unlock_at_overridden` ENUM('new_unlock_at', 'same_unlock_at'),
    `updated_at` DATETIME,
    `quiz_version` INTEGER UNSIGNED,
    `workflow_state` ENUM('active', 'deleted'),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX assignment_id (assignment_id),
  INDEX course_section_id (course_section_id),
  INDEX group_id (group_id),
  INDEX quiz_id (quiz_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS assignment_override_fact (
    `assignment_override_id` BIGINT,
    `account_id` BIGINT,
    `assignment_id` BIGINT,
    `assignment_group_id` BIGINT,
    `course_id` BIGINT,
    `course_section_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `group_id` BIGINT,
    `group_category_id` BIGINT,
    `group_parent_account_id` BIGINT,
    `nonxlist_course_id` BIGINT,
    `quiz_id` BIGINT,
    `group_wiki_id` BIGINT,
  PRIMARY KEY (assignment_override_id),
  INDEX account_id (account_id),
  INDEX assignment_id (assignment_id),
  INDEX assignment_group_id (assignment_group_id),
  INDEX course_id (course_id),
  INDEX course_section_id (course_section_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX group_id (group_id),
  INDEX group_category_id (group_category_id),
  INDEX group_parent_account_id (group_parent_account_id),
  INDEX nonxlist_course_id (nonxlist_course_id),
  INDEX quiz_id (quiz_id),
  INDEX group_wiki_id (group_wiki_id)
  );
  CREATE TABLE IF NOT EXISTS assignment_override_user_rollup_fact (
    `assignment_id` BIGINT,
    `assignment_override_id` BIGINT,
    `assignment_override_user_adhoc_id` BIGINT,
    `assignment_group_id` BIGINT,
    `course_id` BIGINT,
    `course_account_id` BIGINT,
    `course_section_id` BIGINT,
    `enrollment_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `group_category_id` BIGINT,
    `group_id` BIGINT,
    `group_parent_account_id` BIGINT,
    `group_wiki_id` BIGINT,
    `nonxlist_course_id` BIGINT,
    `quiz_id` BIGINT,
    `user_id` BIGINT,
    `pkey` BIGINT NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (pkey),
  INDEX assignment_id (assignment_id),
  INDEX assignment_override_id (assignment_override_id),
  INDEX assignment_override_user_adhoc_id (assignment_override_user_adhoc_id),
  INDEX assignment_group_id (assignment_group_id),
  INDEX course_id (course_id),
  INDEX course_account_id (course_account_id),
  INDEX course_section_id (course_section_id),
  INDEX enrollment_id (enrollment_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX group_category_id (group_category_id),
  INDEX group_id (group_id),
  INDEX group_parent_account_id (group_parent_account_id),
  INDEX group_wiki_id (group_wiki_id),
  INDEX nonxlist_course_id (nonxlist_course_id),
  INDEX quiz_id (quiz_id),
  INDEX user_id (user_id)
  );
  CREATE TABLE IF NOT EXISTS submission_file_fact (
    `submission_file_id` BIGINT,
    `file_id` BIGINT,
    `submission_id` BIGINT,
    `assignment_id` BIGINT,
    `user_id` BIGINT,
    `grader_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
  PRIMARY KEY (submission_file_id),
  INDEX file_id (file_id),
  INDEX submission_id (submission_id),
  INDEX assignment_id (assignment_id),
  INDEX user_id (user_id),
  INDEX grader_id (grader_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id)
  );
  CREATE TABLE IF NOT EXISTS catalog_dim (
    `id` BIGINT,
    `parent_id` BIGINT,
    `name` VARCHAR(256),
    `currency` VARCHAR(256),
    `country` VARCHAR(256),
    `time_zone` VARCHAR(256),
    `created_at` DATETIME,
    `updated_at` DATETIME,
  PRIMARY KEY (id),
  INDEX parent_id (parent_id)
  );
  CREATE TABLE IF NOT EXISTS catalog_product_dim (
    `id` BIGINT,
    `catalog_id` BIGINT,
    `start_date` DATETIME,
    `end_date` DATETIME,
    `course_id` BIGINT,
    `product_type` VARCHAR(256),
    `title` VARCHAR(256),
    `visibility` VARCHAR(256),
    `enrollment_open` ENUM('false','true'),
    `has_waitlist` ENUM('false','true'),
    `created_at` DATETIME,
    `updated_at` DATETIME,
  PRIMARY KEY (id),
  INDEX catalog_id (catalog_id),
  INDEX course_id (course_id)
  );
  CREATE TABLE IF NOT EXISTS catalog_product_fact (
    `catalog_product_id` BIGINT,
    `catalog_id` BIGINT,
    `parent_catalog_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `enrollment_fee` DOUBLE,
    `credits` DOUBLE,
    `waitlist_capacity` INTEGER UNSIGNED,
    `enrollment_capacity` INTEGER UNSIGNED,
  PRIMARY KEY (catalog_product_id),
  INDEX catalog_id (catalog_id),
  INDEX parent_catalog_id (parent_catalog_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id)
  );
  CREATE TABLE IF NOT EXISTS catalog_enrollment_dim (
    `id` BIGINT,
    `catalog_product_id` BIGINT,
    `user_id` BIGINT,
    `root_program_id` BIGINT,
    `status` VARCHAR(256),
    `requirements_completed_at` DATETIME,
    `ends_at` DATETIME,
    `created_at` DATETIME,
    `updated_at` DATETIME,
  PRIMARY KEY (id),
  INDEX catalog_product_id (catalog_product_id),
  INDEX user_id (user_id),
  INDEX root_program_id (root_program_id)
  );
  CREATE TABLE IF NOT EXISTS catalog_user_registration_dim (
    `id` BIGINT,
    `catalog_id` BIGINT,
    `user_id` BIGINT,
    `created_at` DATETIME,
    `updated_at` DATETIME,
  PRIMARY KEY (id),
  INDEX catalog_id (catalog_id),
  INDEX user_id (user_id)
  );
  CREATE TABLE IF NOT EXISTS catalog_program_requirement_fact (
    `id` BIGINT,
    `catalog_id` BIGINT,
    `catalog_program_id` BIGINT,
    `catalog_product_id` BIGINT,
    `course_id` BIGINT,
  PRIMARY KEY (id),
  INDEX catalog_id (catalog_id),
  INDEX catalog_program_id (catalog_program_id),
  INDEX catalog_product_id (catalog_product_id),
  INDEX course_id (course_id)
  );
  CREATE TABLE IF NOT EXISTS communication_channel_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `user_id` BIGINT,
    `address` VARCHAR(256),
    `type` ENUM('email', 'facebook', 'push', 'sms', 'twitter'),
    `position` INTEGER UNSIGNED,
    `workflow_state` ENUM('unconfirmed', 'active'),
    `created_at` DATETIME,
    `updated_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX user_id (user_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS communication_channel_fact (
    `communication_channel_id` BIGINT,
    `user_id` BIGINT,
    `bounce_count` INTEGER UNSIGNED,
  PRIMARY KEY (communication_channel_id),
  INDEX user_id (user_id)
  );
  CREATE TABLE IF NOT EXISTS conference_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `title` VARCHAR(256),
    `conference_type` VARCHAR(256),
    `group_id` BIGINT,
    `course_id` BIGINT,
    `account_id` BIGINT,
    `start_at` DATETIME,
    `started_at` DATETIME,
    `end_at` DATETIME,
    `ended_at` DATETIME,
    `created_at` DATETIME,
    `updated_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX group_id (group_id),
  INDEX course_id (course_id),
  INDEX account_id (account_id)
  );
  CREATE TABLE IF NOT EXISTS conference_fact (
    `conference_id` BIGINT,
    `group_id` BIGINT,
    `course_id` BIGINT,
    `account_id` BIGINT,
    `duration` DOUBLE,
  PRIMARY KEY (conference_id),
  INDEX group_id (group_id),
  INDEX course_id (course_id),
  INDEX account_id (account_id)
  );
  CREATE TABLE IF NOT EXISTS conference_participant_dim (
    `id` BIGINT,
    `user_id` BIGINT,
    `conference_id` BIGINT,
    `participation_type` VARCHAR(256),
    `created_at` DATETIME,
    `updated_at` DATETIME,
  PRIMARY KEY (id),
  INDEX user_id (user_id),
  INDEX conference_id (conference_id)
  );
  CREATE TABLE IF NOT EXISTS conference_participant_fact (
    `conference_participant_id` BIGINT,
    `group_id` BIGINT,
    `course_id` BIGINT,
    `account_id` BIGINT,
    `user_id` BIGINT,
    `conference_id` BIGINT,
  PRIMARY KEY (conference_participant_id),
  INDEX group_id (group_id),
  INDEX course_id (course_id),
  INDEX account_id (account_id),
  INDEX user_id (user_id),
  INDEX conference_id (conference_id)
  );
  CREATE TABLE IF NOT EXISTS conversation_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `has_attachments` ENUM('false','true'),
    `has_media_objects` ENUM('false','true'),
    `subject` VARCHAR(256),
    `course_id` BIGINT,
    `group_id` BIGINT,
    `account_id` BIGINT,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX course_id (course_id),
  INDEX group_id (group_id),
  INDEX account_id (account_id)
  );
  CREATE TABLE IF NOT EXISTS conversation_message_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `conversation_id` BIGINT,
    `author_id` BIGINT,
    `created_at` DATETIME,
    `generated` ENUM('false','true'),
    `has_attachments` ENUM('false','true'),
    `has_media_objects` ENUM('false','true'),
    `body` LONGTEXT,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX conversation_id (conversation_id),
  INDEX author_id (author_id)
  );
  CREATE TABLE IF NOT EXISTS conversation_message_participant_fact (
    `conversation_message_id` BIGINT,
    `conversation_id` BIGINT,
    `user_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `course_account_id` BIGINT,
    `group_id` BIGINT,
    `account_id` BIGINT,
    `enrollment_rollup_id` BIGINT,
    `message_size_bytes` INTEGER UNSIGNED,
    `message_character_count` INTEGER UNSIGNED,
    `message_word_count` INTEGER UNSIGNED,
    `message_line_count` INTEGER UNSIGNED,
  PRIMARY KEY (conversation_message_id,user_id),
  INDEX conversation_message_id (conversation_message_id),
  INDEX conversation_id (conversation_id),
  INDEX user_id (user_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX course_account_id (course_account_id),
  INDEX group_id (group_id),
  INDEX account_id (account_id),
  INDEX enrollment_rollup_id (enrollment_rollup_id)
  );
  CREATE TABLE IF NOT EXISTS discussion_topic_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `title` VARCHAR(256),
    `message` LONGTEXT,
    `type` VARCHAR(256),
    `workflow_state` ENUM('unpublished', 'active', 'locked', 'deleted', 'post_delayed'),
    `last_reply_at` DATETIME,
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `delayed_post_at` DATETIME,
    `posted_at` DATETIME,
    `deleted_at` DATETIME,
    `discussion_type` VARCHAR(256),
    `pinned` ENUM('false','true'),
    `locked` ENUM('false','true'),
    `course_id` BIGINT,
    `group_id` BIGINT,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX workflow_state (workflow_state),
  INDEX course_id (course_id),
  INDEX group_id (group_id)
  );
  CREATE TABLE IF NOT EXISTS discussion_topic_fact (
    `discussion_topic_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `course_account_id` BIGINT,
    `user_id` BIGINT,
    `assignment_id` BIGINT,
    `editor_id` BIGINT,
    `enrollment_rollup_id` BIGINT,
    `message_length` INTEGER UNSIGNED,
    `group_id` BIGINT,
    `group_parent_course_id` BIGINT,
    `group_parent_account_id` BIGINT,
    `group_parent_course_account_id` BIGINT,
  PRIMARY KEY (discussion_topic_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX course_account_id (course_account_id),
  INDEX user_id (user_id),
  INDEX assignment_id (assignment_id),
  INDEX editor_id (editor_id),
  INDEX enrollment_rollup_id (enrollment_rollup_id),
  INDEX group_id (group_id),
  INDEX group_parent_course_id (group_parent_course_id),
  INDEX group_parent_account_id (group_parent_account_id),
  INDEX group_parent_course_account_id (group_parent_course_account_id)
  );
  CREATE TABLE IF NOT EXISTS discussion_entry_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `message` LONGTEXT,
    `workflow_state` ENUM('active', 'deleted'),
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `deleted_at` DATETIME,
    `depth` INTEGER UNSIGNED,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS discussion_entry_fact (
    `discussion_entry_id` BIGINT,
    `parent_discussion_entry_id` BIGINT,
    `user_id` BIGINT,
    `topic_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `course_account_id` BIGINT,
    `topic_user_id` BIGINT,
    `topic_assignment_id` BIGINT,
    `topic_editor_id` BIGINT,
    `enrollment_rollup_id` BIGINT,
    `message_length` INTEGER UNSIGNED,
  PRIMARY KEY (discussion_entry_id),
  INDEX parent_discussion_entry_id (parent_discussion_entry_id),
  INDEX user_id (user_id),
  INDEX topic_id (topic_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX course_account_id (course_account_id),
  INDEX topic_user_id (topic_user_id),
  INDEX topic_assignment_id (topic_assignment_id),
  INDEX topic_editor_id (topic_editor_id),
  INDEX enrollment_rollup_id (enrollment_rollup_id)
  );
  CREATE TABLE IF NOT EXISTS enrollment_term_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `root_account_id` BIGINT,
    `name` VARCHAR(256),
    `date_start` DATETIME,
    `date_end` DATETIME,
    `sis_source_id` VARCHAR(256),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX root_account_id (root_account_id),
  INDEX sis_source_id (sis_source_id)
  );
  CREATE TABLE IF NOT EXISTS course_section_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `name` VARCHAR(256),
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `default_section` ENUM('false','true'),
    `accepting_enrollments` ENUM('false','true'),
    `can_manually_enroll` ENUM('false','true'),
    `start_at` DATETIME,
    `end_at` DATETIME,
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `workflow_state` ENUM('deleted', 'inactive'),
    `restrict_enrollments_to_section_dates` ENUM('false','true'),
    `nonxlist_course_id` BIGINT,
    `sis_source_id` VARCHAR(256),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX workflow_state (workflow_state),
  INDEX nonxlist_course_id (nonxlist_course_id),
  INDEX sis_source_id (sis_source_id)
  );
  CREATE TABLE IF NOT EXISTS role_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `root_account_id` BIGINT,
    `account_id` BIGINT,
    `name` VARCHAR(256),
    `base_role_type` VARCHAR(256),
    `workflow_state` ENUM('active', 'deleted'),
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `deleted_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX root_account_id (root_account_id),
  INDEX account_id (account_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS enrollment_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `root_account_id` BIGINT,
    `course_section_id` BIGINT,
    `role_id` BIGINT,
    `type` VARCHAR(256),
    `workflow_state` ENUM('active', 'completed', 'rejected', 'deleted', 'invited', 'creation_pending'),
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `start_at` DATETIME,
    `end_at` DATETIME,
    `completed_at` DATETIME,
    `self_enrolled` ENUM('false','true'),
    `sis_source_id` VARCHAR(256),
    `course_id` BIGINT,
    `user_id` BIGINT,
    `last_activity_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX root_account_id (root_account_id),
  INDEX course_section_id (course_section_id),
  INDEX role_id (role_id),
  INDEX workflow_state (workflow_state),
  INDEX sis_source_id (sis_source_id),
  INDEX course_id (course_id),
  INDEX user_id (user_id)
  );
  CREATE TABLE IF NOT EXISTS enrollment_fact (
    `enrollment_id` BIGINT,
    `user_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `course_account_id` BIGINT,
    `course_section_id` BIGINT,
    `computed_final_score` DOUBLE,
    `computed_current_score` DOUBLE,
  PRIMARY KEY (enrollment_id),
  INDEX user_id (user_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX course_account_id (course_account_id),
  INDEX course_section_id (course_section_id)
  );
  CREATE TABLE IF NOT EXISTS enrollment_rollup_dim (
    `id` BIGINT,
    `user_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_count` INTEGER UNSIGNED,
    `role_count` INTEGER UNSIGNED,
    `base_role_count` INTEGER UNSIGNED,
    `account_admin_role_count` INTEGER UNSIGNED,
    `teacher_enrollment_role_count` INTEGER UNSIGNED,
    `designer_enrollment_role_count` INTEGER UNSIGNED,
    `ta_enrollment_role_count` INTEGER UNSIGNED,
    `student_enrollment_role_count` INTEGER UNSIGNED,
    `observer_enrollment_role_count` INTEGER UNSIGNED,
    `account_membership_role_count` INTEGER UNSIGNED,
    `no_permissions_role_count` INTEGER UNSIGNED,
    `account_admin_enrollment_id` BIGINT,
    `teacher_enrollment_enrollment_id` BIGINT,
    `designer_enrollment_enrollment_id` BIGINT,
    `ta_enrollment_enrollment_id` BIGINT,
    `student_enrollment_enrollment_id` BIGINT,
    `observer_enrollment_enrollment_id` BIGINT,
    `account_membership_enrollment_id` BIGINT,
    `no_permissions_enrollment_id` BIGINT,
    `most_privileged_role` VARCHAR(256),
    `least_privileged_role` VARCHAR(256),
  PRIMARY KEY (id),
  INDEX user_id (user_id),
  INDEX course_id (course_id),
  INDEX account_admin_enrollment_id (account_admin_enrollment_id),
  INDEX teacher_enrollment_enrollment_id (teacher_enrollment_enrollment_id),
  INDEX designer_enrollment_enrollment_id (designer_enrollment_enrollment_id),
  INDEX ta_enrollment_enrollment_id (ta_enrollment_enrollment_id),
  INDEX student_enrollment_enrollment_id (student_enrollment_enrollment_id),
  INDEX observer_enrollment_enrollment_id (observer_enrollment_enrollment_id),
  INDEX account_membership_enrollment_id (account_membership_enrollment_id),
  INDEX no_permissions_enrollment_id (no_permissions_enrollment_id)
  );
  CREATE TABLE IF NOT EXISTS assignment_group_score_fact (
    `score_id` BIGINT,
    `canvas_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `assignment_group_id` BIGINT,
    `enrollment_id` BIGINT,
    `current_score` DOUBLE,
    `final_score` DOUBLE,
    `muted_current_score` DOUBLE,
    `muted_final_score` DOUBLE,
  PRIMARY KEY (score_id),
  INDEX canvas_id (canvas_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX assignment_group_id (assignment_group_id),
  INDEX enrollment_id (enrollment_id)
  );
  CREATE TABLE IF NOT EXISTS course_score_fact (
    `score_id` BIGINT,
    `canvas_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_id` BIGINT,
    `current_score` DOUBLE,
    `final_score` DOUBLE,
    `muted_current_score` DOUBLE,
    `muted_final_score` DOUBLE,
  PRIMARY KEY (score_id),
  INDEX canvas_id (canvas_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX enrollment_id (enrollment_id)
  );
  CREATE TABLE IF NOT EXISTS grading_period_score_fact (
    `score_id` BIGINT,
    `canvas_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_id` BIGINT,
    `grading_period_id` BIGINT,
    `grading_period_group_id` BIGINT,
    `grading_period_group_account_id` BIGINT,
    `current_score` DOUBLE,
    `final_score` DOUBLE,
    `muted_current_score` DOUBLE,
    `muted_final_score` DOUBLE,
  PRIMARY KEY (score_id),
  INDEX canvas_id (canvas_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX enrollment_id (enrollment_id),
  INDEX grading_period_id (grading_period_id),
  INDEX grading_period_group_id (grading_period_group_id),
  INDEX grading_period_group_account_id (grading_period_group_account_id)
  );
  CREATE TABLE IF NOT EXISTS assignment_group_score_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `assignment_group_id` BIGINT,
    `enrollment_id` BIGINT,
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `workflow_state` ENUM('active', 'deleted'),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX assignment_group_id (assignment_group_id),
  INDEX enrollment_id (enrollment_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS course_score_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `enrollment_id` BIGINT,
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `workflow_state` ENUM('active', 'deleted'),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX enrollment_id (enrollment_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS grading_period_score_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `enrollment_id` BIGINT,
    `grading_period_id` BIGINT,
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `workflow_state` ENUM('active', 'deleted'),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX enrollment_id (enrollment_id),
  INDEX grading_period_id (grading_period_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS grading_period_fact (
    `grading_period_id` BIGINT,
    `canvas_id` BIGINT,
    `grading_period_group_id` BIGINT,
    `grading_period_group_account_id` BIGINT,
    `grading_period_group_course_id` BIGINT,
    `weight` DOUBLE,
  PRIMARY KEY (grading_period_id),
  INDEX canvas_id (canvas_id),
  INDEX grading_period_group_id (grading_period_group_id),
  INDEX grading_period_group_account_id (grading_period_group_account_id),
  INDEX grading_period_group_course_id (grading_period_group_course_id)
  );
  CREATE TABLE IF NOT EXISTS grading_period_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `grading_period_group_id` BIGINT,
    `close_date` DATETIME,
    `created_at` DATETIME,
    `end_date` DATETIME,
    `start_date` DATETIME,
    `title` VARCHAR(256),
    `updated_at` DATETIME,
    `workflow_state` ENUM('active', 'deleted'),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX grading_period_group_id (grading_period_group_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS grading_period_group_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `course_id` BIGINT,
    `account_id` BIGINT,
    `created_at` DATETIME,
    `title` VARCHAR(256),
    `updated_at` DATETIME,
    `workflow_state` ENUM('active', 'deleted'),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX course_id (course_id),
  INDEX account_id (account_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS file_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `display_name` LONGTEXT,
    `account_id` BIGINT,
    `assignment_id` BIGINT,
    `conversation_message_id` BIGINT,
    `course_id` BIGINT,
    `folder_id` BIGINT,
    `group_id` BIGINT,
    `quiz_id` BIGINT,
    `quiz_submission_id` BIGINT,
    `replacement_file_id` BIGINT,
    `root_file_id` BIGINT,
    `submission_id` BIGINT,
    `uploader_id` BIGINT,
    `user_id` BIGINT,
    `owner_entity_type` ENUM('account', 'assignment', 'conversation_message', 'course', 'group', 'quiz', 'quiz_submission', 'submission', 'user'),
    `content_type` VARCHAR(256),
    `md5` VARCHAR(256),
    `file_state` ENUM('available', 'broken', 'deleted', 'errored', 'hidden'),
    `could_be_locked` ENUM('allow_locking', 'disallow_locking'),
    `locked` ENUM('is_locked', 'is_not_locked'),
    `lock_at` DATETIME,
    `unlock_at` DATETIME,
    `viewed_at` DATETIME,
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `deleted_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX account_id (account_id),
  INDEX assignment_id (assignment_id),
  INDEX conversation_message_id (conversation_message_id),
  INDEX course_id (course_id),
  INDEX folder_id (folder_id),
  INDEX group_id (group_id),
  INDEX quiz_id (quiz_id),
  INDEX quiz_submission_id (quiz_submission_id),
  INDEX replacement_file_id (replacement_file_id),
  INDEX root_file_id (root_file_id),
  INDEX submission_id (submission_id),
  INDEX uploader_id (uploader_id),
  INDEX user_id (user_id)
  );
  CREATE TABLE IF NOT EXISTS file_fact (
    `file_id` BIGINT,
    `account_id` BIGINT,
    `assignment_id` BIGINT,
    `assignment_group_id` BIGINT,
    `conversation_id` BIGINT,
    `conversation_message_author_id` BIGINT,
    `conversation_message_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_rollup_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `folder_id` BIGINT,
    `grader_id` BIGINT,
    `group_id` BIGINT,
    `group_category_id` BIGINT,
    `quiz_id` BIGINT,
    `quiz_submission_id` BIGINT,
    `replacement_file_id` BIGINT,
    `root_file_id` BIGINT,
    `sis_source_id` VARCHAR(256),
    `submission_id` BIGINT,
    `uploader_id` BIGINT,
    `user_id` BIGINT,
    `wiki_id` BIGINT,
    `size` BIGINT,
  PRIMARY KEY (file_id),
  INDEX account_id (account_id),
  INDEX assignment_id (assignment_id),
  INDEX assignment_group_id (assignment_group_id),
  INDEX conversation_id (conversation_id),
  INDEX conversation_message_author_id (conversation_message_author_id),
  INDEX conversation_message_id (conversation_message_id),
  INDEX course_id (course_id),
  INDEX enrollment_rollup_id (enrollment_rollup_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX folder_id (folder_id),
  INDEX grader_id (grader_id),
  INDEX group_id (group_id),
  INDEX group_category_id (group_category_id),
  INDEX quiz_id (quiz_id),
  INDEX quiz_submission_id (quiz_submission_id),
  INDEX replacement_file_id (replacement_file_id),
  INDEX root_file_id (root_file_id),
  INDEX sis_source_id (sis_source_id),
  INDEX submission_id (submission_id),
  INDEX uploader_id (uploader_id),
  INDEX user_id (user_id),
  INDEX wiki_id (wiki_id)
  );
  CREATE TABLE IF NOT EXISTS group_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `name` VARCHAR(256),
    `description` LONGTEXT,
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `deleted_at` DATETIME,
    `is_public` ENUM('false','true'),
    `workflow_state` ENUM('active', 'deleted'),
    `context_type` VARCHAR(256),
    `category` LONGTEXT,
    `join_level` VARCHAR(256),
    `default_view` VARCHAR(256),
    `sis_source_id` BIGINT,
    `group_category_id` BIGINT,
    `account_id` BIGINT,
    `wiki_id` BIGINT,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX workflow_state (workflow_state),
  INDEX sis_source_id (sis_source_id),
  INDEX group_category_id (group_category_id),
  INDEX account_id (account_id),
  INDEX wiki_id (wiki_id)
  );
  CREATE TABLE IF NOT EXISTS group_fact (
    `group_id` BIGINT,
    `parent_course_id` BIGINT,
    `parent_account_id` BIGINT,
    `parent_course_account_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `max_membership` INTEGER UNSIGNED,
    `storage_quota` BIGINT,
    `group_category_id` BIGINT,
    `account_id` BIGINT,
    `wiki_id` BIGINT,
  PRIMARY KEY (group_id),
  INDEX parent_course_id (parent_course_id),
  INDEX parent_account_id (parent_account_id),
  INDEX parent_course_account_id (parent_course_account_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX group_category_id (group_category_id),
  INDEX account_id (account_id),
  INDEX wiki_id (wiki_id)
  );
  CREATE TABLE IF NOT EXISTS group_membership_fact (
    `group_id` BIGINT,
    `parent_course_id` BIGINT,
    `parent_account_id` BIGINT,
    `parent_course_account_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `user_id` BIGINT,
    `group_membership_id` VARCHAR(256),
  INDEX group_id (group_id),
  INDEX parent_course_id (parent_course_id),
  INDEX parent_account_id (parent_account_id),
  INDEX parent_course_account_id (parent_course_account_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX user_id (user_id),
  PRIMARY KEY (group_membership_id)
  );
  CREATE TABLE IF NOT EXISTS group_membership_dim (
    `id` VARCHAR(256),
    `canvas_id` VARCHAR(256),
    `group_id` BIGINT,
    `moderator` ENUM('is_moderator', 'not_moderator'),
    `workflow_state` ENUM('accepted', 'invited', 'requested', 'deleted'),
    `created_at` DATETIME,
    `updated_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX group_id (group_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS module_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `course_id` BIGINT,
    `require_sequential_progress` ENUM('required', 'not_required', 'unspecified'),
    `workflow_state` ENUM('locked', 'completed', 'unlocked', 'started'),
    `position` INTEGER UNSIGNED,
    `name` LONGTEXT,
    `created_at` DATETIME,
    `deleted_at` DATETIME,
    `unlock_at` DATETIME,
    `updated_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX course_id (course_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS module_fact (
    `module_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `wiki_id` BIGINT,
  PRIMARY KEY (module_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX wiki_id (wiki_id)
  );
  CREATE TABLE IF NOT EXISTS module_item_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `assignment_id` BIGINT,
    `course_id` BIGINT,
    `discussion_topic_id` BIGINT,
    `file_id` BIGINT,
    `module_id` BIGINT,
    `quiz_id` BIGINT,
    `wiki_page_id` BIGINT,
    `content_type` ENUM('Assignment', 'Attachment', 'DiscussionTopic', 'ContextExternalTool', 'ContextModuleSubHeader', 'ExternalUrl', 'LearningOutcome', 'Quiz', 'Rubric', 'WikiPage'),
    `workflow_state` ENUM('active', 'unpublished', 'deleted'),
    `position` INTEGER UNSIGNED,
    `title` LONGTEXT,
    `url` LONGTEXT,
    `created_at` DATETIME,
    `updated_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX assignment_id (assignment_id),
  INDEX course_id (course_id),
  INDEX discussion_topic_id (discussion_topic_id),
  INDEX file_id (file_id),
  INDEX module_id (module_id),
  INDEX quiz_id (quiz_id),
  INDEX wiki_page_id (wiki_page_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS module_item_fact (
    `module_item_id` BIGINT,
    `account_id` BIGINT,
    `assignment_id` BIGINT,
    `assignment_group_id` BIGINT,
    `course_id` BIGINT,
    `discussion_topic_id` BIGINT,
    `discussion_topic_editor_id` BIGINT,
    `enrollment_rollup_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `file_id` BIGINT,
    `module_id` BIGINT,
    `quiz_id` BIGINT,
    `user_id` BIGINT,
    `wiki_id` BIGINT,
    `wiki_page_id` BIGINT,
  PRIMARY KEY (module_item_id),
  INDEX account_id (account_id),
  INDEX assignment_id (assignment_id),
  INDEX assignment_group_id (assignment_group_id),
  INDEX course_id (course_id),
  INDEX discussion_topic_id (discussion_topic_id),
  INDEX discussion_topic_editor_id (discussion_topic_editor_id),
  INDEX enrollment_rollup_id (enrollment_rollup_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX file_id (file_id),
  INDEX module_id (module_id),
  INDEX quiz_id (quiz_id),
  INDEX user_id (user_id),
  INDEX wiki_id (wiki_id),
  INDEX wiki_page_id (wiki_page_id)
  );
  CREATE TABLE IF NOT EXISTS module_progression_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `module_id` BIGINT,
    `user_id` BIGINT,
    `collapsed` ENUM('collapsed', 'not_collapsed', 'unspecified'),
    `is_current` ENUM('current', 'not_current', 'unspecified'),
    `workflow_state` ENUM('locked', 'completed', 'unlocked', 'started'),
    `current_position` INTEGER UNSIGNED,
    `lock_version` INTEGER UNSIGNED,
    `created_at` DATETIME,
    `completed_at` DATETIME,
    `evaluated_at` DATETIME,
    `updated_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX module_id (module_id),
  INDEX user_id (user_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS module_progression_fact (
    `module_progression_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `module_id` BIGINT,
    `user_id` BIGINT,
    `wiki_id` BIGINT,
  PRIMARY KEY (module_progression_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX module_id (module_id),
  INDEX user_id (user_id),
  INDEX wiki_id (wiki_id)
  );
  CREATE TABLE IF NOT EXISTS module_completion_requirement_dim (
    `id` BIGINT,
    `module_id` BIGINT,
    `module_item_id` BIGINT,
    `requirement_type` ENUM('must_view', 'must_mark_done', 'min_score', 'must_submit'),
  PRIMARY KEY (id),
  INDEX module_id (module_id),
  INDEX module_item_id (module_item_id)
  );
  CREATE TABLE IF NOT EXISTS module_completion_requirement_fact (
    `module_completion_requirement_id` BIGINT,
    `account_id` BIGINT,
    `assignment_id` BIGINT,
    `assignment_group_id` BIGINT,
    `course_id` BIGINT,
    `discussion_topic_id` BIGINT,
    `discussion_topic_editor_id` BIGINT,
    `enrollment_rollup_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `file_id` BIGINT,
    `module_id` BIGINT,
    `module_item_id` BIGINT,
    `quiz_id` BIGINT,
    `user_id` BIGINT,
    `wiki_id` BIGINT,
    `wiki_page_id` BIGINT,
    `min_score` DOUBLE,
  PRIMARY KEY (module_completion_requirement_id),
  INDEX account_id (account_id),
  INDEX assignment_id (assignment_id),
  INDEX assignment_group_id (assignment_group_id),
  INDEX course_id (course_id),
  INDEX discussion_topic_id (discussion_topic_id),
  INDEX discussion_topic_editor_id (discussion_topic_editor_id),
  INDEX enrollment_rollup_id (enrollment_rollup_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX file_id (file_id),
  INDEX module_id (module_id),
  INDEX module_item_id (module_item_id),
  INDEX quiz_id (quiz_id),
  INDEX user_id (user_id),
  INDEX wiki_id (wiki_id),
  INDEX wiki_page_id (wiki_page_id)
  );
  CREATE TABLE IF NOT EXISTS module_prerequisite_dim (
    `id` BIGINT,
    `module_id` BIGINT,
    `prerequisite_module_id` BIGINT,
  PRIMARY KEY (id),
  INDEX module_id (module_id),
  INDEX prerequisite_module_id (prerequisite_module_id)
  );
  CREATE TABLE IF NOT EXISTS module_prerequisite_fact (
    `module_prerequisite_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `module_id` BIGINT,
    `prerequisite_module_id` BIGINT,
    `prerequisite_wiki_id` BIGINT,
    `wiki_id` BIGINT,
  PRIMARY KEY (module_prerequisite_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX module_id (module_id),
  INDEX prerequisite_module_id (prerequisite_module_id),
  INDEX prerequisite_wiki_id (prerequisite_wiki_id),
  INDEX wiki_id (wiki_id)
  );
  CREATE TABLE IF NOT EXISTS module_progression_completion_requirement_dim (
    `id` BIGINT,
    `module_progression_id` BIGINT,
    `module_item_id` BIGINT,
    `requirement_type` ENUM('must_view', 'must_mark_done', 'min_score', 'must_submit'),
    `completion_status` ENUM('complete', 'incomplete'),
  PRIMARY KEY (id),
  INDEX module_progression_id (module_progression_id),
  INDEX module_item_id (module_item_id)
  );
  CREATE TABLE IF NOT EXISTS module_progression_completion_requirement_fact (
    `module_progression_completion_requirement_id` BIGINT,
    `account_id` BIGINT,
    `assignment_id` BIGINT,
    `assignment_group_id` BIGINT,
    `course_id` BIGINT,
    `discussion_topic_id` BIGINT,
    `discussion_topic_editor_id` BIGINT,
    `enrollment_rollup_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `file_id` BIGINT,
    `module_id` BIGINT,
    `module_item_id` BIGINT,
    `module_progression_id` BIGINT,
    `quiz_id` BIGINT,
    `user_id` BIGINT,
    `wiki_id` BIGINT,
    `wiki_page_id` BIGINT,
    `min_score` DOUBLE,
    `score` DOUBLE,
  PRIMARY KEY (module_progression_completion_requirement_id),
  INDEX account_id (account_id),
  INDEX assignment_id (assignment_id),
  INDEX assignment_group_id (assignment_group_id),
  INDEX course_id (course_id),
  INDEX discussion_topic_id (discussion_topic_id),
  INDEX discussion_topic_editor_id (discussion_topic_editor_id),
  INDEX enrollment_rollup_id (enrollment_rollup_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX file_id (file_id),
  INDEX module_id (module_id),
  INDEX module_item_id (module_item_id),
  INDEX module_progression_id (module_progression_id),
  INDEX quiz_id (quiz_id),
  INDEX user_id (user_id),
  INDEX wiki_id (wiki_id),
  INDEX wiki_page_id (wiki_page_id)
  );
  CREATE TABLE IF NOT EXISTS course_ui_canvas_navigation_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `name` VARCHAR(256),
    `default` VARCHAR(256),
    `original_position` VARCHAR(256),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id)
  );
  CREATE TABLE IF NOT EXISTS course_ui_navigation_item_dim (
    `id` BIGINT,
    `root_account_id` BIGINT,
    `visible` VARCHAR(256),
    `position` INTEGER UNSIGNED,
  PRIMARY KEY (id),
  INDEX root_account_id (root_account_id)
  );
  CREATE TABLE IF NOT EXISTS course_ui_navigation_item_fact (
    `root_account_id` BIGINT,
    `course_ui_navigation_item_id` BIGINT,
    `course_ui_canvas_navigation_id` BIGINT,
    `external_tool_activation_id` BIGINT,
    `course_id` BIGINT,
    `course_account_id` BIGINT,
    `enrollment_term_id` BIGINT,
  INDEX root_account_id (root_account_id),
  INDEX course_ui_canvas_navigation_id (course_ui_canvas_navigation_id),
  INDEX external_tool_activation_id (external_tool_activation_id),
  INDEX course_id (course_id),
  INDEX course_account_id (course_account_id),
  INDEX enrollment_term_id (enrollment_term_id),
  PRIMARY KEY (course_ui_navigation_item_id)
  );
  CREATE TABLE IF NOT EXISTS learning_outcome_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `short_description` VARCHAR(256),
    `description` LONGTEXT,
    `workflow_state` ENUM('active', 'deleted'),
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `vendor_guid` VARCHAR(256),
    `display_name` VARCHAR(256),
    `calculation_method` LONGTEXT,
    `calculation_int` INTEGER UNSIGNED,
    `outcome_import_id` BIGINT,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX workflow_state (workflow_state),
  INDEX outcome_import_id (outcome_import_id)
  );
  CREATE TABLE IF NOT EXISTS learning_outcome_fact (
    `learning_outcome_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `mastery_points` DOUBLE,
    `points_possible` DOUBLE,
    `outcome_import_id` BIGINT,
  PRIMARY KEY (learning_outcome_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX outcome_import_id (outcome_import_id)
  );
  CREATE TABLE IF NOT EXISTS learning_outcome_rubric_criterion_dim (
    `id` BIGINT,
    `learning_outcome_id` BIGINT,
    `description` LONGTEXT,
  PRIMARY KEY (id),
  INDEX learning_outcome_id (learning_outcome_id)
  );
  CREATE TABLE IF NOT EXISTS learning_outcome_rubric_criterion_fact (
    `learning_outcome_rubric_criterion_id` BIGINT,
    `learning_outcome_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `points` DOUBLE,
  PRIMARY KEY (learning_outcome_rubric_criterion_id),
  INDEX learning_outcome_id (learning_outcome_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id)
  );
  CREATE TABLE IF NOT EXISTS learning_outcome_group_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `title` VARCHAR(256),
    `parent_group_id` BIGINT,
    `root_group_id` BIGINT,
    `workflow_state` ENUM('active', 'deleted'),
    `description` LONGTEXT,
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `vendor_guid` VARCHAR(256),
    `outcome_import_id` BIGINT,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX parent_group_id (parent_group_id),
  INDEX root_group_id (root_group_id),
  INDEX workflow_state (workflow_state),
  INDEX outcome_import_id (outcome_import_id)
  );
  CREATE TABLE IF NOT EXISTS learning_outcome_group_fact (
    `learning_outcome_group_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `parent_group_id` BIGINT,
    `root_group_id` BIGINT,
    `outcome_import_id` BIGINT,
  PRIMARY KEY (learning_outcome_group_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX parent_group_id (parent_group_id),
  INDEX root_group_id (root_group_id),
  INDEX outcome_import_id (outcome_import_id)
  );
  CREATE TABLE IF NOT EXISTS learning_outcome_group_association_fact (
    `learning_outcome_id` BIGINT,
    `learning_outcome_group_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `pkey` BIGINT NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (pkey),
  INDEX learning_outcome_id (learning_outcome_id),
  INDEX learning_outcome_group_id (learning_outcome_group_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id)
  );
  CREATE TABLE IF NOT EXISTS learning_outcome_result_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `assignment_id` BIGINT,
    `quiz_id` BIGINT,
    `learning_outcome_id` BIGINT,
    `user_id` BIGINT,
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `assessed_at` DATETIME,
    `submitted_at` DATETIME,
    `hide_points` ENUM('false','true'),
    `hidden` ENUM('false','true'),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX assignment_id (assignment_id),
  INDEX quiz_id (quiz_id),
  INDEX learning_outcome_id (learning_outcome_id),
  INDEX user_id (user_id)
  );
  CREATE TABLE IF NOT EXISTS learning_outcome_result_fact (
    `learning_outcome_result_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `assignment_id` BIGINT,
    `quiz_id` BIGINT,
    `learning_outcome_id` BIGINT,
    `user_id` BIGINT,
    `mastery` ENUM('false','true'),
    `score` DOUBLE,
    `attempts` INTEGER UNSIGNED,
    `possible` DOUBLE,
    `original_score` DOUBLE,
    `original_possible` DOUBLE,
    `original_mastery` ENUM('false','true'),
    `percent` DOUBLE,
  PRIMARY KEY (learning_outcome_result_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX assignment_id (assignment_id),
  INDEX quiz_id (quiz_id),
  INDEX learning_outcome_id (learning_outcome_id),
  INDEX user_id (user_id)
  );
  CREATE TABLE IF NOT EXISTS learning_outcome_question_result_dim (
    `id` BIGINT,
    `learning_outcome_result_id` BIGINT,
    `learning_outcome_id` BIGINT,
    `assessment_question_id` BIGINT,
    `title` LONGTEXT,
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `assessed_at` DATETIME,
    `submitted_at` DATETIME,
  PRIMARY KEY (id),
  INDEX learning_outcome_result_id (learning_outcome_result_id),
  INDEX learning_outcome_id (learning_outcome_id),
  INDEX assessment_question_id (assessment_question_id)
  );
  CREATE TABLE IF NOT EXISTS learning_outcome_question_result_fact (
    `learning_outcome_question_result_id` BIGINT,
    `learning_outcome_result_id` BIGINT,
    `learning_outcome_id` BIGINT,
    `assessment_question_id` BIGINT,
    `user_id` BIGINT,
    `account_id` BIGINT,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `assignment_id` BIGINT,
    `quiz_id` BIGINT,
    `mastery` ENUM('false','true'),
    `score` DOUBLE,
    `attempts` INTEGER UNSIGNED,
    `possible` DOUBLE,
    `original_score` DOUBLE,
    `original_possible` DOUBLE,
    `original_mastery` ENUM('false','true'),
    `percent` DOUBLE,
  PRIMARY KEY (learning_outcome_question_result_id),
  INDEX learning_outcome_result_id (learning_outcome_result_id),
  INDEX learning_outcome_id (learning_outcome_id),
  INDEX assessment_question_id (assessment_question_id),
  INDEX user_id (user_id),
  INDEX account_id (account_id),
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX assignment_id (assignment_id),
  INDEX quiz_id (quiz_id)
  );
  CREATE TABLE IF NOT EXISTS quiz_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `root_account_id` BIGINT,
    `name` VARCHAR(256),
    `points_possible` DOUBLE,
    `description` LONGTEXT,
    `quiz_type` ENUM('practice_quiz', 'assignment', 'graded_survey', 'survey', 'NULL'),
    `course_id` BIGINT,
    `assignment_id` BIGINT,
    `workflow_state` ENUM('unpublished', 'published', 'deleted'),
    `scoring_policy` ENUM('keep_highest', 'keep_latest', 'keep_average'),
    `anonymous_submissions` ENUM('allow_anonymous_submissions', 'disallow_anonymous_submissions'),
    `display_questions` ENUM('multiple_at_a_time', 'one_at_a_time', 'one_question_at_a_time'),
    `answer_display_order` ENUM('in_order', 'shuffled', 'shuffle_answers'),
    `go_back_to_previous_question` ENUM('display_questions', 'one_at_a_time', 'allow_going_back', 'disallow_going_back', 'cant_go_back'),
    `could_be_locked` ENUM('allow_locking', 'disallow_locking'),
    `browser_lockdown` ENUM('required', 'not_required'),
    `browser_lockdown_for_displaying_results` ENUM('hide_results', 'never', 'until_after_last_attempt', 'required', 'not_required'),
    `browser_lockdown_monitor` ENUM('required', 'not_required'),
    `ip_filter` VARCHAR(256),
    `show_results` ENUM('always', 'never', 'dw_quiz_fact.allowed_attempts > 1', 'always_after_last_attempt', 'only_once_after_last_attempt', 'hide_results', 'one_time_results'),
    `show_correct_answers` ENUM('s valid only if ', ' is set to ', '. Possible values are ', ', ', ' and ', ' (Last two are only valid if ', ') which have a behavior similar to ', '. Defaults to ', '. Equivalent Canvas API field -> ', ' combined with '),
    `show_correct_answers_at` DATETIME,
    `hide_correct_answers_at` DATETIME,
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `published_at` DATETIME,
    `unlock_at` DATETIME,
    `lock_at` DATETIME,
    `due_at` DATETIME,
    `deleted_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX root_account_id (root_account_id),
  INDEX course_id (course_id),
  INDEX assignment_id (assignment_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS quiz_fact (
    `quiz_id` BIGINT,
    `points_possible` DOUBLE,
    `time_limit` INTEGER UNSIGNED,
    `allowed_attempts` INTEGER UNSIGNED,
    `unpublished_question_count` INTEGER UNSIGNED,
    `question_count` INTEGER UNSIGNED,
    `course_id` BIGINT,
    `assignment_id` BIGINT,
    `course_account_id` BIGINT,
    `enrollment_term_id` BIGINT,
  PRIMARY KEY (quiz_id),
  INDEX course_id (course_id),
  INDEX assignment_id (assignment_id),
  INDEX course_account_id (course_account_id),
  INDEX enrollment_term_id (enrollment_term_id)
  );
  CREATE TABLE IF NOT EXISTS quiz_submission_historical_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `quiz_id` BIGINT,
    `submission_id` BIGINT,
    `user_id` BIGINT,
    `version_number` INTEGER UNSIGNED,
    `submission_state` ENUM('current_submission', 'previous_submission'),
    `workflow_state` ENUM('untaken', 'complete', 'pending_review', 'preview', 'settings_only'),
    `quiz_state_during_submission` VARCHAR(256),
    `submission_scoring_policy` ENUM('s scoring policy. Possible values are ', ' or the general quiz scoring policies', ', ', ' and '),
    `submission_source` ENUM('student', 'test_preview'),
    `has_seen_results` VARCHAR(256),
    `temporary_user_code` VARCHAR(256),
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `started_at` DATETIME,
    `finished_at` DATETIME,
    `due_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX quiz_id (quiz_id),
  INDEX submission_id (submission_id),
  INDEX user_id (user_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS quiz_submission_historical_fact (
    `score` DOUBLE,
    `kept_score` DOUBLE,
    `date` DATETIME,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `course_account_id` BIGINT,
    `quiz_id` BIGINT,
    `assignment_id` BIGINT,
    `user_id` BIGINT,
    `submission_id` BIGINT,
    `enrollment_rollup_id` BIGINT,
    `quiz_submission_historical_id` BIGINT,
    `quiz_points_possible` DOUBLE,
    `score_before_regrade` DOUBLE,
    `fudge_points` DOUBLE,
    `total_attempts` INTEGER UNSIGNED,
    `extra_attempts` INTEGER UNSIGNED,
    `extra_time` INTEGER UNSIGNED,
    `time_taken` INTEGER UNSIGNED,
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX course_account_id (course_account_id),
  INDEX quiz_id (quiz_id),
  INDEX assignment_id (assignment_id),
  INDEX user_id (user_id),
  INDEX submission_id (submission_id),
  INDEX enrollment_rollup_id (enrollment_rollup_id),
  PRIMARY KEY (quiz_submission_historical_id)
  );
  CREATE TABLE IF NOT EXISTS quiz_submission_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `quiz_id` BIGINT,
    `submission_id` BIGINT,
    `user_id` BIGINT,
    `workflow_state` ENUM('untaken', 'complete', 'pending_review', 'preview', 'settings_only', 'essay_question'),
    `quiz_state_during_submission` VARCHAR(256),
    `submission_scoring_policy` ENUM('s scoring policy. Possible values are ', ' or the general quiz scoring policies', ', ', ' and '),
    `submission_source` ENUM('student', 'test_preview'),
    `has_seen_results` VARCHAR(256),
    `temporary_user_code` VARCHAR(256),
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `started_at` DATETIME,
    `finished_at` DATETIME,
    `due_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX quiz_id (quiz_id),
  INDEX submission_id (submission_id),
  INDEX user_id (user_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS quiz_submission_fact (
    `score` DOUBLE,
    `kept_score` DOUBLE,
    `date` DATETIME,
    `course_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `course_account_id` BIGINT,
    `quiz_id` BIGINT,
    `assignment_id` BIGINT,
    `user_id` BIGINT,
    `submission_id` BIGINT,
    `enrollment_rollup_id` BIGINT,
    `quiz_submission_id` BIGINT,
    `quiz_points_possible` DOUBLE,
    `score_before_regrade` DOUBLE,
    `fudge_points` DOUBLE,
    `total_attempts` INTEGER UNSIGNED,
    `extra_attempts` INTEGER UNSIGNED,
    `extra_time` INTEGER UNSIGNED,
    `time_taken` INTEGER UNSIGNED,
  INDEX course_id (course_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX course_account_id (course_account_id),
  INDEX quiz_id (quiz_id),
  INDEX assignment_id (assignment_id),
  INDEX user_id (user_id),
  INDEX submission_id (submission_id),
  INDEX enrollment_rollup_id (enrollment_rollup_id),
  PRIMARY KEY (quiz_submission_id)
  );
  CREATE TABLE IF NOT EXISTS quiz_question_group_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `quiz_id` BIGINT,
    `name` VARCHAR(256),
    `position` INTEGER UNSIGNED,
    `created_at` DATETIME,
    `updated_at` DATETIME,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX quiz_id (quiz_id)
  );
  CREATE TABLE IF NOT EXISTS quiz_question_group_fact (
    `quiz_question_group_id` BIGINT,
    `pick_count` INTEGER UNSIGNED,
    `question_points` DOUBLE,
    `quiz_id` BIGINT,
    `course_id` BIGINT,
    `assignment_id` BIGINT,
    `course_account_id` BIGINT,
    `enrollment_term_id` BIGINT,
  PRIMARY KEY (quiz_question_group_id),
  INDEX quiz_id (quiz_id),
  INDEX course_id (course_id),
  INDEX assignment_id (assignment_id),
  INDEX course_account_id (course_account_id),
  INDEX enrollment_term_id (enrollment_term_id)
  );
  CREATE TABLE IF NOT EXISTS quiz_question_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `quiz_id` BIGINT,
    `quiz_question_group_id` BIGINT,
    `position` INTEGER UNSIGNED,
    `workflow_state` ENUM('unpublished', 'published', 'deleted'),
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `assessment_question_id` BIGINT,
    `assessment_question_version` INTEGER UNSIGNED,
    `name` VARCHAR(256),
    `question_type` ENUM('calculated_question', 'essay_question', 'file_upload_question', 'fill_in_multiple_blanks_question', 'matching_question', 'multiple_answers_question', 'multiple_choice_question', 'multiple_dropdowns_question', 'numerical_question', 'short_answer_question', 'text_only_question', 'true_false_question'),
    `question_text` LONGTEXT,
    `regrade_option` ENUM('available', 'unavailable', 'multiple_answers_question', 'multiple_choice_question', 'true_false_question', 'NULL'),
    `correct_comments` LONGTEXT,
    `incorrect_comments` LONGTEXT,
    `neutral_comments` LONGTEXT,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX quiz_id (quiz_id),
  INDEX quiz_question_group_id (quiz_question_group_id),
  INDEX workflow_state (workflow_state),
  INDEX assessment_question_id (assessment_question_id)
  );
  CREATE TABLE IF NOT EXISTS quiz_question_fact (
    `quiz_question_id` BIGINT,
    `quiz_id` BIGINT,
    `quiz_question_group_id` BIGINT,
    `assessment_question_id` BIGINT,
    `course_id` BIGINT,
    `assignment_id` BIGINT,
    `course_account_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `points_possible` DOUBLE,
  PRIMARY KEY (quiz_question_id),
  INDEX quiz_id (quiz_id),
  INDEX quiz_question_group_id (quiz_question_group_id),
  INDEX assessment_question_id (assessment_question_id),
  INDEX course_id (course_id),
  INDEX assignment_id (assignment_id),
  INDEX course_account_id (course_account_id),
  INDEX enrollment_term_id (enrollment_term_id)
  );
  CREATE TABLE IF NOT EXISTS quiz_question_answer_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `quiz_question_id` BIGINT,
    `text` LONGTEXT,
    `html` LONGTEXT,
    `comments` LONGTEXT,
    `text_after_answers` LONGTEXT,
    `answer_match_left` VARCHAR(256),
    `answer_match_right` VARCHAR(256),
    `matching_answer_incorrect_matches` VARCHAR(256),
    `numerical_answer_type` ENUM('numerical_question', 'NULL', 'exact_answer', 'range_answer'),
    `blank_id` VARCHAR(256),
    `exact` DOUBLE,
    `margin` DOUBLE,
    `starting_range` DOUBLE,
    `ending_range` DOUBLE,
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX quiz_question_id (quiz_question_id),
  INDEX blank_id (blank_id)
  );
  CREATE TABLE IF NOT EXISTS quiz_question_answer_fact (
    `quiz_question_answer_id` BIGINT,
    `quiz_question_id` BIGINT,
    `quiz_question_group_id` BIGINT,
    `quiz_id` BIGINT,
    `assessment_question_id` BIGINT,
    `course_id` BIGINT,
    `assignment_id` BIGINT,
    `course_account_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `weight` DOUBLE,
    `exact` DOUBLE,
    `margin` DOUBLE,
    `starting_range` DOUBLE,
    `ending_range` DOUBLE,
  PRIMARY KEY (quiz_question_answer_id),
  INDEX quiz_question_id (quiz_question_id),
  INDEX quiz_question_group_id (quiz_question_group_id),
  INDEX quiz_id (quiz_id),
  INDEX assessment_question_id (assessment_question_id),
  INDEX course_id (course_id),
  INDEX assignment_id (assignment_id),
  INDEX course_account_id (course_account_id),
  INDEX enrollment_term_id (enrollment_term_id)
  );
  DROP TABLE IF EXISTS requests;
  CREATE TABLE IF NOT EXISTS requests (
    `id` VARCHAR(36),
    `timestamp` DATETIME(3),
    `timestamp_year` VARCHAR(256),
    `timestamp_month` VARCHAR(256),
    `timestamp_day` VARCHAR(256),
    `user_id` BIGINT,
    `course_id` BIGINT,
    `root_account_id` BIGINT,
    `course_account_id` BIGINT,
    `quiz_id` BIGINT,
    `discussion_id` BIGINT,
    `conversation_id` BIGINT,
    `assignment_id` BIGINT,
    `url` LONGTEXT,
    `user_agent` LONGTEXT,
    `http_method` VARCHAR(256),
    `remote_ip` VARCHAR(256),
    `interaction_micros` BIGINT,
    `web_application_controller` VARCHAR(256),
    `web_application_action` VARCHAR(256),
    `web_application_context_type` VARCHAR(256),
    `web_application_context_id` VARCHAR(256),
    `real_user_id` BIGINT,
    `session_id` VARCHAR(256),
    `user_agent_id` BIGINT,
    `http_status` INTEGER UNSIGNED,
    `http_version` VARCHAR(256),
    `developer_key_id` BIGINT,
    `pkey` BIGINT NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (pkey),
  INDEX web_application_controller (web_application_controller),
  INDEX web_application_action (web_application_action),
  INDEX web_application_context_type (web_application_context_type)
  );
  CREATE TABLE IF NOT EXISTS external_tool_activation_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `course_id` BIGINT,
    `account_id` BIGINT,
    `activation_target_type` VARCHAR(256),
    `url` VARCHAR(4096),
    `name` VARCHAR(256),
    `description` VARCHAR(256),
    `workflow_state` ENUM('active', 'deleted'),
    `privacy_level` VARCHAR(256),
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `tool_id` VARCHAR(256),
    `selectable_all` ENUM('false','true'),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX course_id (course_id),
  INDEX account_id (account_id),
  INDEX workflow_state (workflow_state),
  INDEX tool_id (tool_id)
  );
  CREATE TABLE IF NOT EXISTS external_tool_activation_fact (
    `external_tool_activation_id` BIGINT,
    `course_id` BIGINT,
    `account_id` BIGINT,
    `root_account_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `course_account_id` BIGINT,
  PRIMARY KEY (external_tool_activation_id),
  INDEX course_id (course_id),
  INDEX account_id (account_id),
  INDEX root_account_id (root_account_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX course_account_id (course_account_id)
  );
  CREATE TABLE IF NOT EXISTS wiki_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `parent_type` VARCHAR(256),
    `title` LONGTEXT,
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `front_page_url` LONGTEXT,
    `has_no_front_page` ENUM('false','true'),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id)
  );
  CREATE TABLE IF NOT EXISTS wiki_fact (
    `wiki_id` BIGINT,
    `parent_course_id` BIGINT,
    `parent_group_id` BIGINT,
    `parent_course_account_id` BIGINT,
    `parent_group_account_id` BIGINT,
    `account_id` BIGINT,
    `root_account_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `group_category_id` BIGINT,
  PRIMARY KEY (wiki_id),
  INDEX parent_course_id (parent_course_id),
  INDEX parent_group_id (parent_group_id),
  INDEX parent_course_account_id (parent_course_account_id),
  INDEX parent_group_account_id (parent_group_account_id),
  INDEX account_id (account_id),
  INDEX root_account_id (root_account_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX group_category_id (group_category_id)
  );
  CREATE TABLE IF NOT EXISTS wiki_page_dim (
    `id` BIGINT,
    `canvas_id` BIGINT,
    `title` VARCHAR(256),
    `body` LONGTEXT,
    `workflow_state` ENUM('active', 'unpublished', 'deleted'),
    `created_at` DATETIME,
    `updated_at` DATETIME,
    `url` LONGTEXT,
    `protected_editing` ENUM('false','true'),
    `editing_roles` VARCHAR(256),
    `revised_at` DATETIME,
    `could_be_locked` ENUM('false','true'),
  PRIMARY KEY (id),
  UNIQUE KEY canvas_id (canvas_id),
  INDEX workflow_state (workflow_state)
  );
  CREATE TABLE IF NOT EXISTS wiki_page_fact (
    `wiki_page_id` BIGINT,
    `wiki_id` BIGINT,
    `parent_course_id` BIGINT,
    `parent_group_id` BIGINT,
    `parent_course_account_id` BIGINT,
    `parent_group_account_id` BIGINT,
    `user_id` BIGINT,
    `account_id` BIGINT,
    `root_account_id` BIGINT,
    `enrollment_term_id` BIGINT,
    `group_category_id` BIGINT,
    `wiki_page_comments_count` INTEGER UNSIGNED,
    `view_count` INTEGER UNSIGNED,
  PRIMARY KEY (wiki_page_id),
  INDEX wiki_id (wiki_id),
  INDEX parent_course_id (parent_course_id),
  INDEX parent_group_id (parent_group_id),
  INDEX parent_course_account_id (parent_course_account_id),
  INDEX parent_group_account_id (parent_group_account_id),
  INDEX user_id (user_id),
  INDEX account_id (account_id),
  INDEX root_account_id (root_account_id),
  INDEX enrollment_term_id (enrollment_term_id),
  INDEX group_category_id (group_category_id)
  );
  