--
-- Host: localhost    Database: riptv
-- ------------------------------------------------------


--
-- Table structure for table `advertisement`
--

CREATE TABLE `advertisement` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `ad_type` varchar(20) NOT NULL,
  `redirect_url` varchar(500) NOT NULL,
  `screens` varchar(100) NOT NULL,
  `file_path` varchar(500) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `position` int(11) NOT NULL DEFAULT 0,
  `enabled` tinyint(1) NOT NULL DEFAULT 1,
  `order_id` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `advertisement`
--


--
-- Table structure for table `api_servers`
--

CREATE TABLE `api_servers` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `created_at` datetime DEFAULT NULL,
  `ip_address` varchar(255) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `password` varchar(255) DEFAULT NULL,
  `port` int(11) NOT NULL,
  `ssh_port` int(11) DEFAULT NULL,
  `apache_port` int(10) unsigned DEFAULT 80,
  `status` varchar(255) DEFAULT NULL,
  `username` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `api_servers`
--


--
-- Table structure for table `apk_register_config`
--

CREATE TABLE `apk_register_config` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `client_name` varchar(100) DEFAULT NULL,
  `iptv_ip` varchar(255) DEFAULT NULL,
  `vod_ip` varchar(255) DEFAULT NULL,
  `catchup_ip` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `apk_register_config`
--

INSERT INTO `apk_register_config` VALUES (1,'AJK','http://192.168.50.35:8080','http://192.168.50.21:8585','http://192.168.50.35:8080');

--
-- Table structure for table `apk_registered_devices`
--

CREATE TABLE `apk_registered_devices` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `android_id` varchar(64) DEFAULT NULL,
  `device_id` varchar(64) DEFAULT NULL,
  `client_id` varchar(64) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `android_id` (`android_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `apk_registered_devices`
--

INSERT INTO `apk_registered_devices` VALUES (1,'6AF7CD24754933C4','deviceId','1','2025-12-23 11:12:33');

--
-- Table structure for table `category`
--

CREATE TABLE `category` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `order_id` int(11) DEFAULT NULL,
  `language` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `category`
--


--
-- Table structure for table `category_channel`
--

CREATE TABLE `category_channel` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `category_id` bigint(20) NOT NULL,
  `channel_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `category_id` (`category_id`),
  KEY `channel_id` (`channel_id`),
  CONSTRAINT `category_channel_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`),
  CONSTRAINT `category_channel_ibfk_2` FOREIGN KEY (`channel_id`) REFERENCES `channel` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `category_channel`
--


--
-- Table structure for table `channel`
--

CREATE TABLE `channel` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `channel_name` varchar(255) NOT NULL,
  `udp_url` varchar(255) NOT NULL,
  `output_type` varchar(50) NOT NULL,
  `output_udp` varchar(255) DEFAULT NULL,
  `output_interface` varchar(100) DEFAULT NULL,
  `drm_enabled` tinyint(1) DEFAULT 0,
  `is_paid` tinyint(1) NOT NULL DEFAULT 1,
  `service_id` varchar(50) DEFAULT NULL,
  `logo_path` varchar(500) DEFAULT NULL,
  `folder_path` varchar(500) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `status` varchar(20) DEFAULT NULL,
  `lcn` varchar(10) DEFAULT NULL,
  `epg` varchar(50) DEFAULT NULL,
  `server_name` varchar(50) NOT NULL DEFAULT 'primary',
  `server_ip` varchar(50) NOT NULL DEFAULT '127.0.0.1',
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `channel`
--

INSERT INTO `channel` VALUES (3,'URL','235.10.3.2:1025','HLS','/riptv/live/URL/index.m3u8','192.168.1.234',0,1,'145','/riptv/channellogo/URL.png','/home/user/RIDSYSPACKAGE/riptv/live/URL','2026-01-08 10:07:46','Active','14','14','primary','192.168.1.234','2026-01-08 10:53:31');

--
-- Table structure for table `client_ip_config`
--

