dicemy's picture
Upload 655 files
e8c001c verified
Raw
History Blame Contribute Delete
18.1 kB
-- mysql_019 database initialization: create tables + load seed data
-- Executed via: mysql -u root < init_db.sql
-- Fix: MySQL root default auth_socket blocks pymysql TCP connections,
-- switch to mysql_native_password so pymysql (Python) can connect.
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root123';
FLUSH PRIVILEGES;
CREATE DATABASE IF NOT EXISTS internal_platform_db
DEFAULT CHARACTER SET utf8mb4
DEFAULT COLLATE utf8mb4_unicode_ci;
USE internal_platform_db;
-- Input table 1: dwd_knowledge_base_sensors_event_di (sensor events, simplified to GT-relevant columns)
CREATE TABLE IF NOT EXISTS dwd_knowledge_base_sensors_event_di_mysql_019 (
`event` VARCHAR(256) DEFAULT NULL,
`user_id` VARCHAR(256) DEFAULT NULL,
`distinct_id` VARCHAR(256) DEFAULT NULL,
`date` VARCHAR(256) DEFAULT NULL,
`time` VARCHAR(256) DEFAULT NULL,
`receive_time` VARCHAR(256) DEFAULT NULL,
`os` VARCHAR(256) DEFAULT NULL,
`appname` VARCHAR(256) DEFAULT NULL,
`ip` VARCHAR(256) DEFAULT NULL,
`track_signup_original_id` VARCHAR(256) DEFAULT NULL,
`group_id` VARCHAR(256) DEFAULT NULL,
`post_id` VARCHAR(256) DEFAULT NULL,
`show_groups` VARCHAR(256) DEFAULT NULL,
`author_nick` VARCHAR(256) DEFAULT NULL,
`source_page` VARCHAR(256) DEFAULT NULL,
`source_module` VARCHAR(256) DEFAULT NULL,
`operation_type` VARCHAR(256) DEFAULT NULL,
`platform_type` VARCHAR(256) DEFAULT NULL,
`target_type` VARCHAR(256) DEFAULT NULL,
`target_id` VARCHAR(256) DEFAULT NULL,
`year` VARCHAR(256) DEFAULT NULL,
`month` VARCHAR(256) DEFAULT NULL,
`day` VARCHAR(256) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO dwd_knowledge_base_sensors_event_di_mysql_019
(`event`, `user_id`, `distinct_id`, `date`, `time`, `receive_time`, `os`, `appname`, `ip`,
`track_signup_original_id`, `group_id`, `post_id`, `show_groups`, `author_nick`,
`source_page`, `source_module`, `operation_type`, `platform_type`,
`target_type`, `target_id`, `year`, `month`, `day`)
VALUES
('postdetailview', 'u001', 'nick_a', '20260608', '2026-06-08 10:00:00', '2026-06-08 10:00:01', 'ios', 'knowledge_base', '192.168.1.1',
'track01', 'grp_code_1', '1001', '101', 'author_a',
'page1', 'mod1', 'op_type1', 'pc',
'target_t1', 'tid1', '2026', '06', '08'),
('postdigg', 'u002', 'nick_b', '20260608', '2026-06-08 11:00:00', '2026-06-08 11:00:01', 'android', 'knowledge_base', '10.0.0.1',
'track02', '102', '1002', NULL, 'author_b',
'page2', 'mod2', 'op_type2', 'android',
'target_t2', 'tid2', '2026', '06', '08'),
('postbooknowledge_baseark', 'u003', 'nick_c', '20260608', '2026-06-08 12:00:00', '2026-06-08 12:00:01', 'h5', 'knowledge_base', '172.16.0.1',
'track03', 'grp_code_1', '1001', '101', 'author_c',
'page3', 'mod3', 'op_type3', 'h5',
'target_t3', 'tid3', '2026', '06', '08'),
('commentsend', 'u004', 'nick_d', '20260608', '2026-06-08 13:00:00', '2026-06-08 13:00:01', 'windows', 'knowledge_base', '8.8.8.8',
'track04', '100', '1003', NULL, 'author_d',
'page4', 'mod4', 'op_type4', 'windows',
'target_t4', 'tid4', '2026', '06', '08'),
('postcomment', 'u005', 'nick_a', '20260608', '2026-06-08 14:00:00', '2026-06-08 14:00:01', 'ios', 'knowledge_base', '1.1.1.1',
'track05', 'grp_code_1', '1002', '102', 'author_e',
'page5', 'mod5', 'op_type5', 'ios',
'target_t5', 'tid5', '2026', '06', '08'),
-- 诱饵 (decoy): event NOT in whitelist; passes all other filters -> must be dropped by event whitelist
('pageview', 'u101', 'nick_x', '20260608', '2026-06-08 15:00:00', '2026-06-08 15:00:01', 'ios', 'knowledge_base', '2.2.2.2',
'track11', '101', '1001', '101', 'author_x',
'page6', 'mod6', 'op_type6', 'ios',
'target_t6', 'tid6', '2026', '06', '08'),
-- 诱饵 (decoy): group_id AND show_groups both NULL -> must be dropped by (group_id IS NOT NULL OR show_groups IS NOT NULL)
('postdigg', 'u102', 'nick_y', '20260608', '2026-06-08 16:00:00', '2026-06-08 16:00:01', 'android', 'knowledge_base', '3.3.3.3',
'track12', NULL, '1001', NULL, 'author_y',
'page7', 'mod7', 'op_type7', 'android',
'target_t7', 'tid7', '2026', '06', '08'),
-- 诱饵 (decoy): post_id empty string -> must be dropped by (post_id IS NOT NULL AND post_id != '')
('postbooknowledge_baseark', 'u103', 'nick_z', '20260608', '2026-06-08 17:00:00', '2026-06-08 17:00:01', 'h5', 'knowledge_base', '4.4.4.4',
'track13', '101', '', '101', 'author_z',
'page8', 'mod8', 'op_type8', 'h5',
'target_t8', 'tid8', '2026', '06', '08');
-- Input table 2: dwv_knowledge_base_groups_users_df
CREATE TABLE IF NOT EXISTS dwv_knowledge_base_groups_users_df_mysql_019 (
`id` BIGINT DEFAULT NULL,
`nick` VARCHAR(256) DEFAULT NULL,
`group_id` BIGINT DEFAULT NULL,
`role` VARCHAR(256) DEFAULT NULL,
`created` VARCHAR(256) DEFAULT NULL,
`enabled` BIGINT DEFAULT NULL,
`origin` VARCHAR(256) DEFAULT NULL,
`is_hidden` BIGINT DEFAULT NULL,
`group_order` BIGINT DEFAULT NULL,
`at_mobile_homepage` BIGINT DEFAULT NULL,
`year` VARCHAR(256) DEFAULT NULL,
`month` VARCHAR(256) DEFAULT NULL,
`day` VARCHAR(256) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO dwv_knowledge_base_groups_users_df_mysql_019
(`id`, `nick`, `group_id`, `role`, `created`, `enabled`, `origin`, `is_hidden`, `group_order`, `at_mobile_homepage`, `year`, `month`, `day`)
VALUES
(1, 'nick_a', 101, 'member', '2025-01-01', 1, 'web', 0, 1, 0, '2026', '06', '08'),
(2, 'nick_b', 102, 'admin', '2025-02-01', 1, 'web', 0, 2, 0, '2026', '06', '08'),
(3, 'nick_c', 101, 'member', '2025-03-01', 0, 'web', 0, 3, 0, '2026', '06', '08'),
(4, 'nick_d', 103, 'member', '2025-04-01', 1, 'web', 0, 4, 0, '2026', '06', '08');
-- Input table 3: dwv_kb_posts_df
CREATE TABLE IF NOT EXISTS dwv_kb_posts_df_mysql_019 (
`id` BIGINT DEFAULT NULL,
`category_id` BIGINT DEFAULT NULL,
`title` VARCHAR(256) DEFAULT NULL,
`source` VARCHAR(256) DEFAULT NULL,
`summary` VARCHAR(256) DEFAULT NULL,
`created_by` VARCHAR(256) DEFAULT NULL,
`created` VARCHAR(256) DEFAULT NULL,
`modified_by` VARCHAR(256) DEFAULT NULL,
`modified` VARCHAR(256) DEFAULT NULL,
`read_count` BIGINT DEFAULT NULL,
`reply_count` BIGINT DEFAULT NULL,
`top` BIGINT DEFAULT NULL,
`essential` BIGINT DEFAULT NULL,
`type` VARCHAR(256) DEFAULT NULL,
`published` VARCHAR(256) DEFAULT NULL,
`post_status` VARCHAR(256) DEFAULT NULL,
`question_status` VARCHAR(256) DEFAULT NULL,
`to_expert` VARCHAR(256) DEFAULT NULL,
`score` VARCHAR(256) DEFAULT NULL,
`expiration` VARCHAR(256) DEFAULT NULL,
`authorship` VARCHAR(256) DEFAULT NULL,
`reward` VARCHAR(256) DEFAULT NULL,
`last_updated` VARCHAR(256) DEFAULT NULL,
`last_updated_by` VARCHAR(256) DEFAULT NULL,
`origin` VARCHAR(256) DEFAULT NULL,
`privacy` VARCHAR(256) DEFAULT NULL,
`guid` VARCHAR(256) DEFAULT NULL,
`digg_count` VARCHAR(256) DEFAULT NULL,
`booknowledge_baseark_count` VARCHAR(256) DEFAULT NULL,
`editor` VARCHAR(256) DEFAULT NULL,
`is_commentable` VARCHAR(256) DEFAULT NULL,
`downloadable` VARCHAR(256) DEFAULT NULL,
`short_title` VARCHAR(256) DEFAULT NULL,
`related_type` VARCHAR(256) DEFAULT NULL,
`related_id` VARCHAR(256) DEFAULT NULL,
`recommended` VARCHAR(256) DEFAULT NULL,
`intro` VARCHAR(256) DEFAULT NULL,
`has_video` VARCHAR(256) DEFAULT NULL,
`default_img` VARCHAR(256) DEFAULT NULL,
`feature_tags` VARCHAR(256) DEFAULT NULL,
`md_content` VARCHAR(256) DEFAULT NULL,
`reward_tip` VARCHAR(256) DEFAULT NULL,
`reward_count` VARCHAR(256) DEFAULT NULL,
`lead_words` VARCHAR(256) DEFAULT NULL,
`is_watermarked` VARCHAR(256) DEFAULT NULL,
`is_hidden` VARCHAR(256) DEFAULT NULL,
`last_published` VARCHAR(256) DEFAULT NULL,
`year` VARCHAR(256) DEFAULT NULL,
`month` VARCHAR(256) DEFAULT NULL,
`day` VARCHAR(256) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO dwv_kb_posts_df_mysql_019
(`id`, `category_id`, `title`, `source`, `summary`, `created_by`, `created`, `modified_by`, `modified`,
`read_count`, `reply_count`, `top`, `essential`, `type`, `published`, `post_status`, `question_status`,
`to_expert`, `score`, `expiration`, `authorship`, `reward`, `last_updated`, `last_updated_by`,
`origin`, `privacy`, `guid`, `digg_count`, `booknowledge_baseark_count`, `editor`, `is_commentable`, `downloadable`,
`short_title`, `related_type`, `related_id`, `recommended`, `intro`, `has_video`, `default_img`,
`feature_tags`, `md_content`, `reward_tip`, `reward_count`, `lead_words`, `is_watermarked`,
`is_hidden`, `last_published`, `year`, `month`, `day`)
VALUES
(1001, 201, 'Post Title 1', 'web', 'summary1', 'user1', '2025-01-01', 'user1', '2025-06-01',
100, 10, 0, 0, 'article', 'yes', 'published', '', '', '', '', 'original', '', '2025-06-01', 'user1',
'web', 'public', 'guid1', '5', '3', 'md', 'yes', 'yes', '', '', '', 'yes', 'intro1', 'no',
'', '', '', '', '', '', 'no', 'no', '2025-06-01', '2026', '06', '08'),
(1002, 202, 'Post Title 2', 'app', 'summary2', 'user2', '2025-02-01', 'user2', '2025-06-02',
200, 20, 1, 1, 'question', 'yes', 'published', 'open', '', '', '', 'repost', '', '2025-06-02', 'user2',
'app', 'private', 'guid2', '10', '5', 'rich', 'yes', 'no', '', '', '', 'no', 'intro2', 'yes',
'', '', '', '', '', '', 'no', 'no', '2025-06-02', '2026', '06', '08'),
(1003, 201, 'Post Title 3', 'web', 'summary3', 'user3', '2025-03-01', 'user3', '2025-06-03',
50, 5, 0, 0, 'article', 'yes', 'published', '', '', '', '', 'original', '', '2025-06-03', 'user3',
'web', 'public', 'guid3', '2', '1', 'md', 'yes', 'yes', '', '', '', 'yes', 'intro3', 'no',
'', '', '', '', '', '', 'no', 'no', '2025-06-03', '2026', '06', '08');
-- Input table 4: dwv_kb_categories_df
CREATE TABLE IF NOT EXISTS dwv_kb_categories_df_mysql_019 (
`id` VARCHAR(256) DEFAULT NULL,
`cat_type` VARCHAR(256) DEFAULT NULL,
`cat_id` VARCHAR(256) DEFAULT NULL,
`node_type` VARCHAR(256) DEFAULT NULL,
`name` VARCHAR(256) DEFAULT NULL,
`code` VARCHAR(256) DEFAULT NULL,
`parent_id` VARCHAR(256) DEFAULT NULL,
`created_by` VARCHAR(256) DEFAULT NULL,
`created` VARCHAR(256) DEFAULT NULL,
`modified_by` VARCHAR(256) DEFAULT NULL,
`modified` VARCHAR(256) DEFAULT NULL,
`posts_count` VARCHAR(256) DEFAULT NULL,
`relate_id` VARCHAR(256) DEFAULT NULL,
`item_order` VARCHAR(256) DEFAULT NULL,
`lft` VARCHAR(256) DEFAULT NULL,
`rgt` VARCHAR(256) DEFAULT NULL,
`enabled` VARCHAR(256) DEFAULT NULL,
`articles_count` VARCHAR(256) DEFAULT NULL,
`files_count` VARCHAR(256) DEFAULT NULL,
`topics_count` VARCHAR(256) DEFAULT NULL,
`event_logches_count` VARCHAR(256) DEFAULT NULL,
`questions_count` VARCHAR(256) DEFAULT NULL,
`color` VARCHAR(256) DEFAULT NULL,
`access_level` VARCHAR(256) DEFAULT NULL,
`year` VARCHAR(256) DEFAULT NULL,
`month` VARCHAR(256) DEFAULT NULL,
`day` VARCHAR(256) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO dwv_kb_categories_df_mysql_019
(`id`, `cat_type`, `cat_id`, `node_type`, `name`, `code`, `parent_id`, `created_by`, `created`,
`modified_by`, `modified`, `posts_count`, `relate_id`, `item_order`, `lft`, `rgt`, `enabled`,
`articles_count`, `files_count`, `topics_count`, `event_logches_count`, `questions_count`,
`color`, `access_level`, `year`, `month`, `day`)
VALUES
('201', 'post', 'c1', 'leaf', 'Tech Category', 'TC', '0', 'admin', '2024-01-01',
'admin', '2024-06-01', '50', '', '1', '1', '10', '1', '', '', '', '', '',
'blue', 'public', '2026', '06', '08'),
('202', 'post', 'c2', 'leaf', 'General Category', 'GC', '0', 'admin', '2024-01-01',
'admin', '2024-06-01', '30', '', '2', '11', '20', '1', '', '', '', '', '',
'green', 'public', '2026', '06', '08');
-- Input table 5: dwv_knowledge_base_groups_df
CREATE TABLE IF NOT EXISTS dwv_knowledge_base_groups_df_mysql_019 (
`id` VARCHAR(256) DEFAULT NULL,
`category_id` VARCHAR(256) DEFAULT NULL,
`name` VARCHAR(256) DEFAULT NULL,
`description` VARCHAR(256) DEFAULT NULL,
`code` VARCHAR(256) DEFAULT NULL,
`logo` VARCHAR(256) DEFAULT NULL,
`type` VARCHAR(256) DEFAULT NULL,
`status` VARCHAR(256) DEFAULT NULL,
`created_by` VARCHAR(256) DEFAULT NULL,
`created` VARCHAR(256) DEFAULT NULL,
`modified_by` VARCHAR(256) DEFAULT NULL,
`modified` VARCHAR(256) DEFAULT NULL,
`notice_level` VARCHAR(256) DEFAULT NULL,
`express` VARCHAR(256) DEFAULT NULL,
`bulletin` VARCHAR(256) DEFAULT NULL,
`preset_tags` VARCHAR(256) DEFAULT NULL,
`root_category_id` VARCHAR(256) DEFAULT NULL,
`access_level` VARCHAR(256) DEFAULT NULL,
`properties` VARCHAR(256) DEFAULT NULL,
`dept_id` VARCHAR(256) DEFAULT NULL,
`is_hot` VARCHAR(256) DEFAULT NULL,
`need_calendar` VARCHAR(256) DEFAULT NULL,
`need_journal` VARCHAR(256) DEFAULT NULL,
`need_platformw` VARCHAR(256) DEFAULT NULL,
`section_id` VARCHAR(256) DEFAULT NULL,
`score` VARCHAR(256) DEFAULT NULL,
`show_custom_banner` VARCHAR(256) DEFAULT NULL,
`banner` VARCHAR(256) DEFAULT NULL,
`need_video` VARCHAR(256) DEFAULT NULL,
`sync_virtual_group` VARCHAR(256) DEFAULT NULL,
`sync_partner` VARCHAR(256) DEFAULT NULL,
`sync_part_time_member` VARCHAR(256) DEFAULT NULL,
`is_public_dept` VARCHAR(256) DEFAULT NULL,
`year` VARCHAR(256) DEFAULT NULL,
`month` VARCHAR(256) DEFAULT NULL,
`day` VARCHAR(256) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO dwv_knowledge_base_groups_df_mysql_019
(`id`, `category_id`, `name`, `description`, `code`, `logo`, `type`, `status`, `created_by`, `created`,
`modified_by`, `modified`, `notice_level`, `express`, `bulletin`, `preset_tags`, `root_category_id`,
`access_level`, `properties`, `dept_id`, `is_hot`, `need_calendar`, `need_journal`, `need_platformw`,
`section_id`, `score`, `show_custom_banner`, `banner`, `need_video`, `sync_virtual_group`,
`sync_partner`, `sync_part_time_member`, `is_public_dept`, `year`, `month`, `day`)
VALUES
('101', 'cat1', 'Group A', 'desc A', '101', '', 'open', 'active', 'admin', '2024-01-01',
'admin', '2024-06-01', '1', '', '', '', '', 'public', '', '', 'no', 'no', 'no', 'no',
'', '', 'no', '', 'no', 'no', 'no', 'no', 'no', '2026', '06', '08'),
('102', 'cat2', 'Group B', 'desc B', '102', '', 'closed', 'active', 'admin', '2024-02-01',
'admin', '2024-06-02', '2', '', '', '', '', 'private', '', '', 'no', 'no', 'no', 'no',
'', '', 'no', '', 'no', 'no', 'no', 'no', 'no', '2026', '06', '08'),
('103', 'cat3', 'Group C', 'desc C', '100', '', 'open', 'active', 'admin', '2024-03-01',
'admin', '2024-06-03', '1', '', '', '', '', 'public', '', '', 'no', 'no', 'no', 'no',
'', '', 'no', '', 'no', 'no', 'no', 'no', 'no', '2026', '06', '08');
-- Output table: dwd_knowledge_base_k_bar_posts_event_di (target for GT)
CREATE TABLE IF NOT EXISTS dwd_knowledge_base_k_bar_posts_event_di_cand_mysql_019 (
`event` VARCHAR(256) DEFAULT NULL,
`distinct_id` VARCHAR(256) DEFAULT NULL,
`appname` VARCHAR(256) DEFAULT NULL,
`user_id` VARCHAR(256) DEFAULT NULL,
`event_time` VARCHAR(256) DEFAULT NULL,
`receive_time` VARCHAR(256) DEFAULT NULL,
`os` VARCHAR(256) DEFAULT NULL,
`track_signup_original_id` VARCHAR(256) DEFAULT NULL,
`author_nick` VARCHAR(256) DEFAULT NULL,
`platform_type` VARCHAR(256) DEFAULT NULL,
`target_type` VARCHAR(256) DEFAULT NULL,
`target_id` VARCHAR(256) DEFAULT NULL,
`ip` VARCHAR(256) DEFAULT NULL,
`post_id` VARCHAR(256) DEFAULT NULL,
`show_groups` VARCHAR(256) DEFAULT NULL,
`group_id` VARCHAR(256) DEFAULT NULL,
`source_page` VARCHAR(256) DEFAULT NULL,
`source_module` VARCHAR(256) DEFAULT NULL,
`operation_type` VARCHAR(256) DEFAULT NULL,
`pc_or_mobile` VARCHAR(256) DEFAULT NULL,
`is_group_member` INT DEFAULT NULL,
`post_authorship` VARCHAR(256) DEFAULT NULL,
`posts_category_id` BIGINT DEFAULT NULL,
`posts_category_name` VARCHAR(256) DEFAULT NULL,
`year` VARCHAR(256) DEFAULT NULL,
`month` VARCHAR(256) DEFAULT NULL,
`day` VARCHAR(256) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;