add local mysql
This commit is contained in:
parent
b60909f240
commit
c3420dd3dc
3
.env
3
.env
@ -1,2 +1,3 @@
|
|||||||
RUST_LOG=info
|
RUST_LOG=info
|
||||||
DB_MYSQL_URL=mysql://rsgl:0andrx@122.152.201.90:9912/test_server
|
#DB_MYSQL_URL=mysql://rsgl:0andrx@122.152.201.90:9912/test_server
|
||||||
|
DB_MYSQL_URL=mysql://rsgl:0andrx@localhost:3306/test_server
|
||||||
@ -8,5 +8,12 @@
|
|||||||
<jdbc-url>jdbc:mysql://122.152.201.90:9912/test_server</jdbc-url>
|
<jdbc-url>jdbc:mysql://122.152.201.90:9912/test_server</jdbc-url>
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
</data-source>
|
</data-source>
|
||||||
|
<data-source source="LOCAL" name="test_server@localhost" uuid="854a2824-c635-4c70-aeab-ae58ed3600a4">
|
||||||
|
<driver-ref>mysql.8</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:mysql://localhost:3306/test_server</jdbc-url>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="SqlDialectMappings">
|
<component name="SqlDialectMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/init.sql" dialect="MySQL" />
|
||||||
<file url="PROJECT" dialect="MySQL" />
|
<file url="PROJECT" dialect="MySQL" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
61
init.sql
61
init.sql
@ -1,29 +1,52 @@
|
|||||||
CREATE TABLE users (
|
CREATE TABLE users
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
(
|
||||||
account VARCHAR(255) UNIQUE NOT NULL,
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
name VARCHAR(255) NOT NULL,
|
account VARCHAR(255) UNIQUE NOT NULL,
|
||||||
birth DATE,
|
name VARCHAR(255) NOT NULL,
|
||||||
email VARCHAR(255),
|
birth DATE,
|
||||||
password VARCHAR(255) NOT NULL,
|
email VARCHAR(255),
|
||||||
phone VARCHAR(20),
|
password VARCHAR(255) NOT NULL,
|
||||||
status ENUM(
|
phone VARCHAR(20),
|
||||||
|
status ENUM (
|
||||||
'active',
|
'active',
|
||||||
'inactive',
|
'inactive',
|
||||||
'suspended',
|
'suspended',
|
||||||
'deleted',
|
'deleted',
|
||||||
'locked',
|
'locked',
|
||||||
'pending verfication'
|
'pending verification'
|
||||||
) DEFAULT 'active',
|
) DEFAULT 'active',
|
||||||
created_time DATETIME DEFAULT CURRENT_TIMESTAMP,
|
created_time DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
updated_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
updated_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO
|
CREATE TABLE IF NOT EXISTS posts
|
||||||
test_server.users (id, account, name, birth, password)
|
(
|
||||||
VALUES
|
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY COMMENT '文章ID',
|
||||||
(0, '123', 'hyh', '2000-0-03', '1');
|
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
|
# pub id: Option<i32>,
|
||||||
('123', 'hyh', '1');
|
# pub title: Option<String>,
|
||||||
|
# pub content: Option<String>,
|
||||||
|
# pub link: Option<String>,
|
||||||
|
# pub popularity: Option<String>,
|
||||||
|
# pub created_time: Option<String>,
|
||||||
|
# pub updated_time: Option<String>,
|
||||||
|
|
||||||
|
|
||||||
|
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');
|
||||||
Reference in New Issue
Block a user