You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

001_setup.rb 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. # Redmine - project management software
  2. # Copyright (C) 2006 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. class Setup < ActiveRecord::Migration[4.2]
  18. class User < ActiveRecord::Base
  19. end
  20. # model removed
  21. class Permission < ActiveRecord::Base; end
  22. def self.up
  23. create_table "attachments", :force => true do |t|
  24. t.column "container_id", :integer, :default => 0, :null => false
  25. t.column "container_type", :string, :limit => 30, :default => "", :null => false
  26. t.column "filename", :string, :default => "", :null => false
  27. t.column "disk_filename", :string, :default => "", :null => false
  28. t.column "filesize", :integer, :default => 0, :null => false
  29. t.column "content_type", :string, :limit => 60, :default => ""
  30. t.column "digest", :string, :limit => 40, :default => "", :null => false
  31. t.column "downloads", :integer, :default => 0, :null => false
  32. t.column "author_id", :integer, :default => 0, :null => false
  33. t.column "created_on", :timestamp
  34. end
  35. create_table "auth_sources", :force => true do |t|
  36. t.column "type", :string, :limit => 30, :default => "", :null => false
  37. t.column "name", :string, :limit => 60, :default => "", :null => false
  38. t.column "host", :string, :limit => 60
  39. t.column "port", :integer
  40. t.column "account", :string, :limit => 60
  41. t.column "account_password", :string, :limit => 60
  42. t.column "base_dn", :string, :limit => 255
  43. t.column "attr_login", :string, :limit => 30
  44. t.column "attr_firstname", :string, :limit => 30
  45. t.column "attr_lastname", :string, :limit => 30
  46. t.column "attr_mail", :string, :limit => 30
  47. t.column "onthefly_register", :boolean, :default => false, :null => false
  48. end
  49. create_table "custom_fields", :force => true do |t|
  50. t.column "type", :string, :limit => 30, :default => "", :null => false
  51. t.column "name", :string, :limit => 30, :default => "", :null => false
  52. t.column "field_format", :string, :limit => 30, :default => "", :null => false
  53. t.column "possible_values", :text
  54. t.column "regexp", :string, :default => ""
  55. t.column "min_length", :integer, :default => 0, :null => false
  56. t.column "max_length", :integer, :default => 0, :null => false
  57. t.column "is_required", :boolean, :default => false, :null => false
  58. t.column "is_for_all", :boolean, :default => false, :null => false
  59. end
  60. create_table "custom_fields_projects", :id => false, :force => true do |t|
  61. t.column "custom_field_id", :integer, :default => 0, :null => false
  62. t.column "project_id", :integer, :default => 0, :null => false
  63. end
  64. create_table "custom_fields_trackers", :id => false, :force => true do |t|
  65. t.column "custom_field_id", :integer, :default => 0, :null => false
  66. t.column "tracker_id", :integer, :default => 0, :null => false
  67. end
  68. create_table "custom_values", :force => true do |t|
  69. t.column "customized_type", :string, :limit => 30, :default => "", :null => false
  70. t.column "customized_id", :integer, :default => 0, :null => false
  71. t.column "custom_field_id", :integer, :default => 0, :null => false
  72. t.column "value", :text
  73. end
  74. create_table "documents", :force => true do |t|
  75. t.column "project_id", :integer, :default => 0, :null => false
  76. t.column "category_id", :integer, :default => 0, :null => false
  77. t.column "title", :string, :limit => 60, :default => "", :null => false
  78. t.column "description", :text
  79. t.column "created_on", :timestamp
  80. end
  81. add_index "documents", ["project_id"], :name => "documents_project_id"
  82. create_table "enumerations", :force => true do |t|
  83. t.column "opt", :string, :limit => 4, :default => "", :null => false
  84. t.column "name", :string, :limit => 30, :default => "", :null => false
  85. end
  86. create_table "issue_categories", :force => true do |t|
  87. t.column "project_id", :integer, :default => 0, :null => false
  88. t.column "name", :string, :limit => 30, :default => "", :null => false
  89. end
  90. add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id"
  91. create_table "issue_histories", :force => true do |t|
  92. t.column "issue_id", :integer, :default => 0, :null => false
  93. t.column "status_id", :integer, :default => 0, :null => false
  94. t.column "author_id", :integer, :default => 0, :null => false
  95. t.column "notes", :text
  96. t.column "created_on", :timestamp
  97. end
  98. add_index "issue_histories", ["issue_id"], :name => "issue_histories_issue_id"
  99. create_table "issue_statuses", :force => true do |t|
  100. t.column "name", :string, :limit => 30, :default => "", :null => false
  101. t.column "is_closed", :boolean, :default => false, :null => false
  102. t.column "is_default", :boolean, :default => false, :null => false
  103. t.column "html_color", :string, :limit => 6, :default => "FFFFFF", :null => false
  104. end
  105. create_table "issues", :force => true do |t|
  106. t.column "tracker_id", :integer, :default => 0, :null => false
  107. t.column "project_id", :integer, :default => 0, :null => false
  108. t.column "subject", :string, :default => "", :null => false
  109. t.column "description", :text
  110. t.column "due_date", :date
  111. t.column "category_id", :integer
  112. t.column "status_id", :integer, :default => 0, :null => false
  113. t.column "assigned_to_id", :integer
  114. t.column "priority_id", :integer, :default => 0, :null => false
  115. t.column "fixed_version_id", :integer
  116. t.column "author_id", :integer, :default => 0, :null => false
  117. t.column "lock_version", :integer, :default => 0, :null => false
  118. t.column "created_on", :timestamp
  119. t.column "updated_on", :timestamp
  120. end
  121. add_index "issues", ["project_id"], :name => "issues_project_id"
  122. create_table "members", :force => true do |t|
  123. t.column "user_id", :integer, :default => 0, :null => false
  124. t.column "project_id", :integer, :default => 0, :null => false
  125. t.column "role_id", :integer, :default => 0, :null => false
  126. t.column "created_on", :timestamp
  127. end
  128. create_table "news", :force => true do |t|
  129. t.column "project_id", :integer
  130. t.column "title", :string, :limit => 60, :default => "", :null => false
  131. t.column "summary", :string, :limit => 255, :default => ""
  132. t.column "description", :text
  133. t.column "author_id", :integer, :default => 0, :null => false
  134. t.column "created_on", :timestamp
  135. end
  136. add_index "news", ["project_id"], :name => "news_project_id"
  137. create_table "permissions", :force => true do |t|
  138. t.column "controller", :string, :limit => 30, :default => "", :null => false
  139. t.column "action", :string, :limit => 30, :default => "", :null => false
  140. t.column "description", :string, :limit => 60, :default => "", :null => false
  141. t.column "is_public", :boolean, :default => false, :null => false
  142. t.column "sort", :integer, :default => 0, :null => false
  143. t.column "mail_option", :boolean, :default => false, :null => false
  144. t.column "mail_enabled", :boolean, :default => false, :null => false
  145. end
  146. create_table "permissions_roles", :id => false, :force => true do |t|
  147. t.column "permission_id", :integer, :default => 0, :null => false
  148. t.column "role_id", :integer, :default => 0, :null => false
  149. end
  150. add_index "permissions_roles", ["role_id"], :name => "permissions_roles_role_id"
  151. create_table "projects", :force => true do |t|
  152. t.column "name", :string, :limit => 30, :default => "", :null => false
  153. t.column "description", :string, :default => "", :null => false
  154. t.column "homepage", :string, :limit => 60, :default => ""
  155. t.column "is_public", :boolean, :default => true, :null => false
  156. t.column "parent_id", :integer
  157. t.column "projects_count", :integer, :default => 0
  158. t.column "created_on", :timestamp
  159. t.column "updated_on", :timestamp
  160. end
  161. create_table "roles", :force => true do |t|
  162. t.column "name", :string, :limit => 30, :default => "", :null => false
  163. end
  164. create_table "tokens", :force => true do |t|
  165. t.column "user_id", :integer, :default => 0, :null => false
  166. t.column "action", :string, :limit => 30, :default => "", :null => false
  167. t.column "value", :string, :limit => 40, :default => "", :null => false
  168. t.column "created_on", :datetime, :null => false
  169. end
  170. create_table "trackers", :force => true do |t|
  171. t.column "name", :string, :limit => 30, :default => "", :null => false
  172. t.column "is_in_chlog", :boolean, :default => false, :null => false
  173. end
  174. create_table "users", :force => true do |t|
  175. t.column "login", :string, :limit => 30, :default => "", :null => false
  176. t.column "hashed_password", :string, :limit => 40, :default => "", :null => false
  177. t.column "firstname", :string, :limit => 30, :default => "", :null => false
  178. t.column "lastname", :string, :limit => 30, :default => "", :null => false
  179. t.column "mail", :string, :limit => 60, :default => "", :null => false
  180. t.column "mail_notification", :boolean, :default => true, :null => false
  181. t.column "admin", :boolean, :default => false, :null => false
  182. t.column "status", :integer, :default => 1, :null => false
  183. t.column "last_login_on", :datetime
  184. t.column "language", :string, :limit => 2, :default => ""
  185. t.column "auth_source_id", :integer
  186. t.column "created_on", :timestamp
  187. t.column "updated_on", :timestamp
  188. end
  189. create_table "versions", :force => true do |t|
  190. t.column "project_id", :integer, :default => 0, :null => false
  191. t.column "name", :string, :limit => 30, :default => "", :null => false
  192. t.column "description", :string, :default => ""
  193. t.column "effective_date", :date
  194. t.column "created_on", :timestamp
  195. t.column "updated_on", :timestamp
  196. end
  197. add_index "versions", ["project_id"], :name => "versions_project_id"
  198. create_table "workflows", :force => true do |t|
  199. t.column "tracker_id", :integer, :default => 0, :null => false
  200. t.column "old_status_id", :integer, :default => 0, :null => false
  201. t.column "new_status_id", :integer, :default => 0, :null => false
  202. t.column "role_id", :integer, :default => 0, :null => false
  203. end
  204. # project
  205. Permission.create :controller => "projects", :action => "show", :description => "label_overview", :sort => 100, :is_public => true
  206. Permission.create :controller => "projects", :action => "changelog", :description => "label_change_log", :sort => 105, :is_public => true
  207. Permission.create :controller => "reports", :action => "issue_report", :description => "label_report_plural", :sort => 110, :is_public => true
  208. Permission.create :controller => "projects", :action => "settings", :description => "label_settings", :sort => 150
  209. Permission.create :controller => "projects", :action => "edit", :description => "button_edit", :sort => 151
  210. # members
  211. Permission.create :controller => "projects", :action => "list_members", :description => "button_list", :sort => 200, :is_public => true
  212. Permission.create :controller => "projects", :action => "add_member", :description => "button_add", :sort => 220
  213. Permission.create :controller => "members", :action => "edit", :description => "button_edit", :sort => 221
  214. Permission.create :controller => "members", :action => "destroy", :description => "button_delete", :sort => 222
  215. # versions
  216. Permission.create :controller => "projects", :action => "add_version", :description => "button_add", :sort => 320
  217. Permission.create :controller => "versions", :action => "edit", :description => "button_edit", :sort => 321
  218. Permission.create :controller => "versions", :action => "destroy", :description => "button_delete", :sort => 322
  219. # issue categories
  220. Permission.create :controller => "projects", :action => "add_issue_category", :description => "button_add", :sort => 420
  221. Permission.create :controller => "issue_categories", :action => "edit", :description => "button_edit", :sort => 421
  222. Permission.create :controller => "issue_categories", :action => "destroy", :description => "button_delete", :sort => 422
  223. # issues
  224. Permission.create :controller => "projects", :action => "list_issues", :description => "button_list", :sort => 1000, :is_public => true
  225. Permission.create :controller => "projects", :action => "export_issues_csv", :description => "label_export_csv", :sort => 1001, :is_public => true
  226. Permission.create :controller => "issues", :action => "show", :description => "button_view", :sort => 1005, :is_public => true
  227. Permission.create :controller => "issues", :action => "download", :description => "button_download", :sort => 1010, :is_public => true
  228. Permission.create :controller => "projects", :action => "add_issue", :description => "button_add", :sort => 1050, :mail_option => 1, :mail_enabled => 1
  229. Permission.create :controller => "issues", :action => "edit", :description => "button_edit", :sort => 1055
  230. Permission.create :controller => "issues", :action => "change_status", :description => "label_change_status", :sort => 1060, :mail_option => 1, :mail_enabled => 1
  231. Permission.create :controller => "issues", :action => "destroy", :description => "button_delete", :sort => 1065
  232. Permission.create :controller => "issues", :action => "add_attachment", :description => "label_attachment_new", :sort => 1070
  233. Permission.create :controller => "issues", :action => "destroy_attachment", :description => "label_attachment_delete", :sort => 1075
  234. # news
  235. Permission.create :controller => "projects", :action => "list_news", :description => "button_list", :sort => 1100, :is_public => true
  236. Permission.create :controller => "news", :action => "show", :description => "button_view", :sort => 1101, :is_public => true
  237. Permission.create :controller => "projects", :action => "add_news", :description => "button_add", :sort => 1120
  238. Permission.create :controller => "news", :action => "edit", :description => "button_edit", :sort => 1121
  239. Permission.create :controller => "news", :action => "destroy", :description => "button_delete", :sort => 1122
  240. # documents
  241. Permission.create :controller => "projects", :action => "list_documents", :description => "button_list", :sort => 1200, :is_public => true
  242. Permission.create :controller => "documents", :action => "show", :description => "button_view", :sort => 1201, :is_public => true
  243. Permission.create :controller => "documents", :action => "download", :description => "button_download", :sort => 1202, :is_public => true
  244. Permission.create :controller => "projects", :action => "add_document", :description => "button_add", :sort => 1220
  245. Permission.create :controller => "documents", :action => "edit", :description => "button_edit", :sort => 1221
  246. Permission.create :controller => "documents", :action => "destroy", :description => "button_delete", :sort => 1222
  247. Permission.create :controller => "documents", :action => "add_attachment", :description => "label_attachment_new", :sort => 1223
  248. Permission.create :controller => "documents", :action => "destroy_attachment", :description => "label_attachment_delete", :sort => 1224
  249. # files
  250. Permission.create :controller => "projects", :action => "list_files", :description => "button_list", :sort => 1300, :is_public => true
  251. Permission.create :controller => "versions", :action => "download", :description => "button_download", :sort => 1301, :is_public => true
  252. Permission.create :controller => "projects", :action => "add_file", :description => "button_add", :sort => 1320
  253. Permission.create :controller => "versions", :action => "destroy_file", :description => "button_delete", :sort => 1322
  254. # create default administrator account
  255. user = User.new :firstname => "Redmine",
  256. :lastname => "Admin",
  257. :mail => "admin@example.net",
  258. :mail_notification => true,
  259. :status => 1
  260. user.login = 'admin'
  261. user.hashed_password = "d033e22ae348aeb5660fc2140aec35850c4da997"
  262. user.admin = true
  263. user.save
  264. end
  265. def self.down
  266. drop_table :attachments
  267. drop_table :auth_sources
  268. drop_table :custom_fields
  269. drop_table :custom_fields_projects
  270. drop_table :custom_fields_trackers
  271. drop_table :custom_values
  272. drop_table :documents
  273. drop_table :enumerations
  274. drop_table :issue_categories
  275. drop_table :issue_histories
  276. drop_table :issue_statuses
  277. drop_table :issues
  278. drop_table :members
  279. drop_table :news
  280. drop_table :permissions
  281. drop_table :permissions_roles
  282. drop_table :projects
  283. drop_table :roles
  284. drop_table :trackers
  285. drop_table :tokens
  286. drop_table :users
  287. drop_table :versions
  288. drop_table :workflows
  289. end
  290. end