Browse Source

docs: update README

JustSong 2 năm trước cách đây
mục cha
commit
e148ac4a1f
2 tập tin đã thay đổi với 63 bổ sung1 xóa
  1. 1 1
      README.md
  2. 62 0
      bin/migrate_v3_to_v4.sql

+ 1 - 1
README.md

@@ -545,7 +545,7 @@ send_message('标题', '描述', '**Markdown 内容**')
 
 
 ## 迁移数据库
-此处均以 SQLite 为例,其他数据库请自行修改。
+此处均以 SQLite 为例,其他数据库请自行修改。我已经让 ChatGPT 翻译成对应的 SQL 版本,见 `bin` 文件夹,供参考。
 
 ### 从 `v0.3` 迁移到 `v0.4`
 1. 首先备份你的数据库文件,复制一份,命名为 `message-pusher-v0.3.db`。

+ 62 - 0
bin/migrate_v3_to_v4.sql

@@ -0,0 +1,62 @@
+-- 未测试,仅供参考
+
+-- 插入 email 通道数据
+INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
+SELECT 'email', id, 'email', '', 1, '', '', '', '', '', UNIX_TIMESTAMP()
+FROM old_database.users
+WHERE email IS NOT NULL;
+
+-- 插入 test 通道数据
+INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
+SELECT 'test', id, 'test', '', 1, wechat_test_account_secret, wechat_test_account_id, wechat_test_account_open_id, '', wechat_test_account_template_id, UNIX_TIMESTAMP()
+FROM old_database.users
+WHERE wechat_test_account_id IS NOT NULL;
+
+-- 插入 corp_app 通道数据
+INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
+SELECT 'corp_app', id, 'corp_app', '', 1, wechat_corp_account_agent_secret, CONCAT(wechat_corp_account_id, '|', wechat_corp_account_agent_id), wechat_corp_account_user_id, '', wechat_corp_account_client_type, UNIX_TIMESTAMP()
+FROM old_database.users
+WHERE wechat_corp_account_id IS NOT NULL;
+
+-- 插入 lark 通道数据
+INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
+SELECT 'lark', id, 'lark', '', 1, lark_webhook_secret, '', '', lark_webhook_url, '', UNIX_TIMESTAMP()
+FROM old_database.users
+WHERE lark_webhook_url IS NOT NULL;
+
+-- 插入 ding 通道数据
+INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
+SELECT 'ding', id, 'ding', '', 1, ding_webhook_secret, '', '', ding_webhook_url, '', UNIX_TIMESTAMP()
+FROM old_database.users
+WHERE ding_webhook_url IS NOT NULL;
+
+-- 插入 corp 通道数据
+INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
+SELECT 'corp', id, 'corp', '', 1, '', '', '', corp_webhook_url, '', UNIX_TIMESTAMP()
+FROM old_database.users
+WHERE corp_webhook_url IS NOT NULL;
+
+-- 插入 bark 通道数据
+INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
+SELECT 'bark', id, 'bark', '', 1, bark_secret, '', '', bark_server, '', UNIX_TIMESTAMP()
+FROM old_database.users
+WHERE bark_server IS NOT NULL;
+
+-- 插入 telegram 通道数据
+INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
+SELECT 'telegram', id, 'telegram', '', 1, telegram_bot_token, '', telegram_chat_id, '', '', UNIX_TIMESTAMP()
+FROM old_database.users
+WHERE telegram_bot_token IS NOT NULL;
+
+-- 插入 discord 通道数据
+INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
+SELECT 'discord', id, 'discord', '', 1, '', '', '', discord_webhook_url, '', UNIX_TIMESTAMP()
+FROM old_database.users
+WHERE discord_webhook_url IS NOT NULL;
+
+-- 插入 client 通道数据
+INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
+SELECT 'client', id, 'client', '', 1, client_secret, '', '', '', '', UNIX_TIMESTAMP()
+FROM old_database.users
+WHERE client_secret IS NOT NULL;
+