Advertisement
Ruslan_Rayanov

falcon_clearSolution

Apr 21st, 2022
1,375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 3.25 KB | None | 0 0
  1. CREATE OR ALTER PROCEDURE [dbo].falcon_clearSolution
  2.     @check nvarchar(128)
  3. AS
  4. BEGIN
  5.     if(@check<>'yes') begin
  6.         select 'Нужно установить check=yes для очистки данных базы. Будут удалены основные бизнес объекты, кроме сист юзеров и точки 4'
  7.         return
  8.     end
  9.  
  10.  
  11. declare @survPointID int = 4
  12. delete from as_changeLog
  13. delete from as_codeRevisions
  14.  
  15. delete from as_comments
  16.  
  17. delete from as_contacts
  18.  
  19. delete from as_emailLettersBody
  20. delete from as_emailLetters
  21. delete from as_emails
  22. delete from as_emailBoxes
  23.  
  24. delete from as_mailing_log
  25. delete from as_events
  26.  
  27. delete from as_msg_red
  28. delete from as_msg_messages
  29. delete from as_msg_roomUsers
  30. delete from as_msg_rooms
  31.  
  32. delete from as_nt_notifications
  33.  
  34. delete from as_exportImportLogItems
  35. delete from as_exportImportLog
  36.  
  37. delete from as_en_statusesLog
  38. delete from [dbo].[as_en_entityInstanceFields]
  39. delete from as_en_entityInstances
  40. delete   FROM as_rs_resources
  41. where entityCode in ('chat', 'prod', 'point', 'articleTitleImage',
  42. 'articleBodyImage', 'order', 'product', 'request')
  43.  
  44. truncate table as_trace
  45. truncate table as_userActions
  46. delete from as_userSettings
  47.  
  48. delete from tg_log
  49. delete from [dbo].[tg_settings]
  50.  
  51.  
  52. delete from faq_items
  53.  
  54.  
  55. delete from fin_scores
  56. delete from fin_financeStatusLog
  57. delete from fin_finances
  58.  
  59. delete from frm_topicTags
  60. delete from frm_posts
  61. delete from frm_topics
  62.  
  63. delete from ord_cartItems
  64. delete from ord_carts
  65. delete from ord_orders
  66. delete from ord_favorites
  67.  
  68. delete from srv_bookingSlots
  69. delete from srv_bookings
  70. delete from srv_bookedSlots
  71. delete from srv_bookingProducts
  72.  
  73. delete from srv_orderItems
  74. delete from [dbo].[srv_orders]
  75.  
  76. delete from srv_kpItems
  77. delete from srv_kps
  78. delete from srv_kpCats
  79.  
  80.  
  81.  
  82. delete from srv_requests
  83. delete from srv_clients
  84. update srv_points set directorID = NULL, notificationManagerID = NULL
  85. where id not in (@survPointID)
  86.  
  87. delete from srv_managers
  88.  
  89. delete from srv_points where id not in (@survPointID)
  90. delete from srv_pointLands where pointID not in (@survPointID)
  91.  
  92. delete from fin_accounts
  93. where contragentID not in (92, 192)
  94.     and contragentID not in (select contragentID from srv_points)
  95.  
  96.  
  97. delete from ctr_contragents where id not in (92, 192) and id not in (select contragentID from srv_points)
  98.  
  99. delete from ctr_contacts where contragentID not in (select id from ctr_contragents)
  100.  
  101. delete from as_api_actionLog
  102.  
  103. delete from as_userRoles
  104. where userID not in (select id from as_users where username in ('admin', 'editor1', 'sitemanager1'))
  105.  
  106. delete from [as_act_actorUsers]
  107. where userID not in (select id from as_users where username in ('admin', 'editor1', 'sitemanager1'))
  108.  
  109. delete from as_users where username not in ('admin', 'editor1', 'sitemanager1')
  110.  
  111.  
  112.  
  113. update as_settings set value = '_______ НУЖНО ЗАПОЛНИТЬ __________'
  114. where code in ('mail.password', 'mail.from', 'mail.loginEmail', 'robots.txt', 'testEmail',
  115. 'domain', 'blogAuthor', 'blogAuthorImg', 'blogBottomText')
  116.  
  117. update as_settings set value = ''
  118. where code in ('CommonScripts', 'CommonStyles', 'helpChatKey', 'publicDadataToken')
  119.  
  120. declare @msg nvarchar(256) = 'Очистка закончена '
  121. Select @msg
  122. print @msg
  123.  
  124.    
  125. END
  126.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement