-- --------------------------------------------------------
-- Host:                         host700513.hostido.net.pl
-- Wersja serwera:               10.11.15-MariaDB-cll-lve - MariaDB Server
-- Serwer OS:                    Linux
-- HeidiSQL Wersja:              12.6.0.6765
-- --------------------------------------------------------

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!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 */;

-- Zrzut struktury tabela host700513_adspro.campaigns
CREATE TABLE IF NOT EXISTS `campaigns` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `client_id` int(11) NOT NULL DEFAULT 0,
  `campaign_id` bigint(20) NOT NULL DEFAULT 0,
  `campaign_name` varchar(255) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `client_id` (`client_id`),
  CONSTRAINT `FK__clients` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=123 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.campaigns_comments
CREATE TABLE IF NOT EXISTS `campaigns_comments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `campaign_id` int(11) NOT NULL,
  `comment` text NOT NULL,
  `date_add` date NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`) USING BTREE,
  KEY `campaign_id` (`campaign_id`),
  CONSTRAINT `FK_campaigns_comments_campaigns` FOREIGN KEY (`campaign_id`) REFERENCES `campaigns` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.campaigns_history
CREATE TABLE IF NOT EXISTS `campaigns_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `campaign_id` int(11) NOT NULL DEFAULT 0,
  `roas_30_days` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `roas_all_time` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `budget` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `money_spent` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversion_value` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `bidding_strategy` text DEFAULT NULL,
  `date_add` date NOT NULL DEFAULT '0000-00-00',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `offer_id` (`campaign_id`) USING BTREE,
  CONSTRAINT `FK_campaigns_history_campaigns` FOREIGN KEY (`campaign_id`) REFERENCES `campaigns` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4400 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.clients
CREATE TABLE IF NOT EXISTS `clients` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL DEFAULT '0',
  `google_ads_customer_id` varchar(20) DEFAULT NULL,
  `google_ads_start_date` date DEFAULT NULL,
  `deleted` int(11) DEFAULT 0,
  `bestseller_min_roas` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.phrases
CREATE TABLE IF NOT EXISTS `phrases` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `client_id` int(11) NOT NULL DEFAULT 0,
  `phrase` varchar(255) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `FK_phrases_clients` (`client_id`),
  CONSTRAINT `FK_phrases_clients` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5512 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.phrases_history
CREATE TABLE IF NOT EXISTS `phrases_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `phrase_id` int(11) NOT NULL DEFAULT 0,
  `impressions` int(11) NOT NULL DEFAULT 0,
  `clicks` int(11) NOT NULL DEFAULT 0,
  `cost` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversions` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversions_value` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `date_add` date NOT NULL DEFAULT '0000-00-00',
  `updated` int(11) NOT NULL DEFAULT 0,
  `deleted` int(11) DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  KEY `offer_id` (`phrase_id`) USING BTREE,
  CONSTRAINT `FK_phrases_history_phrases` FOREIGN KEY (`phrase_id`) REFERENCES `phrases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=13088 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.phrases_history_30
CREATE TABLE IF NOT EXISTS `phrases_history_30` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `phrase_id` int(11) NOT NULL,
  `impressions` int(11) NOT NULL,
  `clicks` int(11) NOT NULL,
  `cost` decimal(20,6) NOT NULL,
  `conversions` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversions_value` decimal(20,6) NOT NULL,
  `roas` decimal(20,6) NOT NULL,
  `date_add` date NOT NULL DEFAULT '0000-00-00',
  `deleted` int(11) DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  KEY `offer_id` (`phrase_id`) USING BTREE,
  CONSTRAINT `FK_phrases_history_30_phrases` FOREIGN KEY (`phrase_id`) REFERENCES `phrases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1795 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.phrases_temp
CREATE TABLE IF NOT EXISTS `phrases_temp` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `phrase_id` int(11) DEFAULT NULL,
  `phrase` varchar(255) DEFAULT NULL,
  `impressions` int(11) DEFAULT NULL,
  `clicks` int(11) DEFAULT NULL,
  `cost` decimal(20,6) DEFAULT NULL,
  `conversions` decimal(20,6) DEFAULT NULL,
  `conversions_value` decimal(20,6) DEFAULT NULL,
  `cpc` decimal(20,6) DEFAULT NULL,
  `roas` decimal(20,0) DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  KEY `offer_id` (`phrase_id`) USING BTREE,
  CONSTRAINT `FK_phrases_temp_phrases` FOREIGN KEY (`phrase_id`) REFERENCES `phrases` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=353973 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.products
CREATE TABLE IF NOT EXISTS `products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `client_id` int(11) NOT NULL DEFAULT 0,
  `offer_id` varchar(50) NOT NULL DEFAULT '0',
  `name` varchar(255) NOT NULL DEFAULT '0',
  `min_roas` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FK_offers_clients` (`client_id`),
  CONSTRAINT `FK_offers_clients` FOREIGN KEY (`client_id`) REFERENCES `clients` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5927 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.products_comments
