@bytebase/dbhub 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,74 +0,0 @@
1
- -- SQLite implementation of views and functions
2
- -- This is simplified compared to the MySQL version
3
-
4
- -- Drop views if they exist
5
- DROP VIEW IF EXISTS v_full_employee;
6
- DROP VIEW IF EXISTS v_full_department;
7
- DROP VIEW IF EXISTS emp_dept_current;
8
-
9
- -- Create helper view to get current department for employees
10
- CREATE VIEW emp_dept_current AS
11
- SELECT
12
- e.emp_no,
13
- de.dept_no
14
- FROM
15
- employee e
16
- JOIN
17
- dept_emp de ON e.emp_no = de.emp_no
18
- JOIN (
19
- SELECT
20
- emp_no,
21
- MAX(from_date) AS max_from_date
22
- FROM
23
- dept_emp
24
- GROUP BY
25
- emp_no
26
- ) latest ON de.emp_no = latest.emp_no AND de.from_date = latest.max_from_date;
27
-
28
- -- View that shows employee with their current department name
29
- CREATE VIEW v_full_employee AS
30
- SELECT
31
- e.emp_no,
32
- e.first_name,
33
- e.last_name,
34
- e.birth_date,
35
- e.gender,
36
- e.hire_date,
37
- d.dept_name AS department
38
- FROM
39
- employee e
40
- LEFT JOIN
41
- emp_dept_current edc ON e.emp_no = edc.emp_no
42
- LEFT JOIN
43
- department d ON edc.dept_no = d.dept_no;
44
-
45
- -- View to get current managers for departments
46
- CREATE VIEW current_managers AS
47
- SELECT
48
- d.dept_no,
49
- d.dept_name,
50
- e.first_name || ' ' || e.last_name AS manager
51
- FROM
52
- department d
53
- LEFT JOIN
54
- dept_manager dm ON d.dept_no = dm.dept_no
55
- JOIN (
56
- SELECT
57
- dept_no,
58
- MAX(from_date) AS max_from_date
59
- FROM
60
- dept_manager
61
- GROUP BY
62
- dept_no
63
- ) latest ON dm.dept_no = latest.dept_no AND dm.from_date = latest.max_from_date
64
- LEFT JOIN
65
- employee e ON dm.emp_no = e.emp_no;
66
-
67
- -- Create a view showing departments with their managers
68
- CREATE VIEW v_full_department AS
69
- SELECT
70
- dept_no,
71
- dept_name,
72
- manager
73
- FROM
74
- current_managers;
@@ -1,4 +0,0 @@
1
- -- SQLite doesn't have information_schema like MySQL
2
- -- This is a simpler version that just shows when the script was run
3
-
4
- SELECT 'Database loaded at ' || datetime('now', 'localtime') AS completion_time;
@@ -1,119 +0,0 @@
1
- -- Sample employee database
2
- -- See changelog table for details
3
- -- Copyright (C) 2007,2008, MySQL AB
4
- --
5
- -- Original data created by Fusheng Wang and Carlo Zaniolo
6
- -- http://www.cs.aau.dk/TimeCenter/software.htm
7
- -- http://www.cs.aau.dk/TimeCenter/Data/employeeTemporalDataSet.zip
8
- --
9
- -- Current schema by Giuseppe Maxia
10
- -- Data conversion from XML to relational by Patrick Crews
11
- -- SQLite adaptation by Claude Code
12
- --
13
- -- This work is licensed under the
14
- -- Creative Commons Attribution-Share Alike 3.0 Unported License.
15
- -- To view a copy of this license, visit
16
- -- http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to
17
- -- Creative Commons, 171 Second Street, Suite 300, San Francisco,
18
- -- California, 94105, USA.
19
- --
20
- -- DISCLAIMER
21
- -- To the best of our knowledge, this data is fabricated, and
22
- -- it does not correspond to real people.
23
- -- Any similarity to existing people is purely coincidental.
24
- --
25
-
26
- SELECT 'TESTING INSTALLATION' as 'INFO';
27
-
28
- DROP TABLE IF EXISTS expected_value;
29
- DROP TABLE IF EXISTS found_value;
30
-
31
- CREATE TABLE expected_value (
32
- table_name TEXT NOT NULL PRIMARY KEY,
33
- recs INTEGER NOT NULL,
34
- crc_md5 TEXT NOT NULL
35
- );
36
-
37
- CREATE TABLE found_value (
38
- table_name TEXT NOT NULL PRIMARY KEY,
39
- recs INTEGER NOT NULL,
40
- crc_md5 TEXT NOT NULL
41
- );
42
-
43
- INSERT INTO expected_value VALUES
44
- ('employee', 1000, '595460127fb609c2b110b1796083e242'),
45
- ('department', 9, 'd1af5e170d2d1591d776d5638d71fc5f'),
46
- ('dept_manager', 16, '8ff425d5ad6dc56975998d1893b8dca9'),
47
- ('dept_emp', 1103, 'e302aa5b56a69b49e40eb0d60674addc'),
48
- ('title', 1470, 'ba77dd331ce00f76c1643a7d73cdcee6'),
49
- ('salary', 9488, '61f22cfece4d34f5bb94c9f05a3da3ef');
50
-
51
- SELECT table_name, recs AS expected_record, crc_md5 AS expected_crc FROM expected_value;
52
-
53
- DROP TABLE IF EXISTS tchecksum;
54
- CREATE TABLE tchecksum (chk TEXT);
55
-
56
- -- For SQLite, we need to use a different approach for MD5 calculation
57
- -- Insert employee checksums
58
- INSERT INTO found_value
59
- SELECT 'employee', COUNT(*),
60
- (SELECT hex(md5(group_concat(emp_no||birth_date||first_name||last_name||gender||hire_date, '#')))
61
- FROM (SELECT * FROM employee ORDER BY emp_no))
62
- FROM employee;
63
-
64
- -- Insert department checksums
65
- INSERT INTO found_value
66
- SELECT 'department', COUNT(*),
67
- (SELECT hex(md5(group_concat(dept_no||dept_name, '#')))
68
- FROM (SELECT * FROM department ORDER BY dept_no))
69
- FROM department;
70
-
71
- -- Insert dept_manager checksums
72
- INSERT INTO found_value
73
- SELECT 'dept_manager', COUNT(*),
74
- (SELECT hex(md5(group_concat(dept_no||emp_no||from_date||to_date, '#')))
75
- FROM (SELECT * FROM dept_manager ORDER BY dept_no, emp_no))
76
- FROM dept_manager;
77
-
78
- -- Insert dept_emp checksums
79
- INSERT INTO found_value
80
- SELECT 'dept_emp', COUNT(*),
81
- (SELECT hex(md5(group_concat(dept_no||emp_no||from_date||to_date, '#')))
82
- FROM (SELECT * FROM dept_emp ORDER BY dept_no, emp_no))
83
- FROM dept_emp;
84
-
85
- -- Insert title checksums
86
- INSERT INTO found_value
87
- SELECT 'title', COUNT(*),
88
- (SELECT hex(md5(group_concat(emp_no||title||from_date||IFNULL(to_date,''), '#')))
89
- FROM (SELECT * FROM title ORDER BY emp_no, title, from_date))
90
- FROM title;
91
-
92
- -- Insert salary checksums
93
- INSERT INTO found_value
94
- SELECT 'salary', COUNT(*),
95
- (SELECT hex(md5(group_concat(emp_no||amount||from_date||to_date, '#')))
96
- FROM (SELECT * FROM salary ORDER BY emp_no, from_date, to_date))
97
- FROM salary;
98
-
99
- SELECT table_name, recs as 'found_records', crc_md5 as found_crc FROM found_value;
100
-
101
- -- Compare expected vs found
102
- SELECT
103
- e.table_name,
104
- CASE WHEN e.recs=f.recs THEN 'OK' ELSE 'not ok' END AS records_match,
105
- CASE WHEN e.crc_md5=f.crc_md5 THEN 'ok' ELSE 'not ok' END AS crc_match
106
- FROM
107
- expected_value e
108
- JOIN found_value f USING (table_name);
109
-
110
- -- Check for failures
111
- SELECT
112
- 'CRC' as summary,
113
- CASE WHEN (SELECT COUNT(*) FROM expected_value e JOIN found_value f USING(table_name) WHERE f.crc_md5 != e.crc_md5) = 0
114
- THEN 'OK' ELSE 'FAIL' END as 'result'
115
- UNION ALL
116
- SELECT
117
- 'count',
118
- CASE WHEN (SELECT COUNT(*) FROM expected_value e JOIN found_value f USING(table_name) WHERE f.recs != e.recs) = 0
119
- THEN 'OK' ELSE 'FAIL' END;