diff --git a/scripts/upgrade/sql/13.0.0/mysql/seahub.sql b/scripts/upgrade/sql/13.0.0/mysql/seahub.sql index 6d3bd3b4d6..ea87a64452 100644 --- a/scripts/upgrade/sql/13.0.0/mysql/seahub.sql +++ b/scripts/upgrade/sql/13.0.0/mysql/seahub.sql @@ -69,6 +69,36 @@ CREATE TABLE IF NOT EXISTS `notifications_sysusernotification` ( KEY `notifications_sysusernotification_created_at_56ffd2a0` (`created_at`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +CREATE TABLE IF NOT EXISTS `stats_ai_by_team` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `org_id` bigint(20) NOT NULL, + `month` date NOT NULL, + `model` varchar(100) NOT NULL, + `input_tokens` int(11) DEFAULT NULL, + `output_tokens` int(11) DEFAULT NULL, + `cost` double NOT NULL, + `created_at` datetime(6) DEFAULT NULL, + `updated_at` datetime(6) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `stats_ai_by_team_org_id_month_model` (`org_id`,`month`,`model`), + KEY `ix_stats_ai_by_team_org_id_month` (`org_id`,`month`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + +CREATE TABLE IF NOT EXISTS `stats_ai_by_owner` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `username` varchar(255) NOT NULL, + `month` date NOT NULL, + `model` varchar(100) NOT NULL, + `input_tokens` int(11) DEFAULT NULL, + `output_tokens` int(11) DEFAULT NULL, + `cost` double NOT NULL, + `created_at` datetime(6) DEFAULT NULL, + `updated_at` datetime(6) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `stats_ai_by_owner_username_month_model` (`username`,`month`,`model`), + KEY `ix_stats_ai_by_owner_username_month` (`username`,`month`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; + ALTER TABLE `sdoc_notification` ADD INDEX `idx_user_seen` (`username`, `seen`); ALTER TABLE organizations_orgsettings ADD COLUMN `is_active` tinyint(1) NOT NULL DEFAULT 1;