--
-- Host: localhost    Database: gpm_privateserver
-- ------------------------------------------------------


--
-- Table structure for table `group_shares`
--

CREATE TABLE `group_shares` (
  `id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `group_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `role` enum('FULL','EDIT','VIEW') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'VIEW',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `group_shares_group_id_user_id_unique` (`group_id`,`user_id`),
  KEY `group_shares_user_id_foreign` (`user_id`),
  CONSTRAINT `group_shares_group_id_foreign` FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`) ON DELETE CASCADE,
  CONSTRAINT `group_shares_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `group_shares`
--


--
-- Table structure for table `groups`
--

CREATE TABLE `groups` (
  `id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `sort_order` int NOT NULL DEFAULT '0',
  `created_by` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `updated_by` char(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `groups_created_by_foreign` (`created_by`),
  KEY `groups_updated_by_foreign` (`updated_by`),
  CONSTRAINT `groups_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`),
  CONSTRAINT `groups_updated_by_foreign` FOREIGN KEY (`updated_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `groups`
--

INSERT INTO `groups` VALUES ('00000000-0000-0000-0000-000000000000','Default group',0,'ab693d72-8ba7-4017-8ca7-8fd44948afba','2025-09-02 20:02:49','2025-09-02 20:02:49','ab693d72-8ba7-4017-8ca7-8fd44948afba');

--
-- Table structure for table `migrations`
--

CREATE TABLE `migrations` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `migrations`
--

INSERT INTO `migrations` VALUES (1,'2014_10_12_000000_create_users_table',1),(2,'2019_12_14_000001_create_personal_access_tokens_table',1),(3,'2022_07_15_080228_create_groups_table',1),(4,'2022_07_15_080407_create_profiles_table',1),(5,'2022_07_15_080434_create_settings_table',1),(6,'2025_06_02_183313_migrate_env_settings_to_database',1),(7,'2025_06_05_105312_update_users_table_structure',1),(8,'2025_06_05_105325_create_group_shares_table',1),(9,'2025_06_05_105431_create_tags_table',1),(10,'2025_06_05_105444_update_profiles_table_structure',1),(11,'2025_06_05_105456_create_profile_shares_table',1),(12,'2025_06_05_105500_create_profile_tags_table',1),(13,'2025_06_05_105504_create_proxies_table',1),(14,'2025_06_05_105508_create_proxy_tags_table',1),(15,'2025_06_05_105512_update_groups_table_structure',1),(16,'2025_06_17_125338_create_cache_table',1),(17,'2025_06_21_144103_create_proxy_shares_table',1),(18,'2025_06_21_144137_add_created_by_to_proxies_table',1),(19,'2025_06_21_151018_update_proxies_table_to_new_schema',1),(20,'2025_06_21_154847_add_unique_constraint_to_proxies_table',1),(21,'2025_06_23_110231_modify_profiles_json_data_to_fingerprint_and_dynamic_data',1),(22,'2025_06_24_153216_add_category_to_tags_table',1),(23,'2025_06_24_222504_add_created_by_to_tags_table',1),(24,'2025_08_29_033731_update_proxies_table',1);

--
-- Table structure for table `profile_shares`
--

CREATE TABLE `profile_shares` (
  `id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `profile_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `role` enum('FULL','EDIT','VIEW') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'VIEW',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `profile_shares_profile_id_user_id_unique` (`profile_id`,`user_id`),
  KEY `profile_shares_user_id_foreign` (`user_id`),
  CONSTRAINT `profile_shares_profile_id_foreign` FOREIGN KEY (`profile_id`) REFERENCES `profiles` (`id`) ON DELETE CASCADE,
  CONSTRAINT `profile_shares_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `profile_shares`
--


--
-- Table structure for table `profile_tags`
--

CREATE TABLE `profile_tags` (
  `id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `profile_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `tag_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `profile_tags_profile_id_tag_id_unique` (`profile_id`,`tag_id`),
  KEY `profile_tags_tag_id_foreign` (`tag_id`),
  CONSTRAINT `profile_tags_profile_id_foreign` FOREIGN KEY (`profile_id`) REFERENCES `profiles` (`id`) ON DELETE CASCADE,
  CONSTRAINT `profile_tags_tag_id_foreign` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `profile_tags`
--


--
-- Table structure for table `profiles`
--

CREATE TABLE `profiles` (
  `id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `storage_type` enum('S3','GOOGLE_DRIVE','LOCAL') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'S3',
  `storage_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `fingerprint_data` text COLLATE utf8mb4_unicode_ci,
  `dynamic_data` text COLLATE utf8mb4_unicode_ci,
  `meta_data` longtext COLLATE utf8mb4_unicode_ci,
  `group_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_by` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_run_by` char(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_run_at` datetime DEFAULT NULL,
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '1 - already, 2 - in use',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `using_by` char(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `last_used_at` timestamp NULL DEFAULT NULL,
  `usage_count` int NOT NULL DEFAULT '0',
  `is_deleted` tinyint(1) NOT NULL DEFAULT '0',
  `deleted_at` timestamp NULL DEFAULT NULL,
  `deleted_by` char(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `profiles_group_id_foreign` (`group_id`),
  KEY `profiles_last_run_by_foreign` (`last_run_by`),
  KEY `profiles_created_by_foreign` (`created_by`),
  KEY `profiles_using_by_foreign` (`using_by`),
  KEY `profiles_deleted_by_foreign` (`deleted_by`),
  CONSTRAINT `profiles_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`),
  CONSTRAINT `profiles_deleted_by_foreign` FOREIGN KEY (`deleted_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  CONSTRAINT `profiles_group_id_foreign` FOREIGN KEY (`group_id`) REFERENCES `groups` (`id`),
  CONSTRAINT `profiles_last_run_by_foreign` FOREIGN KEY (`last_run_by`) REFERENCES `users` (`id`),
  CONSTRAINT `profiles_using_by_foreign` FOREIGN KEY (`using_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `profiles`
--


--
-- Table structure for table `proxies`
--

CREATE TABLE `proxies` (
  `id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `meta_data` longtext COLLATE utf8mb4_unicode_ci,
  `raw_proxy` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `created_by` char(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `updated_by` char(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unique_raw_proxy_per_user` (`raw_proxy`,`created_by`),
  KEY `proxies_created_by_foreign` (`created_by`),
  CONSTRAINT `proxies_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `proxies`
--


--
-- Table structure for table `proxy_shares`
--

CREATE TABLE `proxy_shares` (
  `id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `proxy_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `role` enum('FULL','EDIT','VIEW') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'VIEW',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `proxy_shares_proxy_id_user_id_unique` (`proxy_id`,`user_id`),
  KEY `proxy_shares_user_id_foreign` (`user_id`),
  CONSTRAINT `proxy_shares_proxy_id_foreign` FOREIGN KEY (`proxy_id`) REFERENCES `proxies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `proxy_shares_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `proxy_shares`
--


--
-- Table structure for table `proxy_tags`
--

CREATE TABLE `proxy_tags` (
  `id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `proxy_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `tag_id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `proxy_tags_proxy_id_tag_id_unique` (`proxy_id`,`tag_id`),
  KEY `proxy_tags_tag_id_foreign` (`tag_id`),
  CONSTRAINT `proxy_tags_proxy_id_foreign` FOREIGN KEY (`proxy_id`) REFERENCES `proxies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `proxy_tags_tag_id_foreign` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `proxy_tags`
--


--
-- Table structure for table `settings`
--

CREATE TABLE `settings` (
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `value` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  UNIQUE KEY `settings_name_unique` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `settings`
--

INSERT INTO `settings` VALUES ('s3_region','APEast1');

--
-- Table structure for table `tags`
--

CREATE TABLE `tags` (
  `id` char(36) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `color` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `category` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_by` char(36) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `tags_name_category_unique` (`name`,`category`),
  KEY `tags_created_by_foreign` (`created_by`),
  CONSTRAINT `tags_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `tags`
--



