-- phpMyAdmin SQL Dump
-- version 4.8.4
-- https://www.phpmyadmin.net/
--
-- Host: dd3632
-- Erstellungszeit: 19. Feb 2019 um 20:48
-- Server-Version: 5.7.21-nmm1-log
-- PHP-Version: 5.6.38-nmm2

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Datenbank: `d02ca25a`
--

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `appointment`
--

DROP TABLE IF EXISTS `appointment`;
CREATE TABLE `appointment` (
                             `id` int(10) UNSIGNED NOT NULL,
                             `team_id` int(10) UNSIGNED NOT NULL,
                             `subject` varchar(255) NOT NULL,
                             `start_dt` datetime NOT NULL,
                             `end_dt` datetime NOT NULL,
                             `deadline_dt` datetime NOT NULL,
                             `serial_id` int(10) UNSIGNED DEFAULT NULL,
                             `min_attendees` int(11) DEFAULT NULL,
                             `max_attendees` int(11) DEFAULT NULL,
                             `location` varchar(255) DEFAULT NULL,
                             `comment` text,
                             `state` enum('open','cancelled') NOT NULL DEFAULT 'open'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `attendee`
--

DROP TABLE IF EXISTS `attendee`;
CREATE TABLE `attendee` (
                          `id` int(10) UNSIGNED NOT NULL,
                          `appointment_id` int(10) UNSIGNED NOT NULL,
                          `profile_id` int(10) UNSIGNED NOT NULL,
                          `status` set('accepted','declined','waiting') NOT NULL,
                          `has_attended` enum('accepted','declined') DEFAULT NULL,
                          `last_update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                          `created_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `chat`
--

DROP TABLE IF EXISTS `chat`;
CREATE TABLE `chat` (
                      `id` int(11) NOT NULL,
                      `ref_id` varchar(64) CHARACTER SET latin1 NOT NULL,
                      `creator_profile_id` int(11) DEFAULT NULL,
                      `message` text NOT NULL,
                      `last_updated_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                      `created_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `message`
--

DROP TABLE IF EXISTS `message`;
CREATE TABLE `message` (
                         `id` int(11) NOT NULL,
                         `creator_id` int(11) DEFAULT NULL,
                         `recipient_id` int(11) NOT NULL,
                         `conversation_id` int(11) DEFAULT NULL,
                         `subject` varchar(64) CHARACTER SET latin1 NOT NULL,
                         `message` text CHARACTER SET latin1 NOT NULL,
                         `is_read` tinyint(4) NOT NULL DEFAULT '0',
                         `last_updated_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                         `created_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `notification`
--

DROP TABLE IF EXISTS `notification`;
CREATE TABLE `notification` (
                              `id` int(11) NOT NULL,
                              `ref_id` varchar(64) CHARACTER SET latin1 DEFAULT NULL,
                              `receiver_profile_id` int(11) NOT NULL,
                              `creator_profile_id` int(11) DEFAULT NULL,
                              `creator_name` varchar(64) CHARACTER SET latin1 DEFAULT NULL,
                              `headline` varchar(512) DEFAULT NULL,
                              `message` varchar(512) DEFAULT NULL,
                              `additional_data_js` json DEFAULT NULL,
                              `is_read` tinyint(1) NOT NULL DEFAULT '0',
                              `last_updated_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                              `created_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `premium_log`
--

DROP TABLE IF EXISTS `premium_log`;
CREATE TABLE `premium_log` (
                             `id` int(11) NOT NULL,
                             `braintree_customer_id` varchar(255) NOT NULL,
                             `braintree_subscription_id` varchar(255) NOT NULL,
                             `account_id` int(11) NOT NULL,
                             `team_id` int(11) NOT NULL,
                             `package_id` varchar(32) NOT NULL,
                             `package_price` float NOT NULL,
                             `package_tax` float NOT NULL,
                             `valid_from_dt` datetime NOT NULL,
                             `valid_until_dt` datetime NOT NULL,
                             `billing_company_name` varchar(255) DEFAULT NULL,
                             `billing_company_tax_id` varchar(255) DEFAULT NULL,
                             `billing_first_name` varchar(255) NOT NULL,
                             `billing_last_name` varchar(255) NOT NULL,
                             `billing_street` varchar(255) NOT NULL,
                             `billing_zip` varchar(255) NOT NULL,
                             `billing_city` varchar(255) NOT NULL,
                             `billing_country` varchar(128) NOT NULL,
                             `billing_email` varchar(255) NOT NULL,
                             `status` varchar(255) DEFAULT NULL,
                             `comment` text,
                             `last_update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                             `created_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `profile`
--

DROP TABLE IF EXISTS `profile`;
CREATE TABLE `profile` (
                         `id` int(10) UNSIGNED NOT NULL,
                         `account_id` int(10) UNSIGNED NOT NULL,
                         `visibility` enum('public','private') CHARACTER SET latin1 NOT NULL DEFAULT 'public',
                         `pic_url` varchar(512) CHARACTER SET latin1 DEFAULT NULL,
                         `pic_cloud_id` varchar(64) CHARACTER SET latin1 DEFAULT NULL,
                         `gender` enum('male','female') CHARACTER SET latin1 NOT NULL DEFAULT 'male',
                         `first_name` varchar(255) DEFAULT NULL,
                         `last_name` varchar(255) DEFAULT NULL,
                         `birthday` date DEFAULT NULL,
                         `street` varchar(255) DEFAULT NULL,
                         `zip_code` varchar(32) DEFAULT NULL,
                         `city` varchar(255) DEFAULT NULL,
                         `phone` varchar(64) DEFAULT NULL,
                         `mobile` varchar(32) CHARACTER SET latin1 DEFAULT NULL,
                         `misc` varchar(255) DEFAULT NULL,
                         `teams_js` json DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `profile_timestamp`
--

DROP TABLE IF EXISTS `profile_timestamp`;
CREATE TABLE `profile_timestamp` (
                                   `id` int(10) UNSIGNED NOT NULL,
                                   `profile_id` int(10) UNSIGNED NOT NULL,
                                   `last_online_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
                                   `last_notification_update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Tabellenstruktur für Tabelle `team`
--

DROP TABLE IF EXISTS `team`;
CREATE TABLE `team` (
                      `id` int(10) UNSIGNED NOT NULL,
                      `public_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
                      `display_name` varchar(255) NOT NULL,
                      `category` varchar(32) CHARACTER SET latin1 DEFAULT NULL,
                      `description` varchar(1024) DEFAULT NULL,
                      `emblem_url` varchar(512) CHARACTER SET latin1 DEFAULT NULL,
                      `emblem_cloud_id` varchar(64) CHARACTER SET latin1 DEFAULT NULL,
                      `last_updated_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                      `created_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Indizes der exportierten Tabellen
--

--
-- Indizes für die Tabelle `appointment`
--
ALTER TABLE `appointment`
  ADD PRIMARY KEY (`id`),
  ADD KEY `serial_id` (`serial_id`);

--
-- Indizes für die Tabelle `attendee`
--
ALTER TABLE `attendee`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `appointment_id_2` (`appointment_id`,`profile_id`),
  ADD KEY `appointment_id` (`appointment_id`);

--
-- Indizes für die Tabelle `chat`
--
ALTER TABLE `chat`
  ADD PRIMARY KEY (`id`),
  ADD KEY `ref_id` (`ref_id`);

--
-- Indizes für die Tabelle `message`
--
ALTER TABLE `message`
  ADD PRIMARY KEY (`id`),
  ADD KEY `creator_id` (`creator_id`),
  ADD KEY `recipient_id` (`recipient_id`),
  ADD KEY `conversation_id` (`conversation_id`);

--
-- Indizes für die Tabelle `notification`
--
ALTER TABLE `notification`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_receiver_profile_id` (`receiver_profile_id`),
  ADD KEY `ref_id` (`ref_id`),
  ADD KEY `ref_id_2` (`ref_id`,`receiver_profile_id`,`is_read`);

--
-- Indizes für die Tabelle `premium_log`
--
ALTER TABLE `premium_log`
  ADD PRIMARY KEY (`id`),
  ADD KEY `braintreecustomerid` (`braintree_customer_id`(191));

--
-- Indizes für die Tabelle `profile`
--
ALTER TABLE `profile`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `account_id` (`account_id`);

--
-- Indizes für die Tabelle `profile_timestamp`
--
ALTER TABLE `profile_timestamp`
  ADD PRIMARY KEY (`id`);

--
-- Indizes für die Tabelle `team`
--
ALTER TABLE `team`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `public_id` (`public_id`);

--
-- AUTO_INCREMENT für exportierte Tabellen
--

--
-- AUTO_INCREMENT für Tabelle `appointment`
--
ALTER TABLE `appointment`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `attendee`
--
ALTER TABLE `attendee`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `chat`
--
ALTER TABLE `chat`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `message`
--
ALTER TABLE `message`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `notification`
--
ALTER TABLE `notification`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `premium_log`
--
ALTER TABLE `premium_log`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `profile`
--
ALTER TABLE `profile`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `profile_timestamp`
--
ALTER TABLE `profile_timestamp`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT für Tabelle `team`
--
ALTER TABLE `team`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;