Files
2026-12-01 19:40:55 +01:00

379 lines
27 KiB
SQL

CREATE TABLE `assets` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`domain_id` uuid,`domain_name` text,`company_id` uuid,`name` text,`description` text,`path` text NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `uni_assets_id` UNIQUE (`id`))
;
CREATE TABLE `options` (`id` uuid NOT NULL,`key` text NOT NULL,`value` text NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `uni_options_id` UNIQUE (`id`),CONSTRAINT `uni_options_key` UNIQUE (`key`))
;
CREATE TABLE `companies` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`name` text NOT NULL,`comment` text,PRIMARY KEY (`id`),CONSTRAINT `uni_companies_id` UNIQUE (`id`),CONSTRAINT `uni_companies_name` UNIQUE (`name`))
;
CREATE TABLE `api_senders` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`name` text NOT NULL,`company_id` uuid,`api_key` text,`custom_field1` text,`custom_field2` text,`custom_field3` text,`custom_field4` text,`request_method` text,`request_url` text,`request_headers` text,`request_body` text,`expected_response_status_code` integer,`expected_response_headers` text,`expected_response_body` text,PRIMARY KEY (`id`),CONSTRAINT `uni_api_senders_id` UNIQUE (`id`))
;
CREATE TABLE `api_sender_headers` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`key` text NOT NULL,`value` text NOT NULL,`is_request_header` numeric NOT NULL,`api_sender_id` uuid NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `uni_api_sender_headers_id` UNIQUE (`id`))
;
CREATE TABLE `roles` (`id` uuid NOT NULL,`name` text NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `uni_roles_id` UNIQUE (`id`),CONSTRAINT `uni_roles_name` UNIQUE (`name`))
;
CREATE TABLE `users` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`deleted_at` datetime,`name` text NOT NULL,`username` text NOT NULL,`email` text,`password_hash` varchar(255),`require_password_renew` numeric DEFAULT false,`totp_enabled` numeric DEFAULT false,`totp_secret` text,`totp_auth_url` text,`totp_recovery_code` varchar(64),`sso_id` text,`company_id` uuid,`role_id` uuid NOT NULL,`api_key` text,PRIMARY KEY (`id`),CONSTRAINT `fk_roles_users` FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`),CONSTRAINT `fk_companies_users` FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`),CONSTRAINT `uni_users_id` UNIQUE (`id`),CONSTRAINT `uni_users_username` UNIQUE (`username`),CONSTRAINT `uni_users_email` UNIQUE (`email`))
;
CREATE TABLE `sessions` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`ip_address` text NOT NULL DEFAULT "",`expires_at` datetime NOT NULL,`max_age_at` datetime NOT NULL,`user_id` uuid,PRIMARY KEY (`id`),CONSTRAINT `fk_sessions_user` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`),CONSTRAINT `uni_sessions_id` UNIQUE (`id`))
;
CREATE TABLE `recipients` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`deleted_at` datetime,`email` text,`phone` text,`extra_identifier` text,`first_name` text,`last_name` text,`position` text,`department` text,`city` text,`country` text,`misc` text,`company_id` uuid,PRIMARY KEY (`id`),CONSTRAINT `fk_recipients_company` FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`),CONSTRAINT `uni_recipients_id` UNIQUE (`id`))
;
CREATE TABLE `recipient_groups` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`name` text NOT NULL,`company_id` uuid,PRIMARY KEY (`id`),CONSTRAINT `fk_companies_recipient_groups` FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`),CONSTRAINT `uni_recipient_groups_id` UNIQUE (`id`))
;
CREATE TABLE `recipient_group_recipients` (`recipient_id` uuid NOT NULL,`recipient_group_id` uuid NOT NULL,CONSTRAINT `fk_recipient_group_recipients_recipient` FOREIGN KEY (`recipient_id`) REFERENCES `recipients`(`id`),CONSTRAINT `fk_recipient_group_recipients_recipient_group` FOREIGN KEY (`recipient_group_id`) REFERENCES `recipient_groups`(`id`))
;
CREATE TABLE `domains` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`company_id` uuid,`proxy_id` uuid,`name` text NOT NULL,`type` text NOT NULL DEFAULT "regular",`proxy_target_domain` text,`managed_tls_certs` numeric NOT NULL DEFAULT false,`own_managed_tls` numeric NOT NULL DEFAULT false,`host_website` numeric NOT NULL,`page_content` text,`page_not_found_content` text,`redirect_url` text,PRIMARY KEY (`id`),CONSTRAINT `fk_domains_company` FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`),CONSTRAINT `uni_domains_name` UNIQUE (`name`),CONSTRAINT `uni_domains_id` UNIQUE (`id`))
;
CREATE TABLE `pages` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`company_id` uuid,`name` text NOT NULL,`content` text NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `fk_pages_company` FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`),CONSTRAINT `uni_pages_id` UNIQUE (`id`))
;
CREATE TABLE `proxies` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`company_id` uuid,`name` text NOT NULL,`description` text,`start_url` text NOT NULL,`proxy_config` text NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `fk_proxies_company` FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`),CONSTRAINT `uni_proxies_id` UNIQUE (`id`))
;
CREATE TABLE `smtp_configurations` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`name` text NOT NULL,`host` text NOT NULL,`port` integer NOT NULL,`username` text NOT NULL,`password` text NOT NULL,`ignore_cert_errors` numeric NOT NULL,`company_id` uuid,PRIMARY KEY (`id`),CONSTRAINT `fk_smtp_configurations_company` FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`),CONSTRAINT `uni_smtp_configurations_id` UNIQUE (`id`))
;
CREATE TABLE `smtp_headers` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`key` text NOT NULL,`value` text NOT NULL,`smtp_configuration_id` uuid NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `fk_smtp_configurations_headers` FOREIGN KEY (`smtp_configuration_id`) REFERENCES `smtp_configurations`(`id`),CONSTRAINT `uni_smtp_headers_id` UNIQUE (`id`))
;
CREATE TABLE `emails` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`name` text NOT NULL,`content` text NOT NULL,`add_tracking_pixel` numeric NOT NULL,`mail_from` text NOT NULL,`subject` text NOT NULL,`from` text NOT NULL,`company_id` uuid,PRIMARY KEY (`id`),CONSTRAINT `fk_emails_company` FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`),CONSTRAINT `uni_emails_id` UNIQUE (`id`))
;
CREATE TABLE `email_attachments` (`email_id` uuid NOT NULL,`attachment_id` uuid NOT NULL,PRIMARY KEY (`email_id`,`attachment_id`))
;
CREATE TABLE `identifiers` (`id` uuid NOT NULL,`name` text NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `uni_identifiers_id` UNIQUE (`id`))
;
CREATE TABLE `campaign_templates` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`name` text NOT NULL,`url_path` text NOT NULL DEFAULT "",`is_usable` numeric NOT NULL DEFAULT false,`landing_page_id` uuid,`landing_proxy_id` uuid,`domain_id` uuid,`url_identifier_id` uuid NOT NULL,`state_identifier_id` uuid,`before_landing_page_id` uuid,`before_landing_proxy_id` uuid,`after_landing_page_id` uuid,`after_landing_proxy_id` uuid,`after_landing_page_redirect_url` text NOT NULL DEFAULT "",`email_id` uuid,`smtp_configuration_id` uuid,`api_sender_id` uuid,`company_id` uuid,PRIMARY KEY (`id`),CONSTRAINT `fk_campaign_templates_after_landing_proxy` FOREIGN KEY (`after_landing_proxy_id`) REFERENCES `proxies`(`id`),CONSTRAINT `fk_campaign_templates_email` FOREIGN KEY (`email_id`) REFERENCES `emails`(`id`),CONSTRAINT `fk_campaign_templates_smtp_configuration` FOREIGN KEY (`smtp_configuration_id`) REFERENCES `smtp_configurations`(`id`),CONSTRAINT `fk_campaign_templates_api_sender` FOREIGN KEY (`api_sender_id`) REFERENCES `api_senders`(`id`),CONSTRAINT `fk_campaign_templates_company` FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`),CONSTRAINT `fk_campaign_templates_landing_page` FOREIGN KEY (`landing_page_id`) REFERENCES `pages`(`id`),CONSTRAINT `fk_campaign_templates_landing_proxy` FOREIGN KEY (`landing_proxy_id`) REFERENCES `proxies`(`id`),CONSTRAINT `fk_campaign_templates_domain` FOREIGN KEY (`domain_id`) REFERENCES `domains`(`id`),CONSTRAINT `fk_campaign_templates_url_identifier` FOREIGN KEY (`url_identifier_id`) REFERENCES `identifiers`(`id`),CONSTRAINT `fk_campaign_templates_state_identifier` FOREIGN KEY (`state_identifier_id`) REFERENCES `identifiers`(`id`),CONSTRAINT `fk_campaign_templates_before_landing_proxy` FOREIGN KEY (`before_landing_proxy_id`) REFERENCES `proxies`(`id`),CONSTRAINT `fk_campaign_templates_after_landing_page` FOREIGN KEY (`after_landing_page_id`) REFERENCES `pages`(`id`),CONSTRAINT `fk_campaign_templates_before_landing_page` FOREIGN KEY (`before_landing_page_id`) REFERENCES `pages`(`id`),CONSTRAINT `uni_campaign_templates_id` UNIQUE (`id`))
;
CREATE TABLE `events` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`name` text NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `uni_events_id` UNIQUE (`id`))
;
CREATE TABLE `campaigns` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`close_at` datetime,`closed_at` datetime,`anonymize_at` datetime,`anonymized_at` datetime,`sort_field` text,`sort_order` text,`send_start_at` datetime,`send_end_at` datetime,`constraint_week_days` integer,`constraint_start_time` text,`constraint_end_time` text,`save_submitted_data` numeric NOT NULL DEFAULT false,`is_anonymous` numeric NOT NULL DEFAULT false,`is_test` numeric NOT NULL DEFAULT false,`campaign_template_id` uuid,`company_id` uuid,`deny_page_id` uuid,`evasion_page_id` uuid,`notable_event_id` uuid,`webhook_id` uuid,`name` text NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `fk_campaigns_campaign_template` FOREIGN KEY (`campaign_template_id`) REFERENCES `campaign_templates`(`id`),CONSTRAINT `fk_campaigns_company` FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`),CONSTRAINT `fk_campaigns_deny_page` FOREIGN KEY (`deny_page_id`) REFERENCES `pages`(`id`),CONSTRAINT `fk_campaigns_evasion_page` FOREIGN KEY (`evasion_page_id`) REFERENCES `pages`(`id`),CONSTRAINT `fk_campaigns_notable_event` FOREIGN KEY (`notable_event_id`) REFERENCES `events`(`id`),CONSTRAINT `uni_campaigns_id` UNIQUE (`id`))
;
CREATE TABLE `allow_denies` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`company_id` uuid,`name` text NOT NULL,`cidrs` text NOT NULL,`allowed` numeric NOT NULL,PRIMARY KEY (`id`),CONSTRAINT `uni_allow_denies_id` UNIQUE (`id`))
;
CREATE TABLE `campaign_allow_denies` (`campaign_id` uuid NOT NULL,`allow_deny_id` uuid NOT NULL,CONSTRAINT `fk_campaign_allow_denies_campaign` FOREIGN KEY (`campaign_id`) REFERENCES `campaigns`(`id`),CONSTRAINT `fk_campaign_allow_denies_allow_deny` FOREIGN KEY (`allow_deny_id`) REFERENCES `allow_denies`(`id`))
;
CREATE TABLE `campaign_recipient_groups` (`campaign_id` uuid NOT NULL,`recipient_group_id` uuid NOT NULL,CONSTRAINT `fk_campaign_recipient_groups_campaign` FOREIGN KEY (`campaign_id`) REFERENCES `campaigns`(`id`),CONSTRAINT `fk_campaign_recipient_groups_recipient_group` FOREIGN KEY (`recipient_group_id`) REFERENCES `recipient_groups`(`id`))
;
CREATE TABLE `campaign_recipients` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`campaign_id` uuid NOT NULL,`cancelled_at` datetime,`send_at` datetime,`last_attempt_at` datetime,`sent_at` datetime,`self_managed` numeric NOT NULL DEFAULT false,`anonymized_id` uuid,`recipient_id` uuid,`notable_event_id` uuid,PRIMARY KEY (`id`),CONSTRAINT `fk_campaign_recipients_campaign` FOREIGN KEY (`campaign_id`) REFERENCES `campaigns`(`id`),CONSTRAINT `fk_campaign_recipients_recipient` FOREIGN KEY (`recipient_id`) REFERENCES `recipients`(`id`),CONSTRAINT `fk_campaign_recipients_notable_event` FOREIGN KEY (`notable_event_id`) REFERENCES `events`(`id`),CONSTRAINT `uni_campaign_recipients_id` UNIQUE (`id`))
;
CREATE TABLE `campaign_events` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`data` text NOT NULL,`campaign_id` uuid NOT NULL,`event_id` uuid NOT NULL,`user_agent` text,`ip_address` text,`anonymized_id` uuid,`recipient_id` uuid,`company_id` uuid,PRIMARY KEY (`id`),CONSTRAINT `fk_campaign_events_recipient` FOREIGN KEY (`recipient_id`) REFERENCES `recipients`(`id`),CONSTRAINT `uni_campaign_events_id` UNIQUE (`id`))
;
CREATE TABLE `attachments` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`company_id` uuid,`name` text,`description` text,`filename` text NOT NULL,`embedded_content` numeric NOT NULL DEFAULT false,PRIMARY KEY (`id`),CONSTRAINT `uni_attachments_id` UNIQUE (`id`))
;
CREATE TABLE `message_attachments` (`attachment_id` uuid NOT NULL,`email_id` uuid NOT NULL,PRIMARY KEY (`attachment_id`,`email_id`),CONSTRAINT `fk_message_attachments_attachment` FOREIGN KEY (`attachment_id`) REFERENCES `attachments`(`id`),CONSTRAINT `fk_message_attachments_email` FOREIGN KEY (`email_id`) REFERENCES `emails`(`id`))
;
CREATE TABLE `webhooks` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`company_id` uuid,`name` text NOT NULL,`url` text NOT NULL,`secret` text,PRIMARY KEY (`id`),CONSTRAINT `uni_webhooks_id` UNIQUE (`id`))
;
CREATE TABLE `campaign_stats` (`id` uuid NOT NULL,`created_at` datetime NOT NULL,`updated_at` datetime NOT NULL,`campaign_id` uuid,`campaign_name` text NOT NULL,`company_id` uuid,`campaign_start_date` datetime,`campaign_end_date` datetime,`campaign_closed_at` datetime,`total_recipients` integer NOT NULL DEFAULT 0,`total_events` integer NOT NULL DEFAULT 0,`emails_sent` integer NOT NULL DEFAULT 0,`tracking_pixel_loaded` integer NOT NULL DEFAULT 0,`website_visits` integer NOT NULL DEFAULT 0,`data_submissions` integer NOT NULL DEFAULT 0,`reported` integer NOT NULL DEFAULT 0,`open_rate` real NOT NULL DEFAULT 0,`click_rate` real NOT NULL DEFAULT 0,`submission_rate` real NOT NULL DEFAULT 0,`report_rate` real NOT NULL DEFAULT 0,`template_name` text,`campaign_type` text,PRIMARY KEY (`id`),CONSTRAINT `uni_campaign_stats_id` UNIQUE (`id`))
;
CREATE INDEX `idx_assets_path` ON `assets`(`path`)
;
CREATE INDEX `idx_assets_name` ON `assets`(`name`)
;
CREATE INDEX `idx_assets_company_id` ON `assets`(`company_id`)
;
CREATE INDEX `idx_assets_domain_id` ON `assets`(`domain_id`)
;
CREATE INDEX `idx_assets_updated_at` ON `assets`(`updated_at`)
;
CREATE INDEX `idx_assets_created_at` ON `assets`(`created_at`)
;
CREATE INDEX `idx_options_key` ON `options`(`key`)
;
CREATE INDEX `idx_companies_name` ON `companies`(`name`)
;
CREATE INDEX `idx_companies_updated_at` ON `companies`(`updated_at`)
;
CREATE INDEX `idx_companies_created_at` ON `companies`(`created_at`)
;
CREATE UNIQUE INDEX `idx_api_senders_name_company_id` ON `api_senders`(`name`,`company_id`)
;
CREATE INDEX `idx_api_senders_updated_at` ON `api_senders`(`updated_at`)
;
CREATE INDEX `idx_api_senders_created_at` ON `api_senders`(`created_at`)
;
CREATE INDEX `idx_api_sender_headers_api_sender_id` ON `api_sender_headers`(`api_sender_id`)
;
CREATE INDEX `idx_api_sender_headers_updated_at` ON `api_sender_headers`(`updated_at`)
;
CREATE INDEX `idx_api_sender_headers_created_at` ON `api_sender_headers`(`created_at`)
;
CREATE INDEX `idx_roles_name` ON `roles`(`name`)
;
CREATE INDEX `idx_users_api_key` ON `users`(`api_key`)
;
CREATE INDEX `idx_users_role_id` ON `users`(`role_id`)
;
CREATE INDEX `idx_users_company_id` ON `users`(`company_id`)
;
CREATE INDEX `idx_users_deleted_at` ON `users`(`deleted_at`)
;
CREATE INDEX `idx_users_updated_at` ON `users`(`updated_at`)
;
CREATE INDEX `idx_users_created_at` ON `users`(`created_at`)
;
CREATE INDEX `idx_sessions_max_age_at` ON `sessions`(`max_age_at`)
;
CREATE INDEX `idx_sessions_expires_at` ON `sessions`(`expires_at`)
;
CREATE INDEX `idx_sessions_ip_address` ON `sessions`(`ip_address`)
;
CREATE INDEX `idx_sessions_updated_at` ON `sessions`(`updated_at`)
;
CREATE INDEX `idx_sessions_created_at` ON `sessions`(`created_at`)
;
CREATE INDEX `idx_recipients_company_id` ON `recipients`(`company_id`)
;
CREATE INDEX `idx_recipients_extra_identifier` ON `recipients`(`extra_identifier`)
;
CREATE INDEX `idx_recipients_phone` ON `recipients`(`phone`)
;
CREATE UNIQUE INDEX `idx_recipients_email` ON `recipients`(`email`)
;
CREATE INDEX `idx_recipients_deleted_at` ON `recipients`(`deleted_at`)
;
CREATE INDEX `idx_recipients_updated_at` ON `recipients`(`updated_at`)
;
CREATE INDEX `idx_recipients_created_at` ON `recipients`(`created_at`)
;
CREATE INDEX `idx_recipient_groups_company_id` ON `recipient_groups`(`company_id`)
;
CREATE UNIQUE INDEX `idx_recipient_groups_unique_name_and_company_id` ON `recipient_groups`(`name`,`company_id`)
;
CREATE INDEX `idx_recipient_groups_name` ON `recipient_groups`(`name`)
;
CREATE INDEX `idx_recipient_groups_updated_at` ON `recipient_groups`(`updated_at`)
;
CREATE INDEX `idx_recipient_groups_created_at` ON `recipient_groups`(`created_at`)
;
CREATE UNIQUE INDEX `idx_recipient_group` ON `recipient_group_recipients`(`recipient_id`,`recipient_group_id`)
;
CREATE INDEX `idx_domains_own_managed_tls` ON `domains`(`own_managed_tls`)
;
CREATE INDEX `idx_domains_managed_tls_certs` ON `domains`(`managed_tls_certs`)
;
CREATE INDEX `idx_domains_proxy_id` ON `domains`(`proxy_id`)
;
CREATE INDEX `idx_domains_company_id` ON `domains`(`company_id`)
;
CREATE INDEX `idx_domains_updated_at` ON `domains`(`updated_at`)
;
CREATE INDEX `idx_domains_created_at` ON `domains`(`created_at`)
;
CREATE INDEX `idx_pages_name` ON `pages`(`name`)
;
CREATE UNIQUE INDEX `idx_pages_unique_name_and_company_id` ON `pages`(`company_id`,`name`)
;
CREATE INDEX `idx_pages_company_id` ON `pages`(`company_id`)
;
CREATE INDEX `idx_pages_updated_at` ON `pages`(`updated_at`)
;
CREATE INDEX `idx_pages_created_at` ON `pages`(`created_at`)
;
CREATE INDEX `idx_proxies_name` ON `proxies`(`name`)
;
CREATE UNIQUE INDEX `idx_proxies_unique_name_and_company_id` ON `proxies`(`company_id`,`name`)
;
CREATE INDEX `idx_proxies_company_id` ON `proxies`(`company_id`)
;
CREATE INDEX `idx_proxies_updated_at` ON `proxies`(`updated_at`)
;
CREATE INDEX `idx_proxies_created_at` ON `proxies`(`created_at`)
;
CREATE UNIQUE INDEX `idx_smtp_configurations_unique_name_and_company_id` ON `smtp_configurations`(`name`,`company_id`)
;
CREATE INDEX `idx_smtp_configurations_updated_at` ON `smtp_configurations`(`updated_at`)
;
CREATE INDEX `idx_smtp_configurations_created_at` ON `smtp_configurations`(`created_at`)
;
CREATE INDEX `idx_smtp_headers_smtp_configuration_id` ON `smtp_headers`(`smtp_configuration_id`)
;
CREATE INDEX `idx_smtp_headers_updated_at` ON `smtp_headers`(`updated_at`)
;
CREATE INDEX `idx_smtp_headers_created_at` ON `smtp_headers`(`created_at`)
;
CREATE INDEX `idx_emails_company_id` ON `emails`(`company_id`)
;
CREATE UNIQUE INDEX `idx_emails_name_company_id` ON `emails`(`name`,`company_id`)
;
CREATE INDEX `idx_emails_name` ON `emails`(`name`)
;
CREATE INDEX `idx_emails_updated_at` ON `emails`(`updated_at`)
;
CREATE INDEX `idx_emails_created_at` ON `emails`(`created_at`)
;
CREATE INDEX `idx_email_attachments_attachment_id` ON `email_attachments`(`attachment_id`)
;
CREATE INDEX `idx_email_attachments_email_id` ON `email_attachments`(`email_id`)
;
CREATE UNIQUE INDEX `idx_identifiers_name` ON `identifiers`(`name`)
;
CREATE INDEX `idx_campaign_templates_company_id` ON `campaign_templates`(`company_id`)
;
CREATE INDEX `idx_campaign_templates_api_sender_id` ON `campaign_templates`(`api_sender_id`)
;
CREATE INDEX `idx_campaign_templates_smtp_configuration_id` ON `campaign_templates`(`smtp_configuration_id`)
;
CREATE INDEX `idx_campaign_templates_email_id` ON `campaign_templates`(`email_id`)
;
CREATE INDEX `idx_campaign_templates_after_landing_proxy_id` ON `campaign_templates`(`after_landing_proxy_id`)
;
CREATE INDEX `idx_campaign_templates_after_landing_page_id` ON `campaign_templates`(`after_landing_page_id`)
;
CREATE INDEX `idx_campaign_templates_before_landing_proxy_id` ON `campaign_templates`(`before_landing_proxy_id`)
;
CREATE INDEX `idx_campaign_templates_before_landing_page_id` ON `campaign_templates`(`before_landing_page_id`)
;
CREATE INDEX `idx_campaign_templates_state_identifier_id` ON `campaign_templates`(`state_identifier_id`)
;
CREATE INDEX `idx_campaign_templates_url_identifier_id` ON `campaign_templates`(`url_identifier_id`)
;
CREATE INDEX `idx_campaign_templates_domain_id` ON `campaign_templates`(`domain_id`)
;
CREATE INDEX `idx_campaign_templates_landing_proxy_id` ON `campaign_templates`(`landing_proxy_id`)
;
CREATE INDEX `idx_campaign_templates_landing_page_id` ON `campaign_templates`(`landing_page_id`)
;
CREATE INDEX `idx_campaign_templates_is_usable` ON `campaign_templates`(`is_usable`)
;
CREATE INDEX `idx_campaign_templates_url_path` ON `campaign_templates`(`url_path`)
;
CREATE UNIQUE INDEX `idx_campaign_templates_unique_name_and_company_id` ON `campaign_templates`(`name`,`company_id`)
;
CREATE INDEX `idx_campaign_templates_name` ON `campaign_templates`(`name`)
;
CREATE INDEX `idx_campaign_templates_updated_at` ON `campaign_templates`(`updated_at`)
;
CREATE INDEX `idx_campaign_templates_created_at` ON `campaign_templates`(`created_at`)
;
CREATE INDEX `idx_events_name` ON `events`(`name`)
;
CREATE INDEX `idx_events_created_at` ON `events`(`created_at`)
;
CREATE INDEX `idx_campaigns_webhook_id` ON `campaigns`(`webhook_id`)
;
CREATE INDEX `idx_campaigns_notable_event_id` ON `campaigns`(`notable_event_id`)
;
CREATE INDEX `idx_campaigns_evasion_page_id` ON `campaigns`(`evasion_page_id`)
;
CREATE INDEX `idx_campaigns_deny_page_id` ON `campaigns`(`deny_page_id`)
;
CREATE UNIQUE INDEX `idx_campaigns_unique_name_and_company_id` ON `campaigns`(`company_id`,`name`)
;
CREATE INDEX `idx_campaigns_company_id` ON `campaigns`(`company_id`,`company_id`)
;
CREATE INDEX `idx_campaigns_campaign_template_id` ON `campaigns`(`campaign_template_id`)
;
CREATE INDEX `idx_campaigns_constraint_end_time` ON `campaigns`(`constraint_end_time`)
;
CREATE INDEX `idx_campaigns_constraint_start_time` ON `campaigns`(`constraint_start_time`)
;
CREATE INDEX `idx_campaigns_send_end_at` ON `campaigns`(`send_end_at`)
;
CREATE INDEX `idx_campaigns_send_start_at` ON `campaigns`(`send_start_at`)
;
CREATE INDEX `idx_campaigns_anonymized_at` ON `campaigns`(`anonymized_at`)
;
CREATE INDEX `idx_campaigns_anonymize_at` ON `campaigns`(`anonymize_at`)
;
CREATE INDEX `idx_campaigns_closed_at` ON `campaigns`(`closed_at`)
;
CREATE INDEX `idx_campaigns_close_at` ON `campaigns`(`close_at`)
;
CREATE INDEX `idx_campaigns_updated_at` ON `campaigns`(`updated_at`)
;
CREATE INDEX `idx_campaigns_created_at` ON `campaigns`(`created_at`)
;
CREATE UNIQUE INDEX `idx_allow_denies_unique_name_and_company_id` ON `allow_denies`(`company_id`,`name`)
;
CREATE INDEX `idx_allow_denies_updated_at` ON `allow_denies`(`updated_at`)
;
CREATE INDEX `idx_allow_denies_created_at` ON `allow_denies`(`created_at`)
;
CREATE INDEX `idx_campaign_allow_denies_allow_deny_id` ON `campaign_allow_denies`(`allow_deny_id`)
;
CREATE UNIQUE INDEX `idx_campaign_allow_denies` ON `campaign_allow_denies`(`campaign_id`,`allow_deny_id`)
;
CREATE INDEX `idx_campaign_allow_denies_campaign_id` ON `campaign_allow_denies`(`campaign_id`)
;
CREATE INDEX `idx_campaign_recipient_groups_recipient_group_id` ON `campaign_recipient_groups`(`recipient_group_id`)
;
CREATE UNIQUE INDEX `idx_campaign_recipient_group` ON `campaign_recipient_groups`(`campaign_id`,`recipient_group_id`)
;
CREATE INDEX `idx_campaign_recipient_groups_campaign_id` ON `campaign_recipient_groups`(`campaign_id`)
;
CREATE INDEX `idx_campaign_recipients_notable_event_id` ON `campaign_recipients`(`notable_event_id`)
;
CREATE INDEX `idx_campaign_recipients_recipient_id` ON `campaign_recipients`(`recipient_id`)
;
CREATE INDEX `idx_campaign_recipients_sent_at` ON `campaign_recipients`(`sent_at`)
;
CREATE INDEX `idx_campaign_recipients_last_attempt_at` ON `campaign_recipients`(`last_attempt_at`)
;
CREATE INDEX `idx_campaign_recipients_send_at` ON `campaign_recipients`(`send_at`)
;
CREATE INDEX `idx_campaign_recipients_cancelled_at` ON `campaign_recipients`(`cancelled_at`)
;
CREATE UNIQUE INDEX `idx_campaign_recipients_campaign_id_recipient_id` ON `campaign_recipients`(`campaign_id`,`recipient_id`)
;
CREATE INDEX `idx_campaign_recipients_updated_at` ON `campaign_recipients`(`updated_at`)
;
CREATE INDEX `idx_campaign_recipients_created_at` ON `campaign_recipients`(`created_at`)
;
CREATE INDEX `idx_campaign_events_company_id` ON `campaign_events`(`company_id`,`company_id`)
;
CREATE INDEX `idx_campaign_events_recipient_id` ON `campaign_events`(`recipient_id`)
;
CREATE INDEX `idx_campaign_events_anonymized_id` ON `campaign_events`(`anonymized_id`)
;
CREATE INDEX `idx_campaign_events_event_id` ON `campaign_events`(`event_id`)
;
CREATE INDEX `idx_campaign_events_campaign_id` ON `campaign_events`(`campaign_id`)
;
CREATE INDEX `idx_campaign_events_created_at` ON `campaign_events`(`created_at`)
;
CREATE INDEX `idx_attachments_embedded_content` ON `attachments`(`embedded_content`)
;
CREATE INDEX `idx_attachments_filename` ON `attachments`(`filename`)
;
CREATE INDEX `idx_attachments_name` ON `attachments`(`name`)
;
CREATE INDEX `idx_attachments_company_id` ON `attachments`(`company_id`)
;
CREATE INDEX `idx_attachments_updated_at` ON `attachments`(`updated_at`)
;
CREATE INDEX `idx_attachments_created_at` ON `attachments`(`created_at`)
;
CREATE UNIQUE INDEX `idx_webhooks_unique_name_and_company_id` ON `webhooks`(`company_id`,`name`)
;
CREATE INDEX `idx_webhooks_updated_at` ON `webhooks`(`updated_at`)
;
CREATE INDEX `idx_webhooks_created_at` ON `webhooks`(`created_at`)
;
CREATE INDEX `idx_campaign_stats_campaign_closed_at` ON `campaign_stats`(`campaign_closed_at`)
;
CREATE INDEX `idx_campaign_stats_campaign_end_date` ON `campaign_stats`(`campaign_end_date`)
;
CREATE INDEX `idx_campaign_stats_campaign_start_date` ON `campaign_stats`(`campaign_start_date`)
;
CREATE INDEX `idx_campaign_stats_company_id` ON `campaign_stats`(`company_id`)
;
CREATE INDEX `idx_campaign_stats_campaign_id` ON `campaign_stats`(`campaign_id`)
;
CREATE INDEX `idx_campaign_stats_created_at` ON `campaign_stats`(`created_at`)
;
CREATE UNIQUE INDEX idx_api_senders_name_null_company_id ON api_senders (name) WHERE (company_id IS NULL)
;
CREATE UNIQUE INDEX idx_recipient_groups_name_null_company_id ON recipient_groups (name) WHERE (company_id IS NULL)
;
CREATE UNIQUE INDEX idx_pages_name_null_company_id ON pages (name) WHERE (company_id IS NULL)
;
CREATE UNIQUE INDEX idx_proxies_name_null_company_id ON proxies (name) WHERE (company_id IS NULL)
;
CREATE UNIQUE INDEX idx_smtp_configurations_name_null_company_id ON smtp_configurations (name) WHERE (company_id IS NULL)
;
CREATE UNIQUE INDEX idx_emails_name_null_company_id ON emails (name) WHERE (company_id IS NULL)
;
CREATE UNIQUE INDEX idx_campaign_templates_name_null_company_id ON campaign_templates (name) WHERE (company_id IS NULL)
;
CREATE UNIQUE INDEX idx_campaigns_name_null_company_id ON campaigns (name) WHERE (company_id IS NULL)
;
CREATE UNIQUE INDEX idx_allow_denies_name_null_company_id ON allow_denies (name) WHERE (company_id IS NULL)
;
CREATE UNIQUE INDEX idx_webhooks_name_null_company_id ON webhooks (name) WHERE (company_id IS NULL)
;