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

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