CREATE TABLE `client_ip_config` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `client_id` varchar(64) DEFAULT NULL,
  `client_name` varchar(100) DEFAULT NULL,
  `iptv_ip` varchar(255) DEFAULT NULL,
  `vod_ip` varchar(255) DEFAULT NULL,
  `catchup_ip` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `client_id` (`client_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `client_ip_config`
--


--
-- Table structure for table `dashboard`
--

CREATE TABLE `dashboard` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `description` varchar(255) DEFAULT NULL,
  `port` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `dashboard`
--


--
-- Table structure for table `epg_channel`
--

CREATE TABLE `epg_channel` (
  `id` varchar(100) NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `lang` varchar(10) DEFAULT NULL,
  `icon` text DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `epg_channel`
--


--
-- Table structure for table `epg_program`
--

CREATE TABLE `epg_program` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `channel` varchar(100) DEFAULT NULL,
  `start_time` datetime DEFAULT NULL,
  `end_time` datetime DEFAULT NULL,
  `title` varchar(255) DEFAULT NULL,
  `description` text DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `epg_program`
--


--
-- Table structure for table `favorite_channel`
--

CREATE TABLE `favorite_channel` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) NOT NULL,
  `channel_id` bigint(20) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `sub_id` bigint(20) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_fav_sub_channel` (`sub_id`,`channel_id`),
  UNIQUE KEY `UK1svvepw6n4jqce1623akwa6qb` (`sub_id`,`channel_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `favorite_channel`
--


--
-- Table structure for table `networks`
--

CREATE TABLE `networks` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `landing_channel_id` varchar(255) DEFAULT NULL,
  `multiscreen` bit(1) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `network_id` varchar(255) DEFAULT NULL,
  `watermark` varchar(255) DEFAULT NULL,
  `watermark_type` varchar(10) DEFAULT NULL,
  `watermark_logo_path` text DEFAULT NULL,
  `network_logo_path` text DEFAULT NULL,
  `mso_qr_path` text DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `networks`
--


--
-- Table structure for table `otaupdate`
--

CREATE TABLE `otaupdate` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `version` varchar(255) NOT NULL,
  `force_update` tinyint(1) NOT NULL,
  `file_name` varchar(255) NOT NULL,
  `created_at` datetime NOT NULL,
  `status` varchar(20) NOT NULL DEFAULT 'STARTED',
  PRIMARY KEY (`id`),
  UNIQUE KEY `version` (`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `otaupdate`
--


--
-- Table structure for table `roles`
--

CREATE TABLE `roles` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `roles`
--

INSERT INTO `roles` VALUES (3,'ROLE_ADMIN'),(5,'ROLE_EMPLOYEE'),(4,'ROLE_OPERATOR'),(1,'ROLE_USER');

--
-- Table structure for table `secondary_udp`
--

CREATE TABLE `secondary_udp` (
  `id` bigint(20) NOT NULL,
  `audio_codec` varchar(255) DEFAULT NULL,
  `bitrate` varchar(255) DEFAULT NULL,
  `network_interface` varchar(255) DEFAULT NULL,
  `packet_size` int(11) NOT NULL,
  `resolution` varchar(255) DEFAULT NULL,
  `service_name` varchar(255) DEFAULT NULL,
  `status` varchar(255) DEFAULT NULL,
  `udp_url` varchar(255) NOT NULL,
  `video_codec` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `secondary_udp`
--


--
-- Table structure for table `secondary_udp_registry`
--

CREATE TABLE `secondary_udp_registry` (
  `id` bigint(20) NOT NULL,
  `udp_url` varchar(255) NOT NULL,
  `service_name` varchar(255) DEFAULT NULL,
  `video_codec` varchar(128) DEFAULT NULL,
  `audio_codec` varchar(128) DEFAULT NULL,
  `resolution` varchar(64) DEFAULT NULL,
  `bitrate` varchar(64) DEFAULT NULL,
  `network_interface` varchar(64) DEFAULT NULL,
  `packet_size` int(11) DEFAULT 0,
  `status` varchar(20) DEFAULT 'inactive',
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_udp_url` (`udp_url`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `secondary_udp_registry`
--


--
-- Table structure for table `stream_port`
--

CREATE TABLE `stream_port` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `description` varchar(255) DEFAULT NULL,
  `port` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `stream_port`
--

INSERT INTO `stream_port` VALUES (1,'Main Stream',1011),(3,'Main Stream 2',1012);

--
-- Table structure for table `streaming_servers`
--

CREATE TABLE `streaming_servers` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  `ip` varchar(50) NOT NULL,
  `status` varchar(20) DEFAULT 'active',
  `apache_port` int(11) NOT NULL DEFAULT 80,
  `protocol` varchar(10) NOT NULL DEFAULT 'http',
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `streaming_servers`
--

INSERT INTO `streaming_servers` VALUES (1,'primary','192.168.1.234','active',80,'http');

--
-- Table structure for table `udp_inputs`
--

CREATE TABLE `udp_inputs` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `udp_url` varchar(255) NOT NULL,
  `video_codec` varchar(100) DEFAULT NULL,
  `audio_codec` varchar(100) DEFAULT NULL,
  `resolution` varchar(50) DEFAULT NULL,
  `channel_bitrate` varchar(50) DEFAULT NULL,
  `service_name` varchar(255) DEFAULT NULL,
  `network_interface` varchar(50) DEFAULT NULL,
  `server_id` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `udp_url` (`udp_url`),
  KEY `FK36yqcp6olu9ea2hef7tji5qnv` (`server_id`),
  CONSTRAINT `FK36yqcp6olu9ea2hef7tji5qnv` FOREIGN KEY (`server_id`) REFERENCES `streaming_servers` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `udp_inputs`
--


--
-- Table structure for table `unicast_status`
--

CREATE TABLE `unicast_status` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `running` tinyint(1) DEFAULT NULL,
  `server_ip` varchar(50) DEFAULT NULL,
  `interface_ip` varchar(50) DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `port` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `unicast_status`
--


--
-- Table structure for table `user_activity`
--

CREATE TABLE `user_activity` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) DEFAULT NULL,
  `username` varchar(100) DEFAULT NULL,
  `role` varchar(50) DEFAULT NULL,
  `action` varchar(100) DEFAULT NULL,
  `endpoint` varchar(255) DEFAULT NULL,
  `method` varchar(10) DEFAULT NULL,
  `ip_address` varchar(50) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `target_name` varchar(255) DEFAULT NULL,
  `old_value` text DEFAULT NULL,
  `new_value` text DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `user_activity`
--



--
-- Table structure for table `user_roles`
--

CREATE TABLE `user_roles` (
  `user_id` bigint(20) NOT NULL,
  `role_id` bigint(20) NOT NULL,
  PRIMARY KEY (`user_id`,`role_id`),
  KEY `role_id` (`role_id`),
  CONSTRAINT `user_roles_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
  CONSTRAINT `user_roles_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `user_roles`
--

INSERT INTO `user_roles` VALUES (1,3),(2,3),(3,1),(4,1);


