diff --git a/.env b/.env
index 0e14e18..893dd83 100644
--- a/.env
+++ b/.env
@@ -1,2 +1,3 @@
RUST_LOG=info
-DB_MYSQL_URL=mysql://rsgl:0andrx@122.152.201.90:9912/test_server
\ No newline at end of file
+#DB_MYSQL_URL=mysql://rsgl:0andrx@122.152.201.90:9912/test_server
+DB_MYSQL_URL=mysql://rsgl:0andrx@localhost:3306/test_server
\ No newline at end of file
diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
index 892e055..75e9cc7 100644
--- a/.idea/dataSources.xml
+++ b/.idea/dataSources.xml
@@ -8,5 +8,12 @@
jdbc:mysql://122.152.201.90:9912/test_server
$ProjectFileDir$
+
+ mysql.8
+ true
+ com.mysql.cj.jdbc.Driver
+ jdbc:mysql://localhost:3306/test_server
+ $ProjectFileDir$
+
\ No newline at end of file
diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml
index 56782ca..478498c 100644
--- a/.idea/sqldialects.xml
+++ b/.idea/sqldialects.xml
@@ -1,6 +1,7 @@
+
\ No newline at end of file
diff --git a/init.sql b/init.sql
index 1cdb9fa..cd4b381 100644
--- a/init.sql
+++ b/init.sql
@@ -1,29 +1,52 @@
-CREATE TABLE users (
- id INT AUTO_INCREMENT PRIMARY KEY,
- account VARCHAR(255) UNIQUE NOT NULL,
- name VARCHAR(255) NOT NULL,
- birth DATE,
- email VARCHAR(255),
- password VARCHAR(255) NOT NULL,
- phone VARCHAR(20),
- status ENUM(
+CREATE TABLE users
+(
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ account VARCHAR(255) UNIQUE NOT NULL,
+ name VARCHAR(255) NOT NULL,
+ birth DATE,
+ email VARCHAR(255),
+ password VARCHAR(255) NOT NULL,
+ phone VARCHAR(20),
+ status ENUM (
'active',
'inactive',
'suspended',
'deleted',
'locked',
- 'pending verfication'
- ) DEFAULT 'active',
+ 'pending verification'
+ ) DEFAULT 'active',
created_time DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
-INSERT INTO
- test_server.users (id, account, name, birth, password)
-VALUES
- (0, '123', 'hyh', '2000-0-03', '1');
+CREATE TABLE IF NOT EXISTS posts
+(
+ id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY COMMENT '文章ID',
+ title VARCHAR(255) NOT NULL COMMENT '标题', -- 将长度扩展为255,适应更长的标题
+ content TEXT COMMENT '内容',
+ link VARCHAR(200) COMMENT 'URL地址', -- 添加唯一索引,避免重复链接
+ popularity VARCHAR(100) COMMENT '热度', -- 假设热度是一个数值,使用 INT 类型
+ created_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+ updated_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+ INDEX idx_title (title), -- 为 title 添加索引,提高查询效率
+ INDEX idx_link (link) -- 为 link 添加索引,避免 URL 查找慢
+) ENGINE = InnoDB
+ DEFAULT CHARSET = utf8mb4
+ COLLATE = utf8mb4_unicode_ci COMMENT ='文章表';
-INSERT INTO
- test_server.users (account, name, password)
-VALUES
- ('123', 'hyh', '1');
\ No newline at end of file
+
+
+# pub id: Option,
+# pub title: Option,
+# pub content: Option,
+# pub link: Option,
+# pub popularity: Option,
+# pub created_time: Option,
+# pub updated_time: Option,
+
+
+INSERT INTO test_server.users (id, account, name, birth, password)
+VALUES (0, '123', 'hyh', '2000-0-03', '1');
+
+INSERT INTO test_server.users (account, name, password)
+VALUES ('123', 'hyh', '1');
\ No newline at end of file