feat: 初始化数据库模式并引入AI记账服务。

This commit is contained in:
2026-01-28 15:46:21 +08:00
parent 6604f50448
commit 57def08201
5 changed files with 86 additions and 28 deletions

View File

@@ -0,0 +1,22 @@
-- Notifications table
CREATE TABLE IF NOT EXISTS `notifications` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime(3) DEFAULT NULL,
`updated_at` datetime(3) DEFAULT NULL,
`deleted_at` datetime(3) DEFAULT NULL,
`user_id` bigint(20) unsigned NOT NULL,
`title` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL,
`content` text COLLATE utf8mb4_unicode_ci NOT NULL,
`type` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'system',
`is_read` tinyint(1) DEFAULT '0',
`link` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`read_at` datetime(3) DEFAULT NULL,
`related_id` bigint(20) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_notifications_deleted_at` (`deleted_at`),
KEY `idx_notifications_user_id` (`user_id`),
KEY `idx_notifications_type` (`type`),
KEY `idx_notifications_is_read` (`is_read`),
KEY `idx_notifications_related_id` (`related_id`),
CONSTRAINT `fk_users_notifications` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;