fix: update test fixtures schema (resolve #786)

This commit is contained in:
Ferdinand Mütsch
2025-05-10 17:02:04 +02:00
parent 8c8ae5d7ee
commit ff287eaa12

View File

@@ -9,7 +9,7 @@ CREATE TABLE `aliases` (`id` integer PRIMARY KEY AUTOINCREMENT,`type` integer NO
DROP TABLE IF EXISTS "diagnostics";
CREATE TABLE `diagnostics` (`id` integer PRIMARY KEY AUTOINCREMENT,`platform` text,`architecture` text,`plugin` text,`cli_version` text,`logs` text,`stack_trace` text);
DROP TABLE IF EXISTS "durations";
CREATE TABLE `durations` (`user_id` text NOT NULL,`time` timestamp NOT NULL,`duration` integer NOT NULL,`project` text,`language` text,`editor` text,`operating_system` text,`machine` text,`category` text,`branch` text,`entity` text,`num_heartbeats` integer,`group_hash` varchar(17),`interval` integer NOT NULL DEFAULT 600000000000);
CREATE TABLE `durations` (`id` integer PRIMARY KEY AUTOINCREMENT,`user_id` text NOT NULL,`time` timestamp NOT NULL,`duration` integer NOT NULL,`project` text,`language` text,`editor` text,`operating_system` text,`machine` text,`category` text,`branch` text,`entity` text,`num_heartbeats` integer,`group_hash` varchar(17),`timeout` integer NOT NULL DEFAULT 600000000000);
DROP TABLE IF EXISTS "heartbeats";
CREATE TABLE `heartbeats` (`id` integer PRIMARY KEY AUTOINCREMENT,`user_id` text NOT NULL,`entity` text NOT NULL,`type` text,`category` text,`project` text,`branch` text,`language` text,`is_write` numeric,`editor` text,`operating_system` text,`machine` text,`user_agent` varchar(255),`time` timestamp(3),`hash` varchar(17),`origin` varchar(255),`origin_id` varchar(255),`created_at` timestamp(3),`lines` integer,`line_no` integer,`cursor_pos` integer,`line_deletions` integer,`line_additions` integer,`project_root_count` integer,CONSTRAINT `fk_heartbeats_user` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE);
DROP TABLE IF EXISTS "key_string_values";
@@ -17,15 +17,15 @@ CREATE TABLE `key_string_values` (`key` text,`value` text,PRIMARY KEY (`key`));
DROP TABLE IF EXISTS "language_mappings";
CREATE TABLE `language_mappings` (`id` integer PRIMARY KEY AUTOINCREMENT,`user_id` text NOT NULL,`extension` varchar(16),`language` varchar(64),CONSTRAINT `fk_language_mappings_user` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE);
DROP TABLE IF EXISTS "leaderboard_items";
CREATE TABLE `leaderboard_items` (`id` integer PRIMARY KEY AUTOINCREMENT,`user_id` text NOT NULL,`interval` text NOT NULL,`by` integer,`total` integer NOT NULL,`key` text,`created_at` timestamp DEFAULT CURRENT_TIMESTAMP,CONSTRAINT `fk_leaderboard_items_user` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE);
CREATE TABLE `leaderboard_items` (`id` integer PRIMARY KEY AUTOINCREMENT,`user_id` text NOT NULL,`interval` text NOT NULL,`by` integer,`total` integer NOT NULL,`key` text,`created_at` timestamp,CONSTRAINT `fk_leaderboard_items_user` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE);
DROP TABLE IF EXISTS "project_labels";
CREATE TABLE `project_labels` (`id` integer PRIMARY KEY AUTOINCREMENT,`user_id` text NOT NULL,`project_key` text,`label` varchar(64),CONSTRAINT `fk_project_labels_user` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE);
DROP TABLE IF EXISTS "summaries";
CREATE TABLE `summaries` (`id` integer PRIMARY KEY AUTOINCREMENT,`user_id` text NOT NULL,`from_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,`to_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,`num_heartbeats` integer,CONSTRAINT `fk_summaries_user` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE);
CREATE TABLE `summaries` (`id` integer PRIMARY KEY AUTOINCREMENT,`user_id` text NOT NULL,`from_time` timestamp NOT NULL,`to_time` timestamp NOT NULL,`num_heartbeats` integer,CONSTRAINT `fk_summaries_user` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE);
DROP TABLE IF EXISTS "summary_items";
CREATE TABLE `summary_items` (`id` integer PRIMARY KEY AUTOINCREMENT,`summary_id` integer,`type` integer,`key` text,`total` integer,CONSTRAINT `fk_summaries_projects` FOREIGN KEY (`summary_id`) REFERENCES `summaries`(`id`) ON DELETE CASCADE ON UPDATE CASCADE);
DROP TABLE IF EXISTS "users";
CREATE TABLE `users` (`id` text,`api_key` text DEFAULT NULL,`email` text,`location` text,`password` text,`created_at` timestamp DEFAULT CURRENT_TIMESTAMP,`last_logged_in_at` timestamp DEFAULT CURRENT_TIMESTAMP,`share_data_max_days` integer,`share_editors` numeric DEFAULT false,`share_languages` numeric DEFAULT false,`share_projects` numeric DEFAULT false,`share_oss` numeric DEFAULT false,`share_machines` numeric DEFAULT false,`share_labels` numeric DEFAULT false,`share_activity_chart` numeric DEFAULT false,`is_admin` numeric DEFAULT false,`has_data` numeric DEFAULT false,`wakatime_api_key` text,`wakatime_api_url` text,`reset_token` text,`reports_weekly` numeric DEFAULT false,`public_leaderboard` numeric DEFAULT false,`subscribed_until` timestamp,`subscription_renewal` timestamp,`stripe_customer_id` text,`invited_by` text,`exclude_unknown_projects` numeric,`heartbeats_timeout_sec` integer DEFAULT 600,PRIMARY KEY (`id`),CONSTRAINT `uni_users_api_key` UNIQUE (`api_key`));
CREATE TABLE `users` (`id` text,`api_key` text DEFAULT NULL,`email` text,`location` text,`password` text,`created_at` timestamp,`last_logged_in_at` timestamp,`share_data_max_days` integer,`share_editors` numeric DEFAULT false,`share_languages` numeric DEFAULT false,`share_projects` numeric DEFAULT false,`share_oss` numeric DEFAULT false,`share_machines` numeric DEFAULT false,`share_labels` numeric DEFAULT false,`share_activity_chart` numeric DEFAULT false,`is_admin` numeric DEFAULT false,`has_data` numeric DEFAULT false,`wakatime_api_key` text,`wakatime_api_url` text,`reset_token` text,`reports_weekly` numeric DEFAULT false,`public_leaderboard` numeric DEFAULT false,`subscribed_until` timestamp,`subscription_renewal` timestamp,`stripe_customer_id` text,`invited_by` text,`exclude_unknown_projects` numeric,`heartbeats_timeout_sec` integer DEFAULT 600,PRIMARY KEY (`id`),CONSTRAINT `uni_users_api_key` UNIQUE (`api_key`));
DROP INDEX IF EXISTS "idx_alias_type_key";
CREATE INDEX `idx_alias_type_key` ON `aliases`(`type`,`key`);
DROP INDEX IF EXISTS "idx_alias_user";