feat(database): add MySQL database support (#201)

This commit is contained in:
521141
2025-07-17 19:44:01 +08:00
committed by GitHub
parent 0ee5ef316f
commit bb5fad47cb
6 changed files with 194 additions and 26 deletions
+33
View File
@@ -0,0 +1,33 @@
-- MySQL Database Initialization Script for NewsNow
-- Run this script to create the required database and tables
-- Create database if not exists
CREATE DATABASE IF NOT EXISTS newsnow CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Use the database
USE newsnow;
-- Create cache table
CREATE TABLE IF NOT EXISTS cache (
id VARCHAR(255) PRIMARY KEY,
updated BIGINT,
data TEXT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Create user table
CREATE TABLE IF NOT EXISTS user (
id VARCHAR(255) PRIMARY KEY,
email VARCHAR(255),
data TEXT,
type VARCHAR(50),
created BIGINT,
updated BIGINT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Create index for user table
CREATE INDEX IF NOT EXISTS idx_user_id ON user(id);
-- Create MySQL user (optional - you can create this manually)
-- CREATE USER IF NOT EXISTS 'newsnow'@'%' IDENTIFIED BY 'your_password';
-- GRANT ALL PRIVILEGES ON newsnow.* TO 'newsnow'@'%';
-- FLUSH PRIVILEGES;