albs_analytics/build_analytics/migrations/3.sql

80 lines
1.8 KiB
MySQL
Raw Normal View History

2023-03-13 19:30:40 +00:00
BEGIN;
2023-03-15 10:28:12 +00:00
-- test_tasks_status_enum
CREATE TABLE test_tasks_status_enum(
2023-03-13 19:30:40 +00:00
id INTEGER PRIMARY KEY,
value VARCHAR(15)
);
2023-03-15 10:28:12 +00:00
INSERT INTO test_tasks_status_enum (id, value)
2023-03-13 19:30:40 +00:00
VALUES
2023-03-15 10:28:12 +00:00
(1, 'created'),
(2, 'started'),
(3, 'completed'),
(4, 'failed');
2023-03-13 19:30:40 +00:00
2023-03-15 10:28:12 +00:00
-- test_tasks
CREATE TABLE test_tasks (
2023-03-13 19:30:40 +00:00
id INTEGER PRIMARY KEY,
build_task_id INTEGER REFERENCES build_tasks(id) ON DELETE CASCADE,
revision INTEGER,
2023-03-15 10:28:12 +00:00
status_id INTEGER REFERENCES test_tasks_status_enum(id) ON DELETE SET NULL,
package_fullname VARCHAR(100),
started_at DOUBLE PRECISION
2023-03-13 19:30:40 +00:00
);
2023-03-15 10:28:12 +00:00
CREATE INDEX test_tasks_build_task_id
ON test_tasks(build_task_id);
2023-03-13 19:30:40 +00:00
2023-03-15 10:28:12 +00:00
CREATE INDEX test_tasks_build_status_id
ON test_tasks(status_id);
2023-03-13 19:30:40 +00:00
2023-03-15 10:28:12 +00:00
CREATE INDEX test_tasks_package_fullname
ON test_tasks(package_fullname);
2023-03-13 19:30:40 +00:00
2023-03-15 10:28:12 +00:00
-- test_steps_enum
CREATE TABLE test_steps_enum (
2023-03-13 19:30:40 +00:00
id INTEGER PRIMARY KEY,
value VARCHAR(50)
);
2023-03-15 10:28:12 +00:00
INSERT INTO test_steps_enum (id, value)
2023-03-13 19:30:40 +00:00
VALUES
2023-03-15 10:28:12 +00:00
(0, 'install_package'),
(1, 'stop_environment'),
(2, 'initial_provision'),
(3, 'start_environment'),
(4, 'uninstall_package'),
(5, 'initialize_terraform'),
2023-03-16 08:31:09 +00:00
(6, 'package_integrity_tests'),
(7, 'stop_environment');
2023-03-13 19:30:40 +00:00
2023-03-16 17:57:31 +00:00
-- test_steps_stats
2023-03-15 10:28:12 +00:00
CREATE TABLE test_steps_stats(
2023-03-16 08:31:09 +00:00
test_task_id INTEGER REFERENCES test_tasks(id) ON DELETE CASCADE,
stat_name_id INTEGER REFERENCES test_steps_enum(id) ON DELETE SET NULL,
2023-03-13 19:30:40 +00:00
start_ts DOUBLE PRECISION,
2023-03-16 08:31:09 +00:00
finish_ts DOUBLE PRECISION
2023-03-13 19:30:40 +00:00
);
2023-03-15 10:28:12 +00:00
ALTER TABLE test_steps_stats
ADD CONSTRAINT test_steps_stats_unique UNIQUE (test_task_id, stat_name_id);
2023-03-13 19:30:40 +00:00
2023-03-15 10:28:12 +00:00
CREATE INDEX test_steps_stats_start_ts
ON test_steps_stats(start_ts);
2023-03-13 19:30:40 +00:00
2023-03-15 10:28:12 +00:00
CREATE INDEX test_steps_stats_end_ts
ON test_steps_stats(finish_ts);
-- increasing size of name field
ALTER TABLE build_tasks ALTER COLUMN name TYPE varchar(150);
2023-03-13 19:30:40 +00:00
UPDATE schema_version
SET version = 3;
COMMIT;