-- ------------------------------------------------------------- -- TablePlus 6.4.8(608) -- -- https://tableplus.com/ -- -- Database: geo_app -- Generation Time: 2025-06-09 18:03:43.5140 -- ------------------------------------------------------------- /*!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 */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; CREATE TABLE `chat_anonymous_users` ( `id` varchar(50) NOT NULL, `device_id` varchar(100) NOT NULL, `name` varchar(100) DEFAULT NULL, `email` varchar(100) DEFAULT NULL, `created_at` timestamp NOT NULL DEFAULT current_timestamp(), `converted_to_user_id` int(10) unsigned DEFAULT NULL, `metadata` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`metadata`)), PRIMARY KEY (`id`), KEY `idx_device_id` (`device_id`), KEY `idx_converted_user` (`converted_to_user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `chat_attachments` ( `id` varchar(50) NOT NULL, `fk_message` varchar(50) NOT NULL, `file_name` varchar(255) NOT NULL, `file_path` varchar(500) NOT NULL, `file_type` varchar(100) NOT NULL, `file_size` int(10) unsigned NOT NULL, `created_at` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `idx_message` (`fk_message`), CONSTRAINT `fk_chat_attachments_message` FOREIGN KEY (`fk_message`) REFERENCES `chat_messages` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `chat_audience_targets` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fk_room` varchar(50) NOT NULL, `target_type` enum('role','entity','all','combined') NOT NULL DEFAULT 'all', `target_id` varchar(50) DEFAULT NULL, `role_filter` varchar(20) DEFAULT NULL, `entity_filter` varchar(50) DEFAULT NULL, `date_creation` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `idx_room` (`fk_room`), KEY `idx_type` (`target_type`), CONSTRAINT `fk_chat_audience_targets_room` FOREIGN KEY (`fk_room`) REFERENCES `chat_rooms` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `chat_broadcast_lists` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fk_room` varchar(50) NOT NULL, `name` varchar(100) NOT NULL, `description` text DEFAULT NULL, `fk_user_creator` int(10) unsigned NOT NULL, `date_creation` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `idx_room` (`fk_room`), KEY `idx_user_creator` (`fk_user_creator`), CONSTRAINT `fk_chat_broadcast_lists_room` FOREIGN KEY (`fk_room`) REFERENCES `chat_rooms` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `chat_messages` ( `id` varchar(50) NOT NULL, `fk_room` varchar(50) NOT NULL, `fk_user` int(10) unsigned DEFAULT NULL, `sender_type` enum('user','anonymous','system') NOT NULL DEFAULT 'user', `content` text DEFAULT NULL, `content_type` enum('text','image','file') NOT NULL DEFAULT 'text', `date_sent` timestamp NOT NULL DEFAULT current_timestamp(), `date_delivered` timestamp NULL DEFAULT NULL, `date_read` timestamp NULL DEFAULT NULL, `statut` enum('envoye','livre','lu','error') NOT NULL DEFAULT 'envoye', `is_announcement` tinyint(1) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `idx_room` (`fk_room`), KEY `idx_user` (`fk_user`), KEY `idx_date` (`date_sent`), KEY `idx_status` (`statut`), KEY `idx_messages_unread` (`fk_room`,`statut`), CONSTRAINT `fk_chat_messages_room` FOREIGN KEY (`fk_room`) REFERENCES `chat_rooms` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `chat_notifications` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `fk_user` int(10) unsigned NOT NULL, `fk_message` varchar(50) DEFAULT NULL, `fk_room` varchar(50) DEFAULT NULL, `type` varchar(50) NOT NULL, `contenu` text DEFAULT NULL, `date_creation` timestamp NOT NULL DEFAULT current_timestamp(), `date_lecture` timestamp NULL DEFAULT NULL, `statut` enum('non_lue','lue') NOT NULL DEFAULT 'non_lue', PRIMARY KEY (`id`), KEY `idx_user` (`fk_user`), KEY `idx_message` (`fk_message`), KEY `idx_room` (`fk_room`), KEY `idx_statut` (`statut`), KEY `idx_notifications_unread` (`fk_user`,`statut`), CONSTRAINT `fk_chat_notifications_message` FOREIGN KEY (`fk_message`) REFERENCES `chat_messages` (`id`) ON DELETE SET NULL, CONSTRAINT `fk_chat_notifications_room` FOREIGN KEY (`fk_room`) REFERENCES `chat_rooms` (`id`) ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `chat_offline_queue` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(10) unsigned NOT NULL, `operation_type` varchar(50) NOT NULL, `operation_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`operation_data`)), `created_at` timestamp NOT NULL DEFAULT current_timestamp(), `processed_at` timestamp NULL DEFAULT NULL, `status` enum('pending','processing','completed','failed') NOT NULL DEFAULT 'pending', `error_message` text DEFAULT NULL, PRIMARY KEY (`id`), KEY `idx_user_id` (`user_id`), KEY `idx_status` (`status`), KEY `idx_created_at` (`created_at`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `chat_participants` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id_room` varchar(50) NOT NULL, `id_user` int(10) unsigned DEFAULT NULL, `anonymous_id` varchar(50) DEFAULT NULL, `role` enum('administrateur','participant','en_lecture_seule') NOT NULL DEFAULT 'participant', `date_ajout` timestamp NOT NULL DEFAULT current_timestamp(), `notification_activee` tinyint(1) unsigned NOT NULL DEFAULT 1, `last_read_message_id` varchar(50) DEFAULT NULL, `via_target` tinyint(1) unsigned NOT NULL DEFAULT 0, `can_reply` tinyint(1) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `uc_room_user` (`id_room`,`id_user`), KEY `idx_room` (`id_room`), KEY `idx_user` (`id_user`), KEY `idx_anonymous_id` (`anonymous_id`), KEY `idx_participants_active` (`id_room`,`id_user`,`notification_activee`), CONSTRAINT `fk_chat_participants_room` FOREIGN KEY (`id_room`) REFERENCES `chat_rooms` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `chat_read_messages` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `fk_message` varchar(50) NOT NULL, `fk_user` int(10) unsigned NOT NULL, `date_read` timestamp NOT NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), UNIQUE KEY `uc_message_user` (`fk_message`,`fk_user`), KEY `idx_message` (`fk_message`), KEY `idx_user` (`fk_user`), CONSTRAINT `fk_chat_read_messages_message` FOREIGN KEY (`fk_message`) REFERENCES `chat_messages` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `chat_rooms` ( `id` varchar(50) NOT NULL, `type` enum('privee','groupe','liste_diffusion','broadcast','announcement') NOT NULL, `title` varchar(100) DEFAULT NULL, `date_creation` timestamp NOT NULL DEFAULT current_timestamp(), `fk_user` int(10) unsigned NOT NULL, `fk_entite` int(10) unsigned DEFAULT NULL, `statut` enum('active','archive') NOT NULL DEFAULT 'active', `description` text DEFAULT NULL, `reply_permission` enum('all','admins_only','sender_only','none') NOT NULL DEFAULT 'all', `is_pinned` tinyint(1) unsigned NOT NULL DEFAULT 0, `expiry_date` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(), PRIMARY KEY (`id`), KEY `idx_user` (`fk_user`), KEY `idx_entite` (`fk_entite`), KEY `idx_type` (`type`), KEY `idx_statut` (`statut`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `email_counter` ( `id` int(10) unsigned NOT NULL DEFAULT 1, `hour_start` timestamp NULL DEFAULT NULL, `count` int(10) unsigned DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `email_queue` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fk_pass` int(10) unsigned NOT NULL DEFAULT 0, `to_email` varchar(255) DEFAULT NULL, `subject` varchar(255) DEFAULT NULL, `body` text DEFAULT NULL, `headers` text DEFAULT NULL, `created_at` timestamp NULL DEFAULT current_timestamp(), `status` enum('pending','sent','failed') DEFAULT 'pending', `attempts` int(10) unsigned DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `entites` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `encrypted_name` varchar(255) DEFAULT NULL, `adresse1` varchar(45) DEFAULT '', `adresse2` varchar(45) DEFAULT '', `code_postal` varchar(5) DEFAULT '', `ville` varchar(45) DEFAULT '', `fk_region` int(10) unsigned DEFAULT NULL, `fk_type` int(10) unsigned DEFAULT 1, `encrypted_phone` varchar(128) DEFAULT '', `encrypted_mobile` varchar(128) DEFAULT '', `encrypted_email` varchar(255) DEFAULT '', `gps_lat` varchar(20) NOT NULL DEFAULT '', `gps_lng` varchar(20) NOT NULL DEFAULT '', `chk_stripe` tinyint(1) unsigned DEFAULT 0, `encrypted_stripe_id` varchar(255) DEFAULT '', `encrypted_iban` varchar(255) DEFAULT '', `encrypted_bic` varchar(128) DEFAULT '', `chk_demo` tinyint(1) unsigned DEFAULT 1, `chk_mdp_manuel` tinyint(1) unsigned NOT NULL DEFAULT 1 COMMENT 'Gestion des mots de passe manuelle O/N', `chk_copie_mail_recu` tinyint(1) unsigned NOT NULL DEFAULT 0, `chk_accept_sms` tinyint(1) unsigned NOT NULL DEFAULT 0, `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date de création', `fk_user_creat` int(10) unsigned DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT 'Date de modification', `fk_user_modif` int(10) unsigned DEFAULT NULL, `chk_active` tinyint(1) unsigned DEFAULT 1, PRIMARY KEY (`id`), KEY `entites_ibfk_1` (`fk_region`), KEY `entites_ibfk_2` (`fk_type`), CONSTRAINT `entites_ibfk_1` FOREIGN KEY (`fk_region`) REFERENCES `x_regions` (`id`) ON UPDATE CASCADE, CONSTRAINT `entites_ibfk_2` FOREIGN KEY (`fk_type`) REFERENCES `x_entites_types` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=1230 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `medias` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `support` varchar(45) NOT NULL DEFAULT '' COMMENT 'Type de support (entite, user, operation, passage)', `support_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'ID de élément associé', `fichier` varchar(250) NOT NULL DEFAULT '' COMMENT 'Nom du fichier stocké', `file_type` varchar(50) DEFAULT NULL COMMENT 'Extension du fichier (pdf, jpg, xlsx, etc.)', `file_category` varchar(50) DEFAULT NULL COMMENT 'export, logo, carte, etc.', `file_size` int(10) unsigned DEFAULT NULL COMMENT 'Taille du fichier en octets', `mime_type` varchar(100) DEFAULT NULL COMMENT 'Type MIME du fichier', `original_name` varchar(255) DEFAULT NULL COMMENT 'Nom original du fichier uploadé', `fk_entite` int(10) unsigned DEFAULT NULL COMMENT 'ID de entité propriétaire', `fk_operation` int(10) unsigned DEFAULT NULL COMMENT 'ID de opération (pour passages)', `file_path` varchar(500) DEFAULT NULL COMMENT 'Chemin complet du fichier', `original_width` int(10) unsigned DEFAULT NULL COMMENT 'Largeur originale de image', `original_height` int(10) unsigned DEFAULT NULL COMMENT 'Hauteur originale de image', `processed_width` int(10) unsigned DEFAULT NULL COMMENT 'Largeur après traitement', `processed_height` int(10) unsigned DEFAULT NULL COMMENT 'Hauteur après traitement', `is_processed` tinyint(1) unsigned DEFAULT 0 COMMENT 'Image redimensionnée (1) ou originale (0)', `description` varchar(100) NOT NULL DEFAULT '' COMMENT 'Description du fichier', `created_at` timestamp NOT NULL DEFAULT current_timestamp(), `fk_user_creat` int(10) unsigned NOT NULL DEFAULT 0, `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(), `fk_user_modif` int(10) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`), KEY `idx_entite` (`fk_entite`), KEY `idx_operation` (`fk_operation`), KEY `idx_support_type` (`support`, `support_id`), KEY `idx_file_type` (`file_type`), KEY `idx_file_category` (`file_category`), CONSTRAINT `fk_medias_entite` FOREIGN KEY (`fk_entite`) REFERENCES `entites` (`id`) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT `fk_medias_operation` FOREIGN KEY (`fk_operation`) REFERENCES `operations` (`id`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; CREATE TABLE `ope_pass` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fk_operation` int(10) unsigned NOT NULL DEFAULT 0, `fk_sector` int(10) unsigned DEFAULT 0, `fk_user` int(10) unsigned NOT NULL DEFAULT 0, `fk_adresse` varchar(25) DEFAULT '' COMMENT 'adresses.cp??.id', `passed_at` timestamp NULL DEFAULT NULL COMMENT 'Date du passage', `fk_type` int(10) unsigned DEFAULT 0, `numero` varchar(10) NOT NULL DEFAULT '', `rue` varchar(75) NOT NULL DEFAULT '', `rue_bis` varchar(1) NOT NULL DEFAULT '', `ville` varchar(75) NOT NULL DEFAULT '', `fk_habitat` int(10) unsigned DEFAULT 1, `appt` varchar(5) DEFAULT '', `niveau` varchar(5) DEFAULT '', `residence` varchar(75) DEFAULT '', `gps_lat` varchar(20) NOT NULL DEFAULT '', `gps_lng` varchar(20) NOT NULL DEFAULT '', `encrypted_name` varchar(255) NOT NULL DEFAULT '', `montant` decimal(7,2) NOT NULL DEFAULT 0.00, `fk_type_reglement` int(10) unsigned DEFAULT 1, `remarque` text DEFAULT '', `encrypted_email` varchar(255) DEFAULT '', `nom_recu` varchar(50) DEFAULT NULL, `date_recu` timestamp NULL DEFAULT NULL COMMENT 'Date de réception', `date_creat_recu` timestamp NULL DEFAULT NULL COMMENT 'Date de création du reçu', `date_sent_recu` timestamp NULL DEFAULT NULL COMMENT 'Date envoi du reçu', `email_erreur` varchar(30) DEFAULT '', `chk_email_sent` tinyint(1) unsigned NOT NULL DEFAULT 0, `encrypted_phone` varchar(128) NOT NULL DEFAULT '', `is_striped` tinyint(1) unsigned NOT NULL DEFAULT 0, `docremis` tinyint(1) unsigned DEFAULT 0, `date_repasser` timestamp NULL DEFAULT NULL COMMENT 'Date prévue pour repasser', `nb_passages` int(11) DEFAULT 1 COMMENT 'Nb passages pour les a repasser', `chk_gps_maj` tinyint(1) unsigned DEFAULT 0, `chk_map_create` tinyint(1) unsigned DEFAULT 0, `chk_mobile` tinyint(1) unsigned DEFAULT 0, `chk_synchro` tinyint(1) unsigned DEFAULT 1 COMMENT 'chk synchro entre web et appli', `chk_api_adresse` tinyint(1) unsigned DEFAULT 0, `chk_maj_adresse` tinyint(1) unsigned DEFAULT 0, `anomalie` tinyint(1) unsigned DEFAULT 0, `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date de création', `fk_user_creat` int(10) unsigned DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT 'Date de modification', `fk_user_modif` int(10) unsigned DEFAULT NULL, `chk_active` tinyint(1) unsigned NOT NULL DEFAULT 1, PRIMARY KEY (`id`), KEY `fk_operation` (`fk_operation`), KEY `fk_sector` (`fk_sector`), KEY `fk_user` (`fk_user`), KEY `fk_type` (`fk_type`), KEY `fk_type_reglement` (`fk_type_reglement`), KEY `email` (`encrypted_email`), CONSTRAINT `ope_pass_ibfk_1` FOREIGN KEY (`fk_operation`) REFERENCES `operations` (`id`) ON UPDATE CASCADE, CONSTRAINT `ope_pass_ibfk_2` FOREIGN KEY (`fk_sector`) REFERENCES `ope_sectors` (`id`) ON UPDATE CASCADE, CONSTRAINT `ope_pass_ibfk_3` FOREIGN KEY (`fk_user`) REFERENCES `users` (`id`) ON UPDATE CASCADE, CONSTRAINT `ope_pass_ibfk_4` FOREIGN KEY (`fk_type_reglement`) REFERENCES `x_types_reglements` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=19499566 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `ope_pass_histo` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fk_pass` int(10) unsigned NOT NULL DEFAULT 0, `date_histo` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date historique', `sujet` varchar(50) DEFAULT NULL, `remarque` varchar(250) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `ope_pass_histo_fk_pass_IDX` (`fk_pass`) USING BTREE, KEY `ope_pass_histo_date_histo_IDX` (`date_histo`) USING BTREE, CONSTRAINT `ope_pass_histo_ibfk_1` FOREIGN KEY (`fk_pass`) REFERENCES `ope_pass` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=6752 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `ope_sectors` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fk_operation` int(10) unsigned NOT NULL DEFAULT 0, `fk_old_sector` int(10) unsigned DEFAULT NULL, `libelle` varchar(75) NOT NULL DEFAULT '', `sector` text NOT NULL DEFAULT '', `color` varchar(7) NOT NULL DEFAULT '#4B77BE', `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date de création', `fk_user_creat` int(10) unsigned NOT NULL DEFAULT 0, `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT 'Date de modification', `fk_user_modif` int(10) unsigned NOT NULL DEFAULT 0, `chk_active` tinyint(1) unsigned NOT NULL DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`), KEY `fk_operation` (`fk_operation`), CONSTRAINT `ope_sectors_ibfk_1` FOREIGN KEY (`fk_operation`) REFERENCES `operations` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=27675 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `ope_users` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fk_operation` int(10) unsigned NOT NULL DEFAULT 0, `fk_user` int(10) unsigned NOT NULL DEFAULT 0, `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date de création', `fk_user_creat` int(10) unsigned DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT 'Date de modification', `fk_user_modif` int(10) unsigned DEFAULT NULL, `chk_active` tinyint(1) unsigned NOT NULL DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`), KEY `ope_users_ibfk_1` (`fk_operation`), KEY `ope_users_ibfk_2` (`fk_user`), CONSTRAINT `ope_users_ibfk_1` FOREIGN KEY (`fk_operation`) REFERENCES `operations` (`id`) ON UPDATE CASCADE, CONSTRAINT `ope_users_ibfk_2` FOREIGN KEY (`fk_user`) REFERENCES `users` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=199006 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `ope_users_sectors` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fk_operation` int(10) unsigned NOT NULL DEFAULT 0, `fk_user` int(10) unsigned NOT NULL DEFAULT 0, `fk_sector` int(10) unsigned NOT NULL DEFAULT 0, `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date de création', `fk_user_creat` int(10) unsigned NOT NULL DEFAULT 0, `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT 'Date de modification', `fk_user_modif` int(10) unsigned DEFAULT NULL, `chk_active` tinyint(1) unsigned DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`), KEY `fk_operation` (`fk_operation`), KEY `fk_user` (`fk_user`), KEY `fk_sector` (`fk_sector`), CONSTRAINT `ope_users_sectors_ibfk_1` FOREIGN KEY (`fk_operation`) REFERENCES `operations` (`id`) ON UPDATE CASCADE, CONSTRAINT `ope_users_sectors_ibfk_2` FOREIGN KEY (`fk_user`) REFERENCES `users` (`id`) ON UPDATE CASCADE, CONSTRAINT `ope_users_sectors_ibfk_3` FOREIGN KEY (`fk_sector`) REFERENCES `ope_sectors` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=48082 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `operations` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fk_entite` int(10) unsigned NOT NULL DEFAULT 1, `libelle` varchar(75) NOT NULL DEFAULT '', `date_deb` date NOT NULL DEFAULT '0000-00-00', `date_fin` date NOT NULL DEFAULT '0000-00-00', `chk_distinct_sectors` tinyint(1) unsigned NOT NULL DEFAULT 0, `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date de création', `fk_user_creat` int(10) unsigned NOT NULL DEFAULT 0, `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT 'Date de modification', `fk_user_modif` int(10) unsigned NOT NULL DEFAULT 0, `chk_active` tinyint(1) unsigned NOT NULL DEFAULT 1, PRIMARY KEY (`id`), KEY `fk_entite` (`fk_entite`), KEY `date_deb` (`date_deb`), CONSTRAINT `operations_ibfk_1` FOREIGN KEY (`fk_entite`) REFERENCES `entites` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=3121 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `params` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `libelle` varchar(35) NOT NULL DEFAULT '', `valeur` varchar(255) NOT NULL DEFAULT '', `aide` varchar(150) NOT NULL DEFAULT '', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `sectors_adresses` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fk_adresse` varchar(25) DEFAULT NULL COMMENT 'adresses.cp??.id', `osm_id` int(10) unsigned NOT NULL DEFAULT 0, `fk_sector` int(10) unsigned NOT NULL DEFAULT 0, `osm_name` varchar(50) NOT NULL DEFAULT '', `numero` varchar(5) NOT NULL DEFAULT '', `rue_bis` varchar(5) NOT NULL DEFAULT '', `rue` varchar(60) NOT NULL DEFAULT '', `cp` varchar(5) NOT NULL DEFAULT '', `ville` varchar(60) NOT NULL DEFAULT '', `gps_lat` varchar(20) NOT NULL DEFAULT '', `gps_lng` varchar(20) NOT NULL DEFAULT '', `osm_date_creat` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date de création', `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT 'Date de modification', PRIMARY KEY (`id`), KEY `sectors_adresses_fk_sector_index` (`fk_sector`), KEY `sectors_adresses_numero_index` (`numero`), KEY `sectors_adresses_rue_index` (`rue`), KEY `sectors_adresses_ville_index` (`ville`), CONSTRAINT `sectors_adresses_ibfk_1` FOREIGN KEY (`fk_sector`) REFERENCES `ope_sectors` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=1562946 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `users` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fk_entite` int(10) unsigned DEFAULT 1, `fk_role` int(10) unsigned DEFAULT 1, `fk_titre` int(10) unsigned DEFAULT 1, `encrypted_name` varchar(255) DEFAULT NULL, `first_name` varchar(45) DEFAULT NULL, `sect_name` varchar(60) DEFAULT '', `encrypted_user_name` varchar(128) DEFAULT '', `user_pass_hash` varchar(60) DEFAULT NULL, `encrypted_phone` varchar(128) DEFAULT NULL, `encrypted_mobile` varchar(128) DEFAULT NULL, `encrypted_email` varchar(255) DEFAULT '', `chk_alert_email` tinyint(1) unsigned DEFAULT 1, `chk_suivi` tinyint(1) unsigned DEFAULT 0, `date_naissance` date DEFAULT NULL, `date_embauche` date DEFAULT NULL, `created_at` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'Date de création', `fk_user_creat` int(10) unsigned DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp() COMMENT 'Date de modification', `fk_user_modif` int(10) unsigned DEFAULT NULL, `chk_active` tinyint(1) unsigned DEFAULT 1, PRIMARY KEY (`id`), KEY `fk_entite` (`fk_entite`), KEY `username` (`encrypted_user_name`), KEY `users_ibfk_2` (`fk_role`), KEY `users_ibfk_3` (`fk_titre`), CONSTRAINT `users_ibfk_1` FOREIGN KEY (`fk_entite`) REFERENCES `entites` (`id`) ON UPDATE CASCADE, CONSTRAINT `users_ibfk_2` FOREIGN KEY (`fk_role`) REFERENCES `x_users_roles` (`id`) ON UPDATE CASCADE, CONSTRAINT `users_ibfk_3` FOREIGN KEY (`fk_titre`) REFERENCES `x_users_titres` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=10027748 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `x_departements` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(3) DEFAULT NULL, `fk_region` int(10) unsigned DEFAULT 1, `libelle` varchar(45) DEFAULT NULL, `chk_active` tinyint(1) unsigned DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`), KEY `x_departements_ibfk_1` (`fk_region`), CONSTRAINT `x_departements_ibfk_1` FOREIGN KEY (`fk_region`) REFERENCES `x_regions` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=105 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `x_devises` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(3) DEFAULT NULL, `symbole` varchar(6) DEFAULT NULL, `libelle` varchar(45) DEFAULT NULL, `chk_active` tinyint(1) unsigned DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `x_entites_types` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `libelle` varchar(45) DEFAULT NULL, `chk_active` tinyint(1) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `x_pays` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(3) DEFAULT NULL, `fk_continent` int(10) unsigned DEFAULT NULL, `fk_devise` int(10) unsigned DEFAULT 1, `libelle` varchar(45) DEFAULT NULL, `chk_active` tinyint(1) unsigned DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`), KEY `x_pays_ibfk_1` (`fk_devise`), CONSTRAINT `x_pays_ibfk_1` FOREIGN KEY (`fk_devise`) REFERENCES `x_devises` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Table des pays avec leurs codes' `PAGE_COMPRESSED`='ON'; CREATE TABLE `x_regions` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fk_pays` int(10) unsigned DEFAULT 1, `libelle` varchar(45) DEFAULT NULL, `libelle_long` varchar(45) DEFAULT NULL, `table_osm` varchar(45) DEFAULT NULL, `departements` varchar(45) DEFAULT NULL, `chk_active` tinyint(1) unsigned DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`), KEY `x_regions_ibfk_1` (`fk_pays`), CONSTRAINT `x_regions_ibfk_1` FOREIGN KEY (`fk_pays`) REFERENCES `x_pays` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `x_types_passages` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `libelle` varchar(10) DEFAULT NULL, `color_button` varchar(15) DEFAULT NULL, `color_mark` varchar(15) DEFAULT NULL, `color_table` varchar(15) DEFAULT NULL, `chk_active` tinyint(1) unsigned NOT NULL DEFAULT 1, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `x_types_reglements` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `libelle` varchar(45) DEFAULT NULL, `chk_active` tinyint(1) unsigned DEFAULT 1, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `x_users_roles` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `libelle` varchar(45) DEFAULT NULL, `chk_active` tinyint(1) unsigned DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Les différents rôles des utilisateurs' `PAGE_COMPRESSED`='ON'; CREATE TABLE `x_users_titres` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `libelle` varchar(45) DEFAULT NULL, `chk_active` tinyint(1) unsigned DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Les différents titres des utilisateurs' `PAGE_COMPRESSED`='ON'; CREATE TABLE `x_villes` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `fk_departement` int(10) unsigned DEFAULT 1, `libelle` varchar(65) DEFAULT NULL, `code_postal` varchar(5) DEFAULT NULL, `code_insee` varchar(5) DEFAULT NULL, `chk_active` tinyint(1) unsigned DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `id_UNIQUE` (`id`), KEY `x_villes_ibfk_1` (`fk_departement`), CONSTRAINT `x_villes_ibfk_1` FOREIGN KEY (`fk_departement`) REFERENCES `x_departements` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=38950 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE TABLE `z_sessions` ( `sid` text NOT NULL, `fk_user` int(11) NOT NULL, `role` varchar(10) DEFAULT NULL, `date_modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `ip` varchar(50) NOT NULL, `browser` varchar(150) NOT NULL, `data` mediumtext DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `PAGE_COMPRESSED`='ON'; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `chat_conversations_unread` AS select `r`.`id` AS `id`,`r`.`type` AS `type`,`r`.`title` AS `title`,`r`.`date_creation` AS `date_creation`,`r`.`fk_user` AS `fk_user`,`r`.`fk_entite` AS `fk_entite`,`r`.`statut` AS `statut`,`r`.`description` AS `description`,`r`.`reply_permission` AS `reply_permission`,`r`.`is_pinned` AS `is_pinned`,`r`.`expiry_date` AS `expiry_date`,`r`.`updated_at` AS `updated_at`,count(distinct `m`.`id`) AS `total_messages`,count(distinct `rm`.`id`) AS `read_messages`,count(distinct `m`.`id`) - count(distinct `rm`.`id`) AS `unread_messages`,(select `geo_app`.`chat_messages`.`date_sent` from `chat_messages` where `geo_app`.`chat_messages`.`fk_room` = `r`.`id` order by `geo_app`.`chat_messages`.`date_sent` desc limit 1) AS `last_message_date` from ((`chat_rooms` `r` left join `chat_messages` `m` on(`r`.`id` = `m`.`fk_room`)) left join `chat_read_messages` `rm` on(`m`.`id` = `rm`.`fk_message`)) group by `r`.`id`; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!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 */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;