{
  "name": "countmein",
  "tables": [
    {
      "name": "current_organization_calendars",
      "type": "VIEW",
      "comment": "VIEW",
      "columns": [
        {
          "name": "organization_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "calendar_id",
          "type": "bigint(20)",
          "nullable": false
        }
      ],
      "def": "CREATE VIEW current_organization_calendars AS (select `och`.`organization_id` AS `organization_id`,`och`.`calendar_id` AS `calendar_id` from `s25101270_countmein`.`organization_calendars_history` `och` where `och`.`added` = 1 and `och`.`created_at` = (select max(`och2`.`created_at`) from `s25101270_countmein`.`organization_calendars_history` `och2` where `och`.`organization_id` = `och2`.`organization_id` and `och`.`calendar_id` = `och2`.`calendar_id`))",
      "referenced_tables": [
        "organization_calendars_history"
      ]
    },
    {
      "name": "calendars_organizations_labels",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "calendar_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "organization_label_id",
          "type": "bigint(20)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "fk_calendars_organizations_labels_organization_label_id",
          "def": "KEY fk_calendars_organizations_labels_organization_label_id (organization_label_id) USING BTREE",
          "table": "calendars_organizations_labels",
          "columns": [
            "organization_label_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (calendar_id, organization_label_id) USING BTREE",
          "table": "calendars_organizations_labels",
          "columns": [
            "calendar_id",
            "organization_label_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "fk_calendars_organizations_labels_calendar_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (calendar_id) REFERENCES calendars (calendar_id)",
          "table": "calendars_organizations_labels",
          "referenced_table": "calendars",
          "columns": [
            "calendar_id"
          ],
          "referenced_columns": [
            "calendar_id"
          ]
        },
        {
          "name": "fk_calendars_organizations_labels_organization_label_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (organization_label_id) REFERENCES organizations_labels (organization_label_id)",
          "table": "calendars_organizations_labels",
          "referenced_table": "organizations_labels",
          "columns": [
            "organization_label_id"
          ],
          "referenced_columns": [
            "organization_label_id"
          ]
        },
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (calendar_id, organization_label_id)",
          "table": "calendars_organizations_labels",
          "columns": [
            "calendar_id",
            "organization_label_id"
          ]
        }
      ],
      "def": "CREATE TABLE `calendars_organizations_labels` (\n  `calendar_id` bigint(20) NOT NULL,\n  `organization_label_id` bigint(20) NOT NULL,\n  PRIMARY KEY (`calendar_id`,`organization_label_id`),\n  KEY `fk_calendars_organizations_labels_organization_label_id` (`organization_label_id`),\n  CONSTRAINT `fk_calendars_organizations_labels_calendar_id` FOREIGN KEY (`calendar_id`) REFERENCES `calendars` (`calendar_id`) ON DELETE CASCADE,\n  CONSTRAINT `fk_calendars_organizations_labels_organization_label_id` FOREIGN KEY (`organization_label_id`) REFERENCES `organizations_labels` (`organization_label_id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "current_member_roles",
      "type": "VIEW",
      "comment": "VIEW",
      "columns": [
        {
          "name": "organization_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "member_user_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "role",
          "type": "enum('owner','admin','user')",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime(6)",
          "nullable": false
        }
      ],
      "def": "CREATE VIEW current_member_roles AS (select `mrh`.`organization_id` AS `organization_id`,`mrh`.`member_user_id` AS `member_user_id`,`mrh`.`role` AS `role`,`mrh`.`created_at` AS `created_at` from (`s25101270_countmein`.`member_roles_history` `mrh` join `s25101270_countmein`.`current_memberships` `cm` on(`mrh`.`organization_id` = `cm`.`organization_id` and `mrh`.`member_user_id` = `cm`.`member_user_id`)) where `mrh`.`created_at` = (select max(`mrh2`.`created_at`) from `s25101270_countmein`.`member_roles_history` `mrh2` where `mrh`.`organization_id` = `mrh2`.`organization_id` and `mrh`.`member_user_id` = `mrh2`.`member_user_id`))",
      "referenced_tables": [
        "member_roles_history",
        "current_memberships"
      ]
    },
    {
      "name": "calendars_users_labels",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "calendar_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "user_label_id",
          "type": "bigint(20)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "fk_calendars_users_labels_user_label_id",
          "def": "KEY fk_calendars_users_labels_user_label_id (user_label_id) USING BTREE",
          "table": "calendars_users_labels",
          "columns": [
            "user_label_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (calendar_id, user_label_id) USING BTREE",
          "table": "calendars_users_labels",
          "columns": [
            "calendar_id",
            "user_label_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "fk_calendars_users_labels_calendar_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (calendar_id) REFERENCES calendars (calendar_id)",
          "table": "calendars_users_labels",
          "referenced_table": "calendars",
          "columns": [
            "calendar_id"
          ],
          "referenced_columns": [
            "calendar_id"
          ]
        },
        {
          "name": "fk_calendars_users_labels_user_label_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (user_label_id) REFERENCES users_labels (user_label_id)",
          "table": "calendars_users_labels",
          "referenced_table": "users_labels",
          "columns": [
            "user_label_id"
          ],
          "referenced_columns": [
            "user_label_id"
          ]
        },
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (calendar_id, user_label_id)",
          "table": "calendars_users_labels",
          "columns": [
            "calendar_id",
            "user_label_id"
          ]
        }
      ],
      "def": "CREATE TABLE `calendars_users_labels` (\n  `calendar_id` bigint(20) NOT NULL,\n  `user_label_id` bigint(20) NOT NULL,\n  PRIMARY KEY (`calendar_id`,`user_label_id`),\n  KEY `fk_calendars_users_labels_user_label_id` (`user_label_id`),\n  CONSTRAINT `fk_calendars_users_labels_calendar_id` FOREIGN KEY (`calendar_id`) REFERENCES `calendars` (`calendar_id`) ON DELETE CASCADE,\n  CONSTRAINT `fk_calendars_users_labels_user_label_id` FOREIGN KEY (`user_label_id`) REFERENCES `users_labels` (`user_label_id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "member_moderations_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "member_moderation_event_id",
          "type": "bigint(20)",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "organization_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "member_user_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "admin_user_id",
          "type": "bigint(20)",
          "nullable": true,
          "default": "NULL"
        },
        {
          "name": "created_at",
          "type": "datetime(6)",
          "nullable": false
        },
        {
          "name": "reason",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "expires_at",
          "type": "datetime(6)",
          "nullable": true,
          "default": "NULL"
        },
        {
          "name": "action",
          "type": "enum('ban','unban')",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "fk_member_moderations_history_admin_user_id",
          "def": "KEY fk_member_moderations_history_admin_user_id (admin_user_id) USING BTREE",
          "table": "member_moderations_history",
          "columns": [
            "admin_user_id"
          ]
        },
        {
          "name": "fk_member_moderations_history_member_user_id",
          "def": "KEY fk_member_moderations_history_member_user_id (member_user_id) USING BTREE",
          "table": "member_moderations_history",
          "columns": [
            "member_user_id"
          ]
        },
        {
          "name": "fk_member_moderations_history_organization_id",
          "def": "KEY fk_member_moderations_history_organization_id (organization_id) USING BTREE",
          "table": "member_moderations_history",
          "columns": [
            "organization_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (member_moderation_event_id) USING BTREE",
          "table": "member_moderations_history",
          "columns": [
            "member_moderation_event_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "fk_member_moderations_history_admin_user_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (admin_user_id) REFERENCES users (user_id)",
          "table": "member_moderations_history",
          "referenced_table": "users",
          "columns": [
            "admin_user_id"
          ],
          "referenced_columns": [
            "user_id"
          ]
        },
        {
          "name": "fk_member_moderations_history_member_user_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (member_user_id) REFERENCES users (user_id)",
          "table": "member_moderations_history",
          "referenced_table": "users",
          "columns": [
            "member_user_id"
          ],
          "referenced_columns": [
            "user_id"
          ]
        },
        {
          "name": "fk_member_moderations_history_organization_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (organization_id) REFERENCES organizations (organization_id)",
          "table": "member_moderations_history",
          "referenced_table": "organizations",
          "columns": [
            "organization_id"
          ],
          "referenced_columns": [
            "organization_id"
          ]
        },
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (member_moderation_event_id)",
          "table": "member_moderations_history",
          "columns": [
            "member_moderation_event_id"
          ]
        }
      ],
      "def": "CREATE TABLE `member_moderations_history` (\n  `member_moderation_event_id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `organization_id` bigint(20) NOT NULL,\n  `member_user_id` bigint(20) NOT NULL,\n  `admin_user_id` bigint(20) DEFAULT NULL,\n  `created_at` datetime(6) NOT NULL,\n  `reason` varchar(255) NOT NULL,\n  `expires_at` datetime(6) DEFAULT NULL,\n  `action` enum('ban','unban') NOT NULL,\n  PRIMARY KEY (`member_moderation_event_id`),\n  KEY `fk_member_moderations_history_admin_user_id` (`admin_user_id`),\n  KEY `fk_member_moderations_history_member_user_id` (`member_user_id`),\n  KEY `fk_member_moderations_history_organization_id` (`organization_id`),\n  CONSTRAINT `fk_member_moderations_history_admin_user_id` FOREIGN KEY (`admin_user_id`) REFERENCES `users` (`user_id`) ON DELETE SET NULL,\n  CONSTRAINT `fk_member_moderations_history_member_user_id` FOREIGN KEY (`member_user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE,\n  CONSTRAINT `fk_member_moderations_history_organization_id` FOREIGN KEY (`organization_id`) REFERENCES `organizations` (`organization_id`) ON DELETE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "join_response_details",
      "type": "VIEW",
      "comment": "VIEW",
      "columns": [
        {
          "name": "join_response_event_id",
          "type": "bigint(20)",
          "nullable": false,
          "default": "0"
        },
        {
          "name": "join_prompt_event_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "responder_user_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "response",
          "type": "text",
          "nullable": false
        },
        {
          "name": "organization_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "owner_user_id",
          "type": "bigint(20)",
          "nullable": true,
          "default": "NULL"
        },
        {
          "name": "prompt",
          "type": "text",
          "nullable": false
        },
        {
          "name": "response_created_at",
          "type": "datetime(6)",
          "nullable": false
        },
        {
          "name": "prompt_created_at",
          "type": "datetime(6)",
          "nullable": false
        }
      ],
      "def": "CREATE VIEW join_response_details AS (select `jrh`.`join_response_event_id` AS `join_response_event_id`,`jrh`.`join_prompt_event_id` AS `join_prompt_event_id`,`jrh`.`responder_user_id` AS `responder_user_id`,`jrh`.`response` AS `response`,`jph`.`organization_id` AS `organization_id`,`jph`.`owner_user_id` AS `owner_user_id`,`jph`.`prompt` AS `prompt`,`jrh`.`created_at` AS `response_created_at`,`jph`.`created_at` AS `prompt_created_at` from (`s25101270_countmein`.`join_responses_history` `jrh` join `s25101270_countmein`.`join_prompts_history` `jph` on(`jrh`.`join_prompt_event_id` = `jph`.`join_prompt_event_id`)))",
      "referenced_tables": [
        "join_responses_history",
        "join_prompts_history"
      ]
    },
    {
      "name": "organization_members_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "organization_member_event_id",
          "type": "bigint(20)",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "organization_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "member_user_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "added",
          "type": "tinyint(1)",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime(6)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "fk_organization_members_history_member_user_id",
          "def": "KEY fk_organization_members_history_member_user_id (member_user_id) USING BTREE",
          "table": "organization_members_history",
          "columns": [
            "member_user_id"
          ]
        },
        {
          "name": "fk_organization_members_history_organization_id",
          "def": "KEY fk_organization_members_history_organization_id (organization_id) USING BTREE",
          "table": "organization_members_history",
          "columns": [
            "organization_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (organization_member_event_id) USING BTREE",
          "table": "organization_members_history",
          "columns": [
            "organization_member_event_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "fk_organization_members_history_member_user_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (member_user_id) REFERENCES users (user_id)",
          "table": "organization_members_history",
          "referenced_table": "users",
          "columns": [
            "member_user_id"
          ],
          "referenced_columns": [
            "user_id"
          ]
        },
        {
          "name": "fk_organization_members_history_organization_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (organization_id) REFERENCES organizations (organization_id)",
          "table": "organization_members_history",
          "referenced_table": "organizations",
          "columns": [
            "organization_id"
          ],
          "referenced_columns": [
            "organization_id"
          ]
        },
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (organization_member_event_id)",
          "table": "organization_members_history",
          "columns": [
            "organization_member_event_id"
          ]
        }
      ],
      "def": "CREATE TABLE `organization_members_history` (\n  `organization_member_event_id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `organization_id` bigint(20) NOT NULL,\n  `member_user_id` bigint(20) NOT NULL,\n  `added` tinyint(1) NOT NULL,\n  `created_at` datetime(6) NOT NULL,\n  PRIMARY KEY (`organization_member_event_id`),\n  KEY `fk_organization_members_history_member_user_id` (`member_user_id`),\n  KEY `fk_organization_members_history_organization_id` (`organization_id`),\n  CONSTRAINT `fk_organization_members_history_member_user_id` FOREIGN KEY (`member_user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE,\n  CONSTRAINT `fk_organization_members_history_organization_id` FOREIGN KEY (`organization_id`) REFERENCES `organizations` (`organization_id`) ON DELETE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "current_memberships",
      "type": "VIEW",
      "comment": "VIEW",
      "columns": [
        {
          "name": "organization_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "member_user_id",
          "type": "bigint(20)",
          "nullable": false
        }
      ],
      "def": "CREATE VIEW current_memberships AS (select `omh`.`organization_id` AS `organization_id`,`omh`.`member_user_id` AS `member_user_id` from `s25101270_countmein`.`organization_members_history` `omh` where `omh`.`added` = 1 and `omh`.`created_at` = (select max(`omh2`.`created_at`) from `s25101270_countmein`.`organization_members_history` `omh2` where `omh`.`organization_id` = `omh2`.`organization_id` and `omh`.`member_user_id` = `omh2`.`member_user_id`))",
      "referenced_tables": [
        "organization_members_history"
      ]
    },
    {
      "name": "users",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "user_id",
          "type": "bigint(20)",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "email",
          "type": "varchar(320)",
          "nullable": false
        },
        {
          "name": "first_name",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "last_name",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "password_hash",
          "type": "varbinary(255)",
          "nullable": false
        },
        {
          "name": "middle_name",
          "type": "varchar(255)",
          "nullable": true,
          "default": "NULL"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (user_id) USING BTREE",
          "table": "users",
          "columns": [
            "user_id"
          ]
        },
        {
          "name": "uq_users_email",
          "def": "UNIQUE KEY uq_users_email (email) USING BTREE",
          "table": "users",
          "columns": [
            "email"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (user_id)",
          "table": "users",
          "columns": [
            "user_id"
          ]
        },
        {
          "name": "uq_users_email",
          "type": "UNIQUE",
          "def": "UNIQUE KEY uq_users_email (email)",
          "table": "users",
          "columns": [
            "email"
          ]
        }
      ],
      "def": "CREATE TABLE `users` (\n  `user_id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `email` varchar(320) NOT NULL,\n  `first_name` varchar(255) NOT NULL,\n  `last_name` varchar(255) NOT NULL,\n  `password_hash` varbinary(255) NOT NULL,\n  `middle_name` varchar(255) DEFAULT NULL,\n  PRIMARY KEY (`user_id`),\n  UNIQUE KEY `uq_users_email` (`email`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "join_responses_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "join_response_event_id",
          "type": "bigint(20)",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "join_prompt_event_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "response",
          "type": "text",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime(6)",
          "nullable": false
        },
        {
          "name": "responder_user_id",
          "type": "bigint(20)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "fk_join_responses_history_join_prompt_event_id",
          "def": "KEY fk_join_responses_history_join_prompt_event_id (join_prompt_event_id) USING BTREE",
          "table": "join_responses_history",
          "columns": [
            "join_prompt_event_id"
          ]
        },
        {
          "name": "fk_join_responses_history_responder_user_id",
          "def": "KEY fk_join_responses_history_responder_user_id (responder_user_id) USING BTREE",
          "table": "join_responses_history",
          "columns": [
            "responder_user_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (join_response_event_id) USING BTREE",
          "table": "join_responses_history",
          "columns": [
            "join_response_event_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "fk_join_responses_history_join_prompt_event_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (join_prompt_event_id) REFERENCES join_prompts_history (join_prompt_event_id)",
          "table": "join_responses_history",
          "referenced_table": "join_prompts_history",
          "columns": [
            "join_prompt_event_id"
          ],
          "referenced_columns": [
            "join_prompt_event_id"
          ]
        },
        {
          "name": "fk_join_responses_history_responder_user_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (responder_user_id) REFERENCES users (user_id)",
          "table": "join_responses_history",
          "referenced_table": "users",
          "columns": [
            "responder_user_id"
          ],
          "referenced_columns": [
            "user_id"
          ]
        },
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (join_response_event_id)",
          "table": "join_responses_history",
          "columns": [
            "join_response_event_id"
          ]
        }
      ],
      "def": "CREATE TABLE `join_responses_history` (\n  `join_response_event_id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `join_prompt_event_id` bigint(20) NOT NULL,\n  `response` text NOT NULL,\n  `created_at` datetime(6) NOT NULL,\n  `responder_user_id` bigint(20) NOT NULL,\n  PRIMARY KEY (`join_response_event_id`),\n  KEY `fk_join_responses_history_join_prompt_event_id` (`join_prompt_event_id`),\n  KEY `fk_join_responses_history_responder_user_id` (`responder_user_id`),\n  CONSTRAINT `fk_join_responses_history_join_prompt_event_id` FOREIGN KEY (`join_prompt_event_id`) REFERENCES `join_prompts_history` (`join_prompt_event_id`) ON DELETE CASCADE,\n  CONSTRAINT `fk_join_responses_history_responder_user_id` FOREIGN KEY (`responder_user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "organizations_labels",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "organization_label_id",
          "type": "bigint(20)",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "organization_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "name",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "color",
          "type": "char(6)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "fk_organizations_labels_organization_id",
          "def": "KEY fk_organizations_labels_organization_id (organization_id) USING BTREE",
          "table": "organizations_labels",
          "columns": [
            "organization_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (organization_label_id) USING BTREE",
          "table": "organizations_labels",
          "columns": [
            "organization_label_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "fk_organizations_labels_organization_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (organization_id) REFERENCES organizations (organization_id)",
          "table": "organizations_labels",
          "referenced_table": "organizations",
          "columns": [
            "organization_id"
          ],
          "referenced_columns": [
            "organization_id"
          ]
        },
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (organization_label_id)",
          "table": "organizations_labels",
          "columns": [
            "organization_label_id"
          ]
        }
      ],
      "def": "CREATE TABLE `organizations_labels` (\n  `organization_label_id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `organization_id` bigint(20) NOT NULL,\n  `name` varchar(255) NOT NULL,\n  `color` char(6) NOT NULL,\n  PRIMARY KEY (`organization_label_id`),\n  KEY `fk_organizations_labels_organization_id` (`organization_id`),\n  CONSTRAINT `fk_organizations_labels_organization_id` FOREIGN KEY (`organization_id`) REFERENCES `organizations` (`organization_id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "calendars",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "calendar_id",
          "type": "bigint(20)",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "owner_user_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "name",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "description",
          "type": "text",
          "nullable": true,
          "default": "NULL"
        }
      ],
      "indexes": [
        {
          "name": "fk_calendars_owner_user_id",
          "def": "KEY fk_calendars_owner_user_id (owner_user_id) USING BTREE",
          "table": "calendars",
          "columns": [
            "owner_user_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (calendar_id) USING BTREE",
          "table": "calendars",
          "columns": [
            "calendar_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "fk_calendars_owner_user_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (owner_user_id) REFERENCES users (user_id)",
          "table": "calendars",
          "referenced_table": "users",
          "columns": [
            "owner_user_id"
          ],
          "referenced_columns": [
            "user_id"
          ]
        },
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (calendar_id)",
          "table": "calendars",
          "columns": [
            "calendar_id"
          ]
        }
      ],
      "def": "CREATE TABLE `calendars` (\n  `calendar_id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `owner_user_id` bigint(20) NOT NULL,\n  `name` varchar(255) NOT NULL,\n  `description` text DEFAULT NULL,\n  PRIMARY KEY (`calendar_id`),\n  KEY `fk_calendars_owner_user_id` (`owner_user_id`),\n  CONSTRAINT `fk_calendars_owner_user_id` FOREIGN KEY (`owner_user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "join_prompts_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "join_prompt_event_id",
          "type": "bigint(20)",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "organization_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "owner_user_id",
          "type": "bigint(20)",
          "nullable": true,
          "default": "NULL"
        },
        {
          "name": "prompt",
          "type": "text",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime(6)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "fk_join_prompts_history_organization_id",
          "def": "KEY fk_join_prompts_history_organization_id (organization_id) USING BTREE",
          "table": "join_prompts_history",
          "columns": [
            "organization_id"
          ]
        },
        {
          "name": "fk_join_prompts_history_owner_user_id",
          "def": "KEY fk_join_prompts_history_owner_user_id (owner_user_id) USING BTREE",
          "table": "join_prompts_history",
          "columns": [
            "owner_user_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (join_prompt_event_id) USING BTREE",
          "table": "join_prompts_history",
          "columns": [
            "join_prompt_event_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "fk_join_prompts_history_organization_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (organization_id) REFERENCES organizations (organization_id)",
          "table": "join_prompts_history",
          "referenced_table": "organizations",
          "columns": [
            "organization_id"
          ],
          "referenced_columns": [
            "organization_id"
          ]
        },
        {
          "name": "fk_join_prompts_history_owner_user_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (owner_user_id) REFERENCES users (user_id)",
          "table": "join_prompts_history",
          "referenced_table": "users",
          "columns": [
            "owner_user_id"
          ],
          "referenced_columns": [
            "user_id"
          ]
        },
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (join_prompt_event_id)",
          "table": "join_prompts_history",
          "columns": [
            "join_prompt_event_id"
          ]
        }
      ],
      "def": "CREATE TABLE `join_prompts_history` (\n  `join_prompt_event_id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `organization_id` bigint(20) NOT NULL,\n  `owner_user_id` bigint(20) DEFAULT NULL,\n  `prompt` text NOT NULL,\n  `created_at` datetime(6) NOT NULL,\n  PRIMARY KEY (`join_prompt_event_id`),\n  KEY `fk_join_prompts_history_organization_id` (`organization_id`),\n  KEY `fk_join_prompts_history_owner_user_id` (`owner_user_id`),\n  CONSTRAINT `fk_join_prompts_history_organization_id` FOREIGN KEY (`organization_id`) REFERENCES `organizations` (`organization_id`) ON DELETE CASCADE,\n  CONSTRAINT `fk_join_prompts_history_owner_user_id` FOREIGN KEY (`owner_user_id`) REFERENCES `users` (`user_id`) ON DELETE SET NULL\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "join_requests_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "join_request_event_id",
          "type": "bigint(20)",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "join_response_event_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime(6)",
          "nullable": false
        },
        {
          "name": "status",
          "type": "enum('open','retracted','accepted','denied')",
          "nullable": false
        },
        {
          "name": "actor_user_id",
          "type": "bigint(20)",
          "nullable": true,
          "default": "NULL"
        }
      ],
      "indexes": [
        {
          "name": "fk_join_requests_history_actor_user_id",
          "def": "KEY fk_join_requests_history_actor_user_id (actor_user_id) USING BTREE",
          "table": "join_requests_history",
          "columns": [
            "actor_user_id"
          ]
        },
        {
          "name": "fk_join_requests_history_join_response_event_id",
          "def": "KEY fk_join_requests_history_join_response_event_id (join_response_event_id) USING BTREE",
          "table": "join_requests_history",
          "columns": [
            "join_response_event_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (join_request_event_id) USING BTREE",
          "table": "join_requests_history",
          "columns": [
            "join_request_event_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "fk_join_requests_history_actor_user_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (actor_user_id) REFERENCES users (user_id)",
          "table": "join_requests_history",
          "referenced_table": "users",
          "columns": [
            "actor_user_id"
          ],
          "referenced_columns": [
            "user_id"
          ]
        },
        {
          "name": "fk_join_requests_history_join_response_event_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (join_response_event_id) REFERENCES join_responses_history (join_response_event_id)",
          "table": "join_requests_history",
          "referenced_table": "join_responses_history",
          "columns": [
            "join_response_event_id"
          ],
          "referenced_columns": [
            "join_response_event_id"
          ]
        },
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (join_request_event_id)",
          "table": "join_requests_history",
          "columns": [
            "join_request_event_id"
          ]
        }
      ],
      "def": "CREATE TABLE `join_requests_history` (\n  `join_request_event_id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `join_response_event_id` bigint(20) NOT NULL,\n  `created_at` datetime(6) NOT NULL,\n  `status` enum('open','retracted','accepted','denied') NOT NULL,\n  `actor_user_id` bigint(20) DEFAULT NULL,\n  PRIMARY KEY (`join_request_event_id`),\n  KEY `fk_join_requests_history_join_response_event_id` (`join_response_event_id`),\n  KEY `fk_join_requests_history_actor_user_id` (`actor_user_id`),\n  CONSTRAINT `fk_join_requests_history_actor_user_id` FOREIGN KEY (`actor_user_id`) REFERENCES `users` (`user_id`) ON DELETE SET NULL,\n  CONSTRAINT `fk_join_requests_history_join_response_event_id` FOREIGN KEY (`join_response_event_id`) REFERENCES `join_responses_history` (`join_response_event_id`) ON DELETE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "users_labels",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "user_label_id",
          "type": "bigint(20)",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "user_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "name",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "color",
          "type": "char(6)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "fk_users_labels_user_id",
          "def": "KEY fk_users_labels_user_id (user_id) USING BTREE",
          "table": "users_labels",
          "columns": [
            "user_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (user_label_id) USING BTREE",
          "table": "users_labels",
          "columns": [
            "user_label_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "fk_users_labels_user_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (user_id) REFERENCES users (user_id)",
          "table": "users_labels",
          "referenced_table": "users",
          "columns": [
            "user_id"
          ],
          "referenced_columns": [
            "user_id"
          ]
        },
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (user_label_id)",
          "table": "users_labels",
          "columns": [
            "user_label_id"
          ]
        }
      ],
      "def": "CREATE TABLE `users_labels` (\n  `user_label_id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `user_id` bigint(20) NOT NULL,\n  `name` varchar(255) NOT NULL,\n  `color` char(6) NOT NULL,\n  PRIMARY KEY (`user_label_id`),\n  KEY `fk_users_labels_user_id` (`user_id`),\n  CONSTRAINT `fk_users_labels_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "organization_calendars_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "organization_calendar_event_id",
          "type": "bigint(20)",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "organization_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "calendar_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "admin_user_id",
          "type": "bigint(20)",
          "nullable": true,
          "default": "NULL"
        },
        {
          "name": "added",
          "type": "tinyint(1)",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime(6)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "fk_organization_calendars_history_admin_user_id",
          "def": "KEY fk_organization_calendars_history_admin_user_id (admin_user_id) USING BTREE",
          "table": "organization_calendars_history",
          "columns": [
            "admin_user_id"
          ]
        },
        {
          "name": "fk_organization_calendars_history_calendar_id",
          "def": "KEY fk_organization_calendars_history_calendar_id (calendar_id) USING BTREE",
          "table": "organization_calendars_history",
          "columns": [
            "calendar_id"
          ]
        },
        {
          "name": "fk_organization_calendars_history_organization_id",
          "def": "KEY fk_organization_calendars_history_organization_id (organization_id) USING BTREE",
          "table": "organization_calendars_history",
          "columns": [
            "organization_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (organization_calendar_event_id) USING BTREE",
          "table": "organization_calendars_history",
          "columns": [
            "organization_calendar_event_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "fk_organization_calendars_history_admin_user_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (admin_user_id) REFERENCES users (user_id)",
          "table": "organization_calendars_history",
          "referenced_table": "users",
          "columns": [
            "admin_user_id"
          ],
          "referenced_columns": [
            "user_id"
          ]
        },
        {
          "name": "fk_organization_calendars_history_calendar_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (calendar_id) REFERENCES calendars (calendar_id)",
          "table": "organization_calendars_history",
          "referenced_table": "calendars",
          "columns": [
            "calendar_id"
          ],
          "referenced_columns": [
            "calendar_id"
          ]
        },
        {
          "name": "fk_organization_calendars_history_organization_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (organization_id) REFERENCES organizations (organization_id)",
          "table": "organization_calendars_history",
          "referenced_table": "organizations",
          "columns": [
            "organization_id"
          ],
          "referenced_columns": [
            "organization_id"
          ]
        },
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (organization_calendar_event_id)",
          "table": "organization_calendars_history",
          "columns": [
            "organization_calendar_event_id"
          ]
        }
      ],
      "def": "CREATE TABLE `organization_calendars_history` (\n  `organization_calendar_event_id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `organization_id` bigint(20) NOT NULL,\n  `calendar_id` bigint(20) NOT NULL,\n  `admin_user_id` bigint(20) DEFAULT NULL,\n  `added` tinyint(1) NOT NULL,\n  `created_at` datetime(6) NOT NULL,\n  PRIMARY KEY (`organization_calendar_event_id`),\n  KEY `fk_organization_calendars_history_admin_user_id` (`admin_user_id`),\n  KEY `fk_organization_calendars_history_calendar_id` (`calendar_id`),\n  KEY `fk_organization_calendars_history_organization_id` (`organization_id`),\n  CONSTRAINT `fk_organization_calendars_history_admin_user_id` FOREIGN KEY (`admin_user_id`) REFERENCES `users` (`user_id`) ON DELETE SET NULL,\n  CONSTRAINT `fk_organization_calendars_history_calendar_id` FOREIGN KEY (`calendar_id`) REFERENCES `calendars` (`calendar_id`) ON DELETE CASCADE,\n  CONSTRAINT `fk_organization_calendars_history_organization_id` FOREIGN KEY (`organization_id`) REFERENCES `organizations` (`organization_id`) ON DELETE CASCADE\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "users_sessions",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "session_hash",
          "type": "binary(32)",
          "nullable": false
        },
        {
          "name": "user_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "expires_at",
          "type": "datetime(6)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "fk_users_sessions_user_id",
          "def": "KEY fk_users_sessions_user_id (user_id) USING BTREE",
          "table": "users_sessions",
          "columns": [
            "user_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (session_hash) USING BTREE",
          "table": "users_sessions",
          "columns": [
            "session_hash"
          ]
        }
      ],
      "constraints": [
        {
          "name": "fk_users_sessions_user_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (user_id) REFERENCES users (user_id)",
          "table": "users_sessions",
          "referenced_table": "users",
          "columns": [
            "user_id"
          ],
          "referenced_columns": [
            "user_id"
          ]
        },
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (session_hash)",
          "table": "users_sessions",
          "columns": [
            "session_hash"
          ]
        }
      ],
      "def": "CREATE TABLE `users_sessions` (\n  `session_hash` binary(32) NOT NULL,\n  `user_id` bigint(20) NOT NULL,\n  `expires_at` datetime(6) NOT NULL,\n  PRIMARY KEY (`session_hash`),\n  KEY `fk_users_sessions_user_id` (`user_id`),\n  CONSTRAINT `fk_users_sessions_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "member_roles_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "member_role_event_id",
          "type": "bigint(20)",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "organization_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "member_user_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "owner_user_id",
          "type": "bigint(20)",
          "nullable": true,
          "default": "NULL"
        },
        {
          "name": "created_at",
          "type": "datetime(6)",
          "nullable": false
        },
        {
          "name": "role",
          "type": "enum('owner','admin','user')",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "fk_member_roles_history_member_user_id",
          "def": "KEY fk_member_roles_history_member_user_id (member_user_id) USING BTREE",
          "table": "member_roles_history",
          "columns": [
            "member_user_id"
          ]
        },
        {
          "name": "fk_member_roles_history_organization_id",
          "def": "KEY fk_member_roles_history_organization_id (organization_id) USING BTREE",
          "table": "member_roles_history",
          "columns": [
            "organization_id"
          ]
        },
        {
          "name": "fk_member_roles_history_owner_user_id",
          "def": "KEY fk_member_roles_history_owner_user_id (owner_user_id) USING BTREE",
          "table": "member_roles_history",
          "columns": [
            "owner_user_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (member_role_event_id) USING BTREE",
          "table": "member_roles_history",
          "columns": [
            "member_role_event_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "fk_member_roles_history_member_user_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (member_user_id) REFERENCES users (user_id)",
          "table": "member_roles_history",
          "referenced_table": "users",
          "columns": [
            "member_user_id"
          ],
          "referenced_columns": [
            "user_id"
          ]
        },
        {
          "name": "fk_member_roles_history_organization_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (organization_id) REFERENCES organizations (organization_id)",
          "table": "member_roles_history",
          "referenced_table": "organizations",
          "columns": [
            "organization_id"
          ],
          "referenced_columns": [
            "organization_id"
          ]
        },
        {
          "name": "fk_member_roles_history_owner_user_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (owner_user_id) REFERENCES users (user_id)",
          "table": "member_roles_history",
          "referenced_table": "users",
          "columns": [
            "owner_user_id"
          ],
          "referenced_columns": [
            "user_id"
          ]
        },
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (member_role_event_id)",
          "table": "member_roles_history",
          "columns": [
            "member_role_event_id"
          ]
        }
      ],
      "def": "CREATE TABLE `member_roles_history` (\n  `member_role_event_id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `organization_id` bigint(20) NOT NULL,\n  `member_user_id` bigint(20) NOT NULL,\n  `owner_user_id` bigint(20) DEFAULT NULL,\n  `created_at` datetime(6) NOT NULL,\n  `role` enum('owner','admin','user') NOT NULL,\n  PRIMARY KEY (`member_role_event_id`),\n  KEY `fk_member_roles_history_member_user_id` (`member_user_id`),\n  KEY `fk_member_roles_history_organization_id` (`organization_id`),\n  KEY `fk_member_roles_history_owner_user_id` (`owner_user_id`),\n  CONSTRAINT `fk_member_roles_history_member_user_id` FOREIGN KEY (`member_user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE,\n  CONSTRAINT `fk_member_roles_history_organization_id` FOREIGN KEY (`organization_id`) REFERENCES `organizations` (`organization_id`) ON DELETE CASCADE,\n  CONSTRAINT `fk_member_roles_history_owner_user_id` FOREIGN KEY (`owner_user_id`) REFERENCES `users` (`user_id`) ON DELETE SET NULL\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "open_join_requests",
      "type": "VIEW",
      "comment": "VIEW",
      "columns": [
        {
          "name": "join_request_event_id",
          "type": "bigint(20)",
          "nullable": false,
          "default": "0"
        },
        {
          "name": "join_response_event_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "actor_user_id",
          "type": "bigint(20)",
          "nullable": true,
          "default": "NULL"
        },
        {
          "name": "created_at",
          "type": "datetime(6)",
          "nullable": false
        },
        {
          "name": "responder_user_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "organization_id",
          "type": "bigint(20)",
          "nullable": false
        }
      ],
      "def": "CREATE VIEW open_join_requests AS (select `jrh`.`join_request_event_id` AS `join_request_event_id`,`jrh`.`join_response_event_id` AS `join_response_event_id`,`jrh`.`actor_user_id` AS `actor_user_id`,`jrh`.`created_at` AS `created_at`,`jrd`.`responder_user_id` AS `responder_user_id`,`jrd`.`organization_id` AS `organization_id` from (`s25101270_countmein`.`join_requests_history` `jrh` join `s25101270_countmein`.`join_response_details` `jrd` on(`jrh`.`join_response_event_id` = `jrd`.`join_response_event_id`)) where `jrh`.`status` = 'open' and `jrh`.`created_at` = (select max(`jrh2`.`created_at`) from (`s25101270_countmein`.`join_requests_history` `jrh2` join `s25101270_countmein`.`join_response_details` `jrd2` on(`jrh2`.`join_response_event_id` = `jrd2`.`join_response_event_id`)) where `jrd2`.`responder_user_id` = `jrd`.`responder_user_id` and `jrd2`.`organization_id` = `jrd`.`organization_id`))",
      "referenced_tables": [
        "join_requests_history",
        "join_response_details"
      ]
    },
    {
      "name": "calendar_writes_history",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "calendar_write_event_id",
          "type": "bigint(20)",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "calendar_id",
          "type": "bigint(20)",
          "nullable": false
        },
        {
          "name": "writer_user_id",
          "type": "bigint(20)",
          "nullable": true,
          "default": "NULL"
        },
        {
          "name": "ical_encrypted",
          "type": "longblob",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime(6)",
          "nullable": false
        }
      ],
      "indexes": [
        {
          "name": "fk_calendar_writes_history_calendar_id",
          "def": "KEY fk_calendar_writes_history_calendar_id (calendar_id) USING BTREE",
          "table": "calendar_writes_history",
          "columns": [
            "calendar_id"
          ]
        },
        {
          "name": "fk_calendar_writes_history_writer_user_id",
          "def": "KEY fk_calendar_writes_history_writer_user_id (writer_user_id) USING BTREE",
          "table": "calendar_writes_history",
          "columns": [
            "writer_user_id"
          ]
        },
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (calendar_write_event_id) USING BTREE",
          "table": "calendar_writes_history",
          "columns": [
            "calendar_write_event_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "fk_calendar_writes_history_calendar_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (calendar_id) REFERENCES calendars (calendar_id)",
          "table": "calendar_writes_history",
          "referenced_table": "calendars",
          "columns": [
            "calendar_id"
          ],
          "referenced_columns": [
            "calendar_id"
          ]
        },
        {
          "name": "fk_calendar_writes_history_writer_user_id",
          "type": "FOREIGN KEY",
          "def": "FOREIGN KEY (writer_user_id) REFERENCES users (user_id)",
          "table": "calendar_writes_history",
          "referenced_table": "users",
          "columns": [
            "writer_user_id"
          ],
          "referenced_columns": [
            "user_id"
          ]
        },
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (calendar_write_event_id)",
          "table": "calendar_writes_history",
          "columns": [
            "calendar_write_event_id"
          ]
        }
      ],
      "def": "CREATE TABLE `calendar_writes_history` (\n  `calendar_write_event_id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `calendar_id` bigint(20) NOT NULL,\n  `writer_user_id` bigint(20) DEFAULT NULL,\n  `ical_encrypted` longblob NOT NULL,\n  `created_at` datetime(6) NOT NULL,\n  PRIMARY KEY (`calendar_write_event_id`),\n  KEY `fk_calendar_writes_history_calendar_id` (`calendar_id`),\n  KEY `fk_calendar_writes_history_writer_user_id` (`writer_user_id`),\n  CONSTRAINT `fk_calendar_writes_history_calendar_id` FOREIGN KEY (`calendar_id`) REFERENCES `calendars` (`calendar_id`) ON DELETE CASCADE,\n  CONSTRAINT `fk_calendar_writes_history_writer_user_id` FOREIGN KEY (`writer_user_id`) REFERENCES `users` (`user_id`) ON DELETE SET NULL\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    },
    {
      "name": "organizations",
      "type": "BASE TABLE",
      "columns": [
        {
          "name": "organization_id",
          "type": "bigint(20)",
          "nullable": false,
          "extra_def": "auto_increment"
        },
        {
          "name": "name",
          "type": "varchar(255)",
          "nullable": false
        },
        {
          "name": "requires_join_request",
          "type": "tinyint(1)",
          "nullable": false
        },
        {
          "name": "created_at",
          "type": "datetime(6)",
          "nullable": false
        },
        {
          "name": "description",
          "type": "text",
          "nullable": true,
          "default": "NULL"
        }
      ],
      "indexes": [
        {
          "name": "PRIMARY",
          "def": "PRIMARY KEY (organization_id) USING BTREE",
          "table": "organizations",
          "columns": [
            "organization_id"
          ]
        }
      ],
      "constraints": [
        {
          "name": "PRIMARY",
          "type": "PRIMARY KEY",
          "def": "PRIMARY KEY (organization_id)",
          "table": "organizations",
          "columns": [
            "organization_id"
          ]
        }
      ],
      "def": "CREATE TABLE `organizations` (\n  `organization_id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `name` varchar(255) NOT NULL,\n  `requires_join_request` tinyint(1) NOT NULL,\n  `created_at` datetime(6) NOT NULL,\n  `description` text DEFAULT NULL,\n  PRIMARY KEY (`organization_id`)\n) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci"
    }
  ],
  "relations": [
    {
      "table": "calendars_organizations_labels",
      "columns": [
        "calendar_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "calendars",
      "parent_columns": [
        "calendar_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (calendar_id) REFERENCES calendars (calendar_id)"
    },
    {
      "table": "calendars_organizations_labels",
      "columns": [
        "organization_label_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "organizations_labels",
      "parent_columns": [
        "organization_label_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (organization_label_id) REFERENCES organizations_labels (organization_label_id)"
    },
    {
      "table": "calendars_users_labels",
      "columns": [
        "calendar_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "calendars",
      "parent_columns": [
        "calendar_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (calendar_id) REFERENCES calendars (calendar_id)"
    },
    {
      "table": "calendars_users_labels",
      "columns": [
        "user_label_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "users_labels",
      "parent_columns": [
        "user_label_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (user_label_id) REFERENCES users_labels (user_label_id)"
    },
    {
      "table": "member_moderations_history",
      "columns": [
        "admin_user_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "users",
      "parent_columns": [
        "user_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (admin_user_id) REFERENCES users (user_id)"
    },
    {
      "table": "member_moderations_history",
      "columns": [
        "member_user_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "users",
      "parent_columns": [
        "user_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (member_user_id) REFERENCES users (user_id)"
    },
    {
      "table": "member_moderations_history",
      "columns": [
        "organization_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "organizations",
      "parent_columns": [
        "organization_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (organization_id) REFERENCES organizations (organization_id)"
    },
    {
      "table": "organization_members_history",
      "columns": [
        "member_user_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "users",
      "parent_columns": [
        "user_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (member_user_id) REFERENCES users (user_id)"
    },
    {
      "table": "organization_members_history",
      "columns": [
        "organization_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "organizations",
      "parent_columns": [
        "organization_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (organization_id) REFERENCES organizations (organization_id)"
    },
    {
      "table": "join_responses_history",
      "columns": [
        "join_prompt_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "join_prompts_history",
      "parent_columns": [
        "join_prompt_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (join_prompt_event_id) REFERENCES join_prompts_history (join_prompt_event_id)"
    },
    {
      "table": "join_responses_history",
      "columns": [
        "responder_user_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "users",
      "parent_columns": [
        "user_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (responder_user_id) REFERENCES users (user_id)"
    },
    {
      "table": "organizations_labels",
      "columns": [
        "organization_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "organizations",
      "parent_columns": [
        "organization_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (organization_id) REFERENCES organizations (organization_id)"
    },
    {
      "table": "calendars",
      "columns": [
        "owner_user_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "users",
      "parent_columns": [
        "user_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (owner_user_id) REFERENCES users (user_id)"
    },
    {
      "table": "join_prompts_history",
      "columns": [
        "organization_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "organizations",
      "parent_columns": [
        "organization_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (organization_id) REFERENCES organizations (organization_id)"
    },
    {
      "table": "join_prompts_history",
      "columns": [
        "owner_user_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "users",
      "parent_columns": [
        "user_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (owner_user_id) REFERENCES users (user_id)"
    },
    {
      "table": "join_requests_history",
      "columns": [
        "actor_user_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "users",
      "parent_columns": [
        "user_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (actor_user_id) REFERENCES users (user_id)"
    },
    {
      "table": "join_requests_history",
      "columns": [
        "join_response_event_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "join_responses_history",
      "parent_columns": [
        "join_response_event_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (join_response_event_id) REFERENCES join_responses_history (join_response_event_id)"
    },
    {
      "table": "users_labels",
      "columns": [
        "user_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "users",
      "parent_columns": [
        "user_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (user_id) REFERENCES users (user_id)"
    },
    {
      "table": "organization_calendars_history",
      "columns": [
        "admin_user_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "users",
      "parent_columns": [
        "user_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (admin_user_id) REFERENCES users (user_id)"
    },
    {
      "table": "organization_calendars_history",
      "columns": [
        "calendar_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "calendars",
      "parent_columns": [
        "calendar_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (calendar_id) REFERENCES calendars (calendar_id)"
    },
    {
      "table": "organization_calendars_history",
      "columns": [
        "organization_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "organizations",
      "parent_columns": [
        "organization_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (organization_id) REFERENCES organizations (organization_id)"
    },
    {
      "table": "users_sessions",
      "columns": [
        "user_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "users",
      "parent_columns": [
        "user_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (user_id) REFERENCES users (user_id)"
    },
    {
      "table": "member_roles_history",
      "columns": [
        "member_user_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "users",
      "parent_columns": [
        "user_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (member_user_id) REFERENCES users (user_id)"
    },
    {
      "table": "member_roles_history",
      "columns": [
        "organization_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "organizations",
      "parent_columns": [
        "organization_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (organization_id) REFERENCES organizations (organization_id)"
    },
    {
      "table": "member_roles_history",
      "columns": [
        "owner_user_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "users",
      "parent_columns": [
        "user_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (owner_user_id) REFERENCES users (user_id)"
    },
    {
      "table": "calendar_writes_history",
      "columns": [
        "calendar_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "calendars",
      "parent_columns": [
        "calendar_id"
      ],
      "parent_cardinality": "exactly_one",
      "def": "FOREIGN KEY (calendar_id) REFERENCES calendars (calendar_id)"
    },
    {
      "table": "calendar_writes_history",
      "columns": [
        "writer_user_id"
      ],
      "cardinality": "zero_or_more",
      "parent_table": "users",
      "parent_columns": [
        "user_id"
      ],
      "parent_cardinality": "zero_or_one",
      "def": "FOREIGN KEY (writer_user_id) REFERENCES users (user_id)"
    }
  ],
  "functions": [
    {
      "name": "ban_member",
      "return_type": "",
      "arguments": "p_actor_user_id bigint; p_organization_id bigint; p_member_user_id bigint; p_reason varchar; p_expires_at_secs bigint",
      "type": "PROCEDURE"
    },
    {
      "name": "create_calendar",
      "return_type": "",
      "arguments": "p_actor_user_id bigint; p_name varchar; p_ical longblob; p_description text; p_AES_SECRET_KEY binary; out_calendar_id bigint",
      "type": "PROCEDURE"
    },
    {
      "name": "create_join_request",
      "return_type": "",
      "arguments": "p_actor_user_id bigint; p_join_response_event_id bigint; out_join_request_event_id bigint",
      "type": "PROCEDURE"
    },
    {
      "name": "create_organization",
      "return_type": "",
      "arguments": "p_actor_user_id bigint; p_name varchar; p_requires_join_request tinyint; p_description text; out_organization_id bigint",
      "type": "PROCEDURE"
    },
    {
      "name": "join_organization",
      "return_type": "",
      "arguments": "p_actor_user_id bigint; p_organization_id bigint",
      "type": "PROCEDURE"
    },
    {
      "name": "leave_organization",
      "return_type": "",
      "arguments": "p_actor_user_id bigint; p_organization_id bigint",
      "type": "PROCEDURE"
    },
    {
      "name": "must_have_one_owner",
      "return_type": "",
      "arguments": "p_organization_id bigint",
      "type": "PROCEDURE"
    },
    {
      "name": "resolve_join_request",
      "return_type": "",
      "arguments": "p_actor_user_id bigint; p_organization_id bigint; p_requester_user_id bigint; p_accept tinyint",
      "type": "PROCEDURE"
    },
    {
      "name": "set_member_role",
      "return_type": "",
      "arguments": "p_actor_user_id bigint; p_organization_id bigint; p_member_user_id bigint; p_role enum",
      "type": "PROCEDURE"
    },
    {
      "name": "SSELECT",
      "return_type": "",
      "arguments": "p_table varchar; p_database varchar; p_where varchar",
      "type": "PROCEDURE"
    },
    {
      "name": "toggle_share_user_calendar",
      "return_type": "",
      "arguments": "p_actor_user_id bigint; p_organization_id bigint; p_calendar_id bigint",
      "type": "PROCEDURE"
    },
    {
      "name": "unsafe_add_member",
      "return_type": "",
      "arguments": "p_organization_id bigint; p_unsafe_user_id bigint",
      "type": "PROCEDURE"
    }
  ],
  "driver": {
    "name": "mysql",
    "database_version": "10.11.14-MariaDB-0+deb12u2",
    "meta": {
      "dict": {
        "Functions": "Stored procedures and functions"
      }
    }
  }
}
