migrate_v3_to_v4.sql 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. -- 未测试,仅供参考
  2. -- 插入 email 通道数据
  3. INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
  4. SELECT 'email', id, 'email', '', 1, '', '', '', '', '', UNIX_TIMESTAMP()
  5. FROM old_database.users
  6. WHERE email IS NOT NULL;
  7. -- 插入 test 通道数据
  8. INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
  9. 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()
  10. FROM old_database.users
  11. WHERE wechat_test_account_id IS NOT NULL;
  12. -- 插入 corp_app 通道数据
  13. INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
  14. 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()
  15. FROM old_database.users
  16. WHERE wechat_corp_account_id IS NOT NULL;
  17. -- 插入 lark 通道数据
  18. INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
  19. SELECT 'lark', id, 'lark', '', 1, lark_webhook_secret, '', '', lark_webhook_url, '', UNIX_TIMESTAMP()
  20. FROM old_database.users
  21. WHERE lark_webhook_url IS NOT NULL;
  22. -- 插入 ding 通道数据
  23. INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
  24. SELECT 'ding', id, 'ding', '', 1, ding_webhook_secret, '', '', ding_webhook_url, '', UNIX_TIMESTAMP()
  25. FROM old_database.users
  26. WHERE ding_webhook_url IS NOT NULL;
  27. -- 插入 corp 通道数据
  28. INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
  29. SELECT 'corp', id, 'corp', '', 1, '', '', '', corp_webhook_url, '', UNIX_TIMESTAMP()
  30. FROM old_database.users
  31. WHERE corp_webhook_url IS NOT NULL;
  32. -- 插入 bark 通道数据
  33. INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
  34. SELECT 'bark', id, 'bark', '', 1, bark_secret, '', '', bark_server, '', UNIX_TIMESTAMP()
  35. FROM old_database.users
  36. WHERE bark_server IS NOT NULL;
  37. -- 插入 telegram 通道数据
  38. INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
  39. SELECT 'telegram', id, 'telegram', '', 1, telegram_bot_token, '', telegram_chat_id, '', '', UNIX_TIMESTAMP()
  40. FROM old_database.users
  41. WHERE telegram_bot_token IS NOT NULL;
  42. -- 插入 discord 通道数据
  43. INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
  44. SELECT 'discord', id, 'discord', '', 1, '', '', '', discord_webhook_url, '', UNIX_TIMESTAMP()
  45. FROM old_database.users
  46. WHERE discord_webhook_url IS NOT NULL;
  47. -- 插入 client 通道数据
  48. INSERT INTO channels (type, user_id, name, description, status, secret, app_id, account_id, url, other, created_time)
  49. SELECT 'client', id, 'client', '', 1, client_secret, '', '', '', '', UNIX_TIMESTAMP()
  50. FROM old_database.users
  51. WHERE client_secret IS NOT NULL;