-- Host: localhost

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
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 */;

--
-- Database: `vmail`
--

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

--
-- Table structure for table `rc_cache`
--

CREATE TABLE `rc_cache` (
  `user_id` int(10) UNSIGNED NOT NULL,
  `cache_key` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `expires` datetime DEFAULT NULL,
  `data` longtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- RELATIONSHIPS FOR TABLE `rc_cache`:
--   `user_id`
--       `rc_users` -> `user_id`
--

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

--
-- Table structure for table `rc_cache_index`
--

CREATE TABLE `rc_cache_index` (
  `user_id` int(10) UNSIGNED NOT NULL,
  `mailbox` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `expires` datetime DEFAULT NULL,
  `valid` tinyint(1) NOT NULL DEFAULT 0,
  `data` longtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- RELATIONSHIPS FOR TABLE `rc_cache_index`:
--   `user_id`
--       `rc_users` -> `user_id`
--

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

--
-- Table structure for table `rc_cache_messages`
--

CREATE TABLE `rc_cache_messages` (
  `user_id` int(10) UNSIGNED NOT NULL,
  `mailbox` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `uid` int(11) UNSIGNED NOT NULL DEFAULT 0,
  `expires` datetime DEFAULT NULL,
  `data` longtext NOT NULL,
  `flags` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- RELATIONSHIPS FOR TABLE `rc_cache_messages`:
--   `user_id`
--       `rc_users` -> `user_id`
--

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

--
-- Table structure for table `rc_cache_shared`
--

CREATE TABLE `rc_cache_shared` (
  `cache_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `expires` datetime DEFAULT NULL,
  `data` longtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- RELATIONSHIPS FOR TABLE `rc_cache_shared`:
--

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

--
-- Table structure for table `rc_cache_thread`
--

CREATE TABLE `rc_cache_thread` (
  `user_id` int(10) UNSIGNED NOT NULL,
  `mailbox` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `expires` datetime DEFAULT NULL,
  `data` longtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- RELATIONSHIPS FOR TABLE `rc_cache_thread`:
--   `user_id`
--       `rc_users` -> `user_id`
--

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

--
-- Table structure for table `rc_carddav_addressbooks`
--

CREATE TABLE `rc_carddav_addressbooks` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `username` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `password` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `url` varchar(4095) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `active` tinyint(3) UNSIGNED NOT NULL DEFAULT 1,
  `user_id` int(10) UNSIGNED NOT NULL,
  `last_updated` timestamp NOT NULL DEFAULT '2000-01-01 08:00:01',
  `refresh_time` time NOT NULL DEFAULT '01:00:00',
  `sync_token` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `presetname` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `use_categories` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- RELATIONSHIPS FOR TABLE `rc_carddav_addressbooks`:
--   `user_id`
--       `rc_users` -> `user_id`
--

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

--
-- Table structure for table `rc_carddav_contacts`
--

CREATE TABLE `rc_carddav_contacts` (
  `id` int(10) UNSIGNED NOT NULL,
  `abook_id` int(10) UNSIGNED NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(4095) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `firstname` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `surname` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `organization` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `showas` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `vcard` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `etag` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `uri` varchar(700) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cuid` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- RELATIONSHIPS FOR TABLE `rc_carddav_contacts`:
--   `abook_id`
--       `rc_carddav_addressbooks` -> `id`
--

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

--
-- Table structure for table `rc_carddav_groups`
--

CREATE TABLE `rc_carddav_groups` (
  `id` int(10) UNSIGNED NOT NULL,
  `abook_id` int(10) UNSIGNED NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `vcard` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `etag` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `uri` varchar(700) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `cuid` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- RELATIONSHIPS FOR TABLE `rc_carddav_groups`:
--   `abook_id`
--       `rc_carddav_addressbooks` -> `id`
--

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

--
-- Table structure for table `rc_carddav_group_user`
--

CREATE TABLE `rc_carddav_group_user` (
  `group_id` int(10) UNSIGNED NOT NULL,
  `contact_id` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- RELATIONSHIPS FOR TABLE `rc_carddav_group_user`:
--   `group_id`
--       `rc_carddav_groups` -> `id`
--   `contact_id`
--       `rc_carddav_contacts` -> `id`
--

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

--
-- Table structure for table `rc_carddav_migrations`
--

CREATE TABLE `rc_carddav_migrations` (
  `ID` bigint(20) UNSIGNED NOT NULL,
  `filename` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `processed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- RELATIONSHIPS FOR TABLE `rc_carddav_migrations`:
--

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

--
-- Table structure for table `rc_carddav_xsubtypes`
--

CREATE TABLE `rc_carddav_xsubtypes` (
  `id` int(10) UNSIGNED NOT NULL,
  `typename` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `subtype` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `abook_id` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- RELATIONSHIPS FOR TABLE `rc_carddav_xsubtypes`:
--   `abook_id`
--       `rc_carddav_addressbooks` -> `id`
--

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

--
-- Table structure for table `rc_contactgroupmembers`
--

CREATE TABLE `rc_contactgroupmembers` (
  `contactgroup_id` int(10) UNSIGNED NOT NULL,
  `contact_id` int(10) UNSIGNED NOT NULL,
  `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- RELATIONSHIPS FOR TABLE `rc_contactgroupmembers`:
--   `contact_id`
--       `rc_contacts` -> `contact_id`
--   `contactgroup_id`
--       `rc_contactgroups` -> `contactgroup_id`
--

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

--
-- Table structure for table `rc_contactgroups`
--

CREATE TABLE `rc_contactgroups` (
  `contactgroup_id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
  `del` tinyint(1) NOT NULL DEFAULT 0,
  `name` varchar(128) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- RELATIONSHIPS FOR TABLE `rc_contactgroups`:
--   `user_id`
--       `rc_users` -> `user_id`
--

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

--
-- Table structure for table `rc_contacts`
--

CREATE TABLE `rc_contacts` (
  `contact_id` int(10) UNSIGNED NOT NULL,
  `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
  `del` tinyint(1) NOT NULL DEFAULT 0,
  `name` varchar(128) NOT NULL DEFAULT '',
  `email` text NOT NULL,
  `firstname` varchar(128) NOT NULL DEFAULT '',
  `surname` varchar(128) NOT NULL DEFAULT '',
  `vcard` longtext DEFAULT NULL,
  `words` text DEFAULT NULL,
  `user_id` int(10) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- RELATIONSHIPS FOR TABLE `rc_contacts`:
--   `user_id`
--       `rc_users` -> `user_id`
--

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

--
-- Table structure for table `rc_dictionary`
--

CREATE TABLE `rc_dictionary` (
  `id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED DEFAULT NULL,
  `language` varchar(5) NOT NULL,
  `data` longtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- RELATIONSHIPS FOR TABLE `rc_dictionary`:
--   `user_id`
--       `rc_users` -> `user_id`
--

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

--
-- Table structure for table `rc_filestore`
--

CREATE TABLE `rc_filestore` (
  `file_id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `context` varchar(32) NOT NULL,
  `filename` varchar(128) NOT NULL,
  `mtime` int(10) NOT NULL,
  `data` longtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- RELATIONSHIPS FOR TABLE `rc_filestore`:
--   `user_id`
--       `rc_users` -> `user_id`
--

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

--
-- Table structure for table `rc_identities`
--

CREATE TABLE `rc_identities` (
  `identity_id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
  `del` tinyint(1) NOT NULL DEFAULT 0,
  `standard` tinyint(1) NOT NULL DEFAULT 0,
  `name` varchar(128) NOT NULL,
  `organization` varchar(128) NOT NULL DEFAULT '',
  `email` varchar(128) NOT NULL,
  `reply-to` varchar(128) NOT NULL DEFAULT '',
  `bcc` varchar(128) NOT NULL DEFAULT '',
  `signature` longtext DEFAULT NULL,
  `html_signature` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- RELATIONSHIPS FOR TABLE `rc_identities`:
--   `user_id`
--       `rc_users` -> `user_id`
--

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

--
-- Table structure for table `rc_searches`
--

CREATE TABLE `rc_searches` (
  `search_id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `type` int(3) NOT NULL DEFAULT 0,
  `name` varchar(128) NOT NULL,
  `data` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- RELATIONSHIPS FOR TABLE `rc_searches`:
--   `user_id`
--       `rc_users` -> `user_id`
--

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

--
-- Table structure for table `rc_session`
--

CREATE TABLE `rc_session` (
  `sess_id` varchar(128) NOT NULL,
  `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
  `ip` varchar(40) NOT NULL,
  `vars` mediumtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- RELATIONSHIPS FOR TABLE `rc_session`:
--

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

--
-- Table structure for table `rc_system`
--

CREATE TABLE `rc_system` (
  `name` varchar(64) NOT NULL,
  `value` mediumtext DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- RELATIONSHIPS FOR TABLE `rc_system`:
--

--
-- Dumping data for table `rc_system`
--

INSERT INTO `rc_system` (`name`, `value`) VALUES
('roundcube-version', '2019092900');

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

--
-- Table structure for table `rc_users`
--

CREATE TABLE `rc_users` (
  `user_id` int(10) UNSIGNED NOT NULL,
  `username` varchar(128) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  `mail_host` varchar(128) NOT NULL,
  `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
  `last_login` datetime DEFAULT NULL,
  `failed_login` datetime DEFAULT NULL,
  `failed_login_counter` int(10) UNSIGNED DEFAULT NULL,
  `language` varchar(5) DEFAULT NULL,
  `preferences` longtext DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- RELATIONSHIPS FOR TABLE `rc_users`:
--

--
-- Indexes for dumped tables
--

--
-- Indexes for table `rc_cache`
--
ALTER TABLE `rc_cache`
  ADD PRIMARY KEY (`user_id`,`cache_key`),
  ADD KEY `expires_index` (`expires`);

--
-- Indexes for table `rc_cache_index`
--
ALTER TABLE `rc_cache_index`
  ADD PRIMARY KEY (`user_id`,`mailbox`),
  ADD KEY `expires_index` (`expires`);

--
-- Indexes for table `rc_cache_messages`
--
ALTER TABLE `rc_cache_messages`
  ADD PRIMARY KEY (`user_id`,`mailbox`,`uid`),
  ADD KEY `expires_index` (`expires`);

--
-- Indexes for table `rc_cache_shared`
--
ALTER TABLE `rc_cache_shared`
  ADD PRIMARY KEY (`cache_key`),
  ADD KEY `expires_index` (`expires`);

--
-- Indexes for table `rc_cache_thread`
--
ALTER TABLE `rc_cache_thread`
  ADD PRIMARY KEY (`user_id`,`mailbox`),
  ADD KEY `expires_index` (`expires`);

--
-- Indexes for table `rc_carddav_addressbooks`
--
ALTER TABLE `rc_carddav_addressbooks`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`) USING BTREE;

--
-- Indexes for table `rc_carddav_contacts`
--
ALTER TABLE `rc_carddav_contacts`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `cuid` (`cuid`(191),`abook_id`) USING BTREE,
  ADD UNIQUE KEY `uri` (`uri`(191),`abook_id`) USING BTREE,
  ADD KEY `abook_id` (`abook_id`);

--
-- Indexes for table `rc_carddav_groups`
--
ALTER TABLE `rc_carddav_groups`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `cuid` (`cuid`(191),`abook_id`) USING BTREE,
  ADD UNIQUE KEY `uri` (`uri`(191),`abook_id`) USING BTREE,
  ADD KEY `abook_id` (`abook_id`);

--
-- Indexes for table `rc_carddav_group_user`
--
ALTER TABLE `rc_carddav_group_user`
  ADD PRIMARY KEY (`group_id`,`contact_id`),
  ADD KEY `contact_id` (`contact_id`);

--
-- Indexes for table `rc_carddav_migrations`
--
ALTER TABLE `rc_carddav_migrations`
  ADD PRIMARY KEY (`ID`),
  ADD UNIQUE KEY `filename` (`filename`);

--
-- Indexes for table `rc_carddav_xsubtypes`
--
ALTER TABLE `rc_carddav_xsubtypes`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `typename` (`typename`,`subtype`,`abook_id`),
  ADD KEY `abook_id` (`abook_id`);

--
-- Indexes for table `rc_contactgroupmembers`
--
ALTER TABLE `rc_contactgroupmembers`
  ADD PRIMARY KEY (`contactgroup_id`,`contact_id`),
  ADD KEY `contactgroupmembers_contact_index` (`contact_id`);

--
-- Indexes for table `rc_contactgroups`
--
ALTER TABLE `rc_contactgroups`
  ADD PRIMARY KEY (`contactgroup_id`),
  ADD KEY `contactgroups_user_index` (`user_id`,`del`);

--
-- Indexes for table `rc_contacts`
--
ALTER TABLE `rc_contacts`
  ADD PRIMARY KEY (`contact_id`),
  ADD KEY `user_contacts_index` (`user_id`,`del`);

--
-- Indexes for table `rc_dictionary`
--
ALTER TABLE `rc_dictionary`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniqueness` (`user_id`,`language`);

--
-- Indexes for table `rc_filestore`
--
ALTER TABLE `rc_filestore`
  ADD PRIMARY KEY (`file_id`),
  ADD UNIQUE KEY `uniqueness` (`user_id`,`context`,`filename`);

--
-- Indexes for table `rc_identities`
--
ALTER TABLE `rc_identities`
  ADD PRIMARY KEY (`identity_id`),
  ADD KEY `user_identities_index` (`user_id`,`del`),
  ADD KEY `email_identities_index` (`email`,`del`);

--
-- Indexes for table `rc_searches`
--
ALTER TABLE `rc_searches`
  ADD PRIMARY KEY (`search_id`),
  ADD UNIQUE KEY `uniqueness` (`user_id`,`type`,`name`);

--
-- Indexes for table `rc_session`
--
ALTER TABLE `rc_session`
  ADD PRIMARY KEY (`sess_id`),
  ADD KEY `changed_index` (`changed`);

--
-- Indexes for table `rc_system`
--
ALTER TABLE `rc_system`
  ADD PRIMARY KEY (`name`);

--
-- Indexes for table `rc_users`
--
ALTER TABLE `rc_users`
  ADD PRIMARY KEY (`user_id`),
  ADD UNIQUE KEY `username` (`username`,`mail_host`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `rc_carddav_addressbooks`
--
ALTER TABLE `rc_carddav_addressbooks`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `rc_carddav_contacts`
--
ALTER TABLE `rc_carddav_contacts`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `rc_carddav_groups`
--
ALTER TABLE `rc_carddav_groups`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `rc_carddav_migrations`
--
ALTER TABLE `rc_carddav_migrations`
  MODIFY `ID` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `rc_carddav_xsubtypes`
--
ALTER TABLE `rc_carddav_xsubtypes`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `rc_contactgroups`
--
ALTER TABLE `rc_contactgroups`
  MODIFY `contactgroup_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `rc_contacts`
--
ALTER TABLE `rc_contacts`
  MODIFY `contact_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `rc_dictionary`
--
ALTER TABLE `rc_dictionary`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `rc_filestore`
--
ALTER TABLE `rc_filestore`
  MODIFY `file_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `rc_identities`
--
ALTER TABLE `rc_identities`
  MODIFY `identity_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `rc_searches`
--
ALTER TABLE `rc_searches`
  MODIFY `search_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `rc_users`
--
ALTER TABLE `rc_users`
  MODIFY `user_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `rc_cache`
--
ALTER TABLE `rc_cache`
  ADD CONSTRAINT `user_id_fk_cache` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_cache_index`
--
ALTER TABLE `rc_cache_index`
  ADD CONSTRAINT `user_id_fk_cache_index` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_cache_messages`
--
ALTER TABLE `rc_cache_messages`
  ADD CONSTRAINT `user_id_fk_cache_messages` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_cache_thread`
--
ALTER TABLE `rc_cache_thread`
  ADD CONSTRAINT `user_id_fk_cache_thread` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_carddav_addressbooks`
--
ALTER TABLE `rc_carddav_addressbooks`
  ADD CONSTRAINT `rc_carddav_addressbooks_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_carddav_contacts`
--
ALTER TABLE `rc_carddav_contacts`
  ADD CONSTRAINT `rc_carddav_contacts_ibfk_1` FOREIGN KEY (`abook_id`) REFERENCES `rc_carddav_addressbooks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_carddav_groups`
--
ALTER TABLE `rc_carddav_groups`
  ADD CONSTRAINT `rc_carddav_groups_ibfk_1` FOREIGN KEY (`abook_id`) REFERENCES `rc_carddav_addressbooks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_carddav_group_user`
--
ALTER TABLE `rc_carddav_group_user`
  ADD CONSTRAINT `rc_carddav_group_user_ibfk_1` FOREIGN KEY (`group_id`) REFERENCES `rc_carddav_groups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `rc_carddav_group_user_ibfk_2` FOREIGN KEY (`contact_id`) REFERENCES `rc_carddav_contacts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_carddav_xsubtypes`
--
ALTER TABLE `rc_carddav_xsubtypes`
  ADD CONSTRAINT `rc_carddav_xsubtypes_ibfk_1` FOREIGN KEY (`abook_id`) REFERENCES `rc_carddav_addressbooks` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_contactgroupmembers`
--
ALTER TABLE `rc_contactgroupmembers`
  ADD CONSTRAINT `contact_id_fk_contacts` FOREIGN KEY (`contact_id`) REFERENCES `rc_contacts` (`contact_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `contactgroup_id_fk_contactgroups` FOREIGN KEY (`contactgroup_id`) REFERENCES `rc_contactgroups` (`contactgroup_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_contactgroups`
--
ALTER TABLE `rc_contactgroups`
  ADD CONSTRAINT `user_id_fk_contactgroups` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_contacts`
--
ALTER TABLE `rc_contacts`
  ADD CONSTRAINT `user_id_fk_contacts` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_dictionary`
--
ALTER TABLE `rc_dictionary`
  ADD CONSTRAINT `user_id_fk_dictionary` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_filestore`
--
ALTER TABLE `rc_filestore`
  ADD CONSTRAINT `user_id_fk_filestore` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_identities`
--
ALTER TABLE `rc_identities`
  ADD CONSTRAINT `user_id_fk_identities` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `rc_searches`
--
ALTER TABLE `rc_searches`
  ADD CONSTRAINT `user_id_fk_searches` FOREIGN KEY (`user_id`) REFERENCES `rc_users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
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 */;
