-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
功能变动: - 重构数据库初始化与迁移逻辑 - 优化上榜文章查询自动补全逻辑 依赖变动: - 更新依赖库
- Loading branch information
Showing
23 changed files
with
125 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from utils.db import jianshu_pool, jpep_pool, jtools_pool | ||
|
||
|
||
async def init_db() -> None: | ||
await jianshu_pool.prepare() | ||
await jpep_pool.prepare() | ||
await jtools_pool.prepare() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- date: 2024-11-13 | ||
-- description: 初始化 | ||
|
||
CREATE ROLE jtools LOGIN PASSWORD 'jtools'; | ||
|
||
CREATE DATABASE jtools WITH OWNER = jtools; | ||
|
||
GRANT CONNECT ON DATABASE jtools TO jtools; | ||
GRANT CONNECT ON DATABASE jianshu TO jtools; | ||
GRANT CONNECT ON DATABASE jpep TO jtools; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- date: 2024-11-13 | ||
-- description: 初始化 | ||
|
||
GRANT SELECT ON TABLE article_earning_ranking_records TO jtools; | ||
GRANT SELECT ON TABLE lottery_win_records TO jtools; | ||
GRANT SELECT ON TABLE users TO jtools; | ||
|
||
CREATE EXTENSION pg_trgm; | ||
|
||
CREATE INDEX CONCURRENTLY idx_article_earning_ranking_records_ranking ON article_earning_ranking_records (ranking); | ||
CREATE INDEX CONCURRENTLY idx_lottery_win_records_time ON lottery_win_records (time); | ||
CREATE INDEX CONCURRENTLY idx_lottery_win_records_user_slug ON lottery_win_records (user_slug); | ||
CREATE INDEX CONCURRENTLY idx_lottery_win_records_award_name ON lottery_win_records (award_name); | ||
CREATE INDEX CONCURRENTLY idx_users_name ON users USING gin (name gin_trgm_ops); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- date: 2024-11-14 | ||
-- description: 添加 article_earning_ranking_records author_slug 索引 | ||
|
||
CREATE INDEX CONCURRENTLY idx_article_earning_ranking_records_author_slug ON article_earning_ranking_records (author_slug); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- date: 2024-11-13 | ||
-- description: 初始化 | ||
|
||
GRANT SELECT ON TABLE ftn_macket_records TO jtools; | ||
GRANT SELECT ON TABLE ftn_orders TO jtools; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- date: 2024-11-13 | ||
-- description: 初始化 | ||
|
||
GRANT SELECT ON TABLE debug_project_records TO jtools; | ||
GRANT SELECT ON TABLE tech_stacks TO jtools; | ||
GRANT SELECT, INSERT ON TABLE tools TO jtools; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- date: 2024-11-13 | ||
-- description: 初始化 | ||
|
||
CREATE TABLE debug_project_records ( | ||
id SMALLSERIAL CONSTRAINT pk_debug_project_records_id PRIMARY KEY, | ||
date DATE NOT NULL, | ||
type TEXT NOT NULL, | ||
module TEXT NOT NULL, | ||
description TEXT NOT NULL, | ||
user_name TEXT NOT NULL, | ||
user_slug VARCHAR(12) NOT NULL, | ||
reward SMALLINT NOT NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- date: 2024-11-13 | ||
-- description: 初始化 | ||
|
||
CREATE TYPE enum_tech_stacks_type AS ENUM ('LIBRARY', 'EXTERNAL_SERVICE'); | ||
CREATE TYPE enum_tech_stacks_scope AS ENUM ('FRONTEND', 'BACKEND', 'TOOLCHAIN'); | ||
|
||
CREATE TABLE tech_stacks ( | ||
name TEXT NOT NULL CONSTRAINT pk_tech_stacks_name PRIMARY KEY, | ||
type enum_tech_stacks_type NOT NULL, | ||
scope enum_tech_stacks_scope NOT NULL, | ||
is_self_developed BOOLEAN NOT NULL, | ||
description TEXT NOT NULL, | ||
url TEXT NOT NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-- date: 2024-11-13 | ||
-- description: 初始化 | ||
|
||
CREATE TYPE enum_tools_status AS ENUM ('NORMAL', 'DOWNGRADED', 'UNAVAILABLE'); | ||
|
||
CREATE TABLE tools ( | ||
slug TEXT CONSTRAINT pk_tools_slug PRIMARY KEY, | ||
status enum_tools_status NOT NULL, | ||
status_description TEXT, | ||
data_update_freq TEXT NOT NULL, | ||
last_update_time_table TEXT, | ||
last_update_time_order_by TEXT, | ||
last_update_time_target_field TEXT, | ||
data_count_table TEXT, | ||
data_source JSONB | ||
); |
Oops, something went wrong.