CREATE TABLE IF NOT EXISTS `products_comments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `product_id` int(11) NOT NULL,
  `comment` text NOT NULL,
  `date_add` date NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `product_id` (`product_id`) USING BTREE,
  CONSTRAINT `FK_products_comments_products` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=118 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.products_data
CREATE TABLE IF NOT EXISTS `products_data` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `product_id` int(11) DEFAULT NULL,
  `custom_label_4` varchar(255) DEFAULT NULL,
  `custom_label_3` varchar(255) DEFAULT NULL,
  `title` varchar(255) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `google_product_category` text DEFAULT NULL,
  `product_url` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `product_id` (`product_id`) USING BTREE,
  CONSTRAINT `FK_products_data_products` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=118 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.products_history
CREATE TABLE IF NOT EXISTS `products_history` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `product_id` int(11) NOT NULL DEFAULT 0,
  `impressions` int(11) NOT NULL DEFAULT 0,
  `clicks` int(11) NOT NULL DEFAULT 0,
  `ctr` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `cost` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversions` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversions_value` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `date_add` date NOT NULL DEFAULT '0000-00-00',
  `updated` int(11) NOT NULL DEFAULT 0,
  `deleted` int(11) DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  KEY `product_id` (`product_id`) USING BTREE,
  CONSTRAINT `FK_products_history_products` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=63549 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.products_history_30
CREATE TABLE IF NOT EXISTS `products_history_30` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `product_id` int(11) NOT NULL,
  `impressions` int(11) NOT NULL,
  `clicks` int(11) NOT NULL,
  `ctr` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `cost` decimal(20,6) NOT NULL,
  `conversions` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversions_value` decimal(20,6) NOT NULL,
  `roas` decimal(20,6) NOT NULL,
  `roas_all_time` decimal(20,6) NOT NULL,
  `date_add` date NOT NULL DEFAULT '0000-00-00',
  `deleted` int(11) DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `product_id` (`product_id`) USING BTREE,
  CONSTRAINT `FK_products_history_30_products` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=27655 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.products_temp
CREATE TABLE IF NOT EXISTS `products_temp` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `product_id` int(11) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `impressions` int(11) DEFAULT NULL,
  `impressions_30` int(11) DEFAULT NULL,
  `clicks` int(11) DEFAULT NULL,
  `clicks_30` int(11) DEFAULT NULL,
  `ctr` decimal(20,6) DEFAULT NULL,
  `cost` decimal(20,6) DEFAULT NULL,
  `conversions` decimal(20,6) DEFAULT NULL,
  `conversions_value` decimal(20,6) DEFAULT NULL,
  `cpc` decimal(20,6) DEFAULT NULL,
  `roas` decimal(20,0) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `product_id` (`product_id`) USING BTREE,
  CONSTRAINT `FK_products_temp_products` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=298845 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.settings
CREATE TABLE IF NOT EXISTS `settings` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `setting_key` varchar(100) NOT NULL,
  `setting_value` text DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_setting_key` (`setting_key`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;

-- Eksport danych został odznaczony.

-- Zrzut struktury tabela host700513_adspro.users
CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `surname` varchar(255) DEFAULT NULL,
  `default_project` int(11) DEFAULT NULL,
  `color` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_polish_ci;

-- Eksport danych został odznaczony.

/*!40103 SET TIME_ZONE=IFNULL(@OLD_TIME_ZONE, 'system') */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;

-- ================================
-- DODANE: struktury kampanie > grupy/frazy
-- ================================

CREATE TABLE IF NOT EXISTS `campaign_ad_groups` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `campaign_id` int(11) NOT NULL,
  `ad_group_id` bigint(20) NOT NULL,
  `ad_group_name` varchar(255) NOT NULL DEFAULT '',
  `impressions_30` int(11) NOT NULL DEFAULT 0,
  `clicks_30` int(11) NOT NULL DEFAULT 0,
  `cost_30` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversions_30` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversion_value_30` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `roas_30` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `impressions_all_time` int(11) NOT NULL DEFAULT 0,
  `clicks_all_time` int(11) NOT NULL DEFAULT 0,
  `cost_all_time` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversions_all_time` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversion_value_all_time` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `roas_all_time` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `date_sync` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_campaign_ad_groups_campaign_ad_group` (`campaign_id`,`ad_group_id`),
  KEY `idx_campaign_ad_groups_campaign_id` (`campaign_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `campaign_search_terms` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `campaign_id` int(11) NOT NULL,
  `ad_group_id` int(11) NOT NULL,
  `search_term` varchar(255) NOT NULL,
  `impressions_30` int(11) NOT NULL DEFAULT 0,
  `clicks_30` int(11) NOT NULL DEFAULT 0,
  `cost_30` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversions_30` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversion_value_30` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `roas_30` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `impressions_all_time` int(11) NOT NULL DEFAULT 0,
  `clicks_all_time` int(11) NOT NULL DEFAULT 0,
  `cost_all_time` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversions_all_time` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `conversion_value_all_time` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `roas_all_time` decimal(20,6) NOT NULL DEFAULT 0.000000,
  `date_sync` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_campaign_search_terms` (`campaign_id`,`ad_group_id`,`search_term`),
  KEY `idx_campaign_search_terms_campaign_id` (`campaign_id`),
  KEY `idx_campaign_search_terms_ad_group_id` (`ad_group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `campaign_negative_keywords` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `campaign_id` int(11) NOT NULL,
  `ad_group_id` int(11) DEFAULT NULL,
  `scope` varchar(20) NOT NULL DEFAULT 'campaign',
  `keyword_text` varchar(255) NOT NULL,
  `match_type` varchar(40) DEFAULT NULL,
  `date_sync` date DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_campaign_negative_keywords_campaign_id` (`campaign_id`),
  KEY `idx_campaign_negative_keywords_ad_group_id` (`ad_group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
