Chris@1295: # Redmine - project management software Chris@0: # Copyright (C) 2006 Jean-Philippe Lang Chris@0: # Chris@0: # This program is free software; you can redistribute it and/or Chris@0: # modify it under the terms of the GNU General Public License Chris@0: # as published by the Free Software Foundation; either version 2 Chris@0: # of the License, or (at your option) any later version. Chris@909: # Chris@0: # This program is distributed in the hope that it will be useful, Chris@0: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@0: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@0: # GNU General Public License for more details. Chris@909: # Chris@0: # You should have received a copy of the GNU General Public License Chris@0: # along with this program; if not, write to the Free Software Chris@0: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@0: Chris@0: class Setup < ActiveRecord::Migration Chris@909: Chris@0: class User < ActiveRecord::Base; end Chris@0: # model removed Chris@0: class Permission < ActiveRecord::Base; end Chris@909: Chris@909: def self.up Chris@909: create_table "attachments", :force => true do |t| Chris@909: t.column "container_id", :integer, :default => 0, :null => false Chris@909: t.column "container_type", :string, :limit => 30, :default => "", :null => false Chris@909: t.column "filename", :string, :default => "", :null => false Chris@909: t.column "disk_filename", :string, :default => "", :null => false Chris@909: t.column "filesize", :integer, :default => 0, :null => false Chris@909: t.column "content_type", :string, :limit => 60, :default => "" Chris@909: t.column "digest", :string, :limit => 40, :default => "", :null => false Chris@909: t.column "downloads", :integer, :default => 0, :null => false Chris@909: t.column "author_id", :integer, :default => 0, :null => false Chris@909: t.column "created_on", :timestamp Chris@909: end Chris@0: Chris@0: create_table "auth_sources", :force => true do |t| Chris@0: t.column "type", :string, :limit => 30, :default => "", :null => false Chris@0: t.column "name", :string, :limit => 60, :default => "", :null => false Chris@0: t.column "host", :string, :limit => 60 Chris@0: t.column "port", :integer Chris@0: t.column "account", :string, :limit => 60 Chris@0: t.column "account_password", :string, :limit => 60 Chris@0: t.column "base_dn", :string, :limit => 255 Chris@0: t.column "attr_login", :string, :limit => 30 Chris@0: t.column "attr_firstname", :string, :limit => 30 Chris@0: t.column "attr_lastname", :string, :limit => 30 Chris@0: t.column "attr_mail", :string, :limit => 30 Chris@0: t.column "onthefly_register", :boolean, :default => false, :null => false Chris@0: end Chris@909: Chris@0: create_table "custom_fields", :force => true do |t| Chris@909: t.column "type", :string, :limit => 30, :default => "", :null => false Chris@909: t.column "name", :string, :limit => 30, :default => "", :null => false Chris@909: t.column "field_format", :string, :limit => 30, :default => "", :null => false Chris@909: t.column "possible_values", :text Chris@909: t.column "regexp", :string, :default => "" Chris@909: t.column "min_length", :integer, :default => 0, :null => false Chris@909: t.column "max_length", :integer, :default => 0, :null => false Chris@0: t.column "is_required", :boolean, :default => false, :null => false Chris@0: t.column "is_for_all", :boolean, :default => false, :null => false Chris@909: end Chris@909: Chris@909: create_table "custom_fields_projects", :id => false, :force => true do |t| Chris@909: t.column "custom_field_id", :integer, :default => 0, :null => false Chris@909: t.column "project_id", :integer, :default => 0, :null => false Chris@909: end Chris@0: Chris@0: create_table "custom_fields_trackers", :id => false, :force => true do |t| Chris@0: t.column "custom_field_id", :integer, :default => 0, :null => false Chris@0: t.column "tracker_id", :integer, :default => 0, :null => false Chris@0: end Chris@909: Chris@909: create_table "custom_values", :force => true do |t| Chris@0: t.column "customized_type", :string, :limit => 30, :default => "", :null => false Chris@0: t.column "customized_id", :integer, :default => 0, :null => false Chris@909: t.column "custom_field_id", :integer, :default => 0, :null => false Chris@909: t.column "value", :text Chris@0: end Chris@909: Chris@909: create_table "documents", :force => true do |t| Chris@909: t.column "project_id", :integer, :default => 0, :null => false Chris@909: t.column "category_id", :integer, :default => 0, :null => false Chris@909: t.column "title", :string, :limit => 60, :default => "", :null => false Chris@909: t.column "description", :text Chris@909: t.column "created_on", :timestamp Chris@0: end Chris@909: Chris@909: add_index "documents", ["project_id"], :name => "documents_project_id" Chris@909: Chris@909: create_table "enumerations", :force => true do |t| Chris@909: t.column "opt", :string, :limit => 4, :default => "", :null => false Chris@909: t.column "name", :string, :limit => 30, :default => "", :null => false Chris@909: end Chris@909: Chris@909: create_table "issue_categories", :force => true do |t| Chris@909: t.column "project_id", :integer, :default => 0, :null => false Chris@909: t.column "name", :string, :limit => 30, :default => "", :null => false Chris@909: end Chris@909: Chris@909: add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" Chris@909: Chris@909: create_table "issue_histories", :force => true do |t| Chris@909: t.column "issue_id", :integer, :default => 0, :null => false Chris@909: t.column "status_id", :integer, :default => 0, :null => false Chris@909: t.column "author_id", :integer, :default => 0, :null => false Chris@909: t.column "notes", :text Chris@909: t.column "created_on", :timestamp Chris@909: end Chris@909: Chris@909: add_index "issue_histories", ["issue_id"], :name => "issue_histories_issue_id" Chris@909: Chris@909: create_table "issue_statuses", :force => true do |t| Chris@909: t.column "name", :string, :limit => 30, :default => "", :null => false Chris@909: t.column "is_closed", :boolean, :default => false, :null => false Chris@909: t.column "is_default", :boolean, :default => false, :null => false Chris@909: t.column "html_color", :string, :limit => 6, :default => "FFFFFF", :null => false Chris@909: end Chris@909: Chris@909: create_table "issues", :force => true do |t| Chris@909: t.column "tracker_id", :integer, :default => 0, :null => false Chris@909: t.column "project_id", :integer, :default => 0, :null => false Chris@909: t.column "subject", :string, :default => "", :null => false Chris@0: t.column "description", :text Chris@909: t.column "due_date", :date Chris@909: t.column "category_id", :integer Chris@909: t.column "status_id", :integer, :default => 0, :null => false Chris@909: t.column "assigned_to_id", :integer Chris@909: t.column "priority_id", :integer, :default => 0, :null => false Chris@909: t.column "fixed_version_id", :integer Chris@0: t.column "author_id", :integer, :default => 0, :null => false Chris@909: t.column "lock_version", :integer, :default => 0, :null => false Chris@909: t.column "created_on", :timestamp Chris@909: t.column "updated_on", :timestamp Chris@0: end Chris@909: Chris@909: add_index "issues", ["project_id"], :name => "issues_project_id" Chris@909: Chris@909: create_table "members", :force => true do |t| Chris@909: t.column "user_id", :integer, :default => 0, :null => false Chris@909: t.column "project_id", :integer, :default => 0, :null => false Chris@909: t.column "role_id", :integer, :default => 0, :null => false Chris@909: t.column "created_on", :timestamp Chris@909: end Chris@909: Chris@909: create_table "news", :force => true do |t| Chris@909: t.column "project_id", :integer Chris@909: t.column "title", :string, :limit => 60, :default => "", :null => false Chris@909: t.column "summary", :string, :limit => 255, :default => "" Chris@909: t.column "description", :text Chris@909: t.column "author_id", :integer, :default => 0, :null => false Chris@909: t.column "created_on", :timestamp Chris@909: end Chris@909: Chris@909: add_index "news", ["project_id"], :name => "news_project_id" Chris@909: Chris@909: create_table "permissions", :force => true do |t| Chris@909: t.column "controller", :string, :limit => 30, :default => "", :null => false Chris@909: t.column "action", :string, :limit => 30, :default => "", :null => false Chris@909: t.column "description", :string, :limit => 60, :default => "", :null => false Chris@909: t.column "is_public", :boolean, :default => false, :null => false Chris@909: t.column "sort", :integer, :default => 0, :null => false Chris@909: t.column "mail_option", :boolean, :default => false, :null => false Chris@909: t.column "mail_enabled", :boolean, :default => false, :null => false Chris@909: end Chris@909: Chris@909: create_table "permissions_roles", :id => false, :force => true do |t| Chris@909: t.column "permission_id", :integer, :default => 0, :null => false Chris@909: t.column "role_id", :integer, :default => 0, :null => false Chris@909: end Chris@909: Chris@909: add_index "permissions_roles", ["role_id"], :name => "permissions_roles_role_id" Chris@909: Chris@909: create_table "projects", :force => true do |t| Chris@909: t.column "name", :string, :limit => 30, :default => "", :null => false Chris@909: t.column "description", :string, :default => "", :null => false Chris@909: t.column "homepage", :string, :limit => 60, :default => "" Chris@0: t.column "is_public", :boolean, :default => true, :null => false Chris@0: t.column "parent_id", :integer Chris@909: t.column "projects_count", :integer, :default => 0 Chris@909: t.column "created_on", :timestamp Chris@909: t.column "updated_on", :timestamp Chris@909: end Chris@909: Chris@909: create_table "roles", :force => true do |t| Chris@909: t.column "name", :string, :limit => 30, :default => "", :null => false Chris@909: end Chris@0: Chris@0: create_table "tokens", :force => true do |t| Chris@0: t.column "user_id", :integer, :default => 0, :null => false Chris@0: t.column "action", :string, :limit => 30, :default => "", :null => false Chris@0: t.column "value", :string, :limit => 40, :default => "", :null => false Chris@0: t.column "created_on", :datetime, :null => false Chris@0: end Chris@909: Chris@909: create_table "trackers", :force => true do |t| Chris@909: t.column "name", :string, :limit => 30, :default => "", :null => false Chris@909: t.column "is_in_chlog", :boolean, :default => false, :null => false Chris@909: end Chris@909: Chris@909: create_table "users", :force => true do |t| Chris@909: t.column "login", :string, :limit => 30, :default => "", :null => false Chris@909: t.column "hashed_password", :string, :limit => 40, :default => "", :null => false Chris@909: t.column "firstname", :string, :limit => 30, :default => "", :null => false Chris@909: t.column "lastname", :string, :limit => 30, :default => "", :null => false Chris@909: t.column "mail", :string, :limit => 60, :default => "", :null => false Chris@909: t.column "mail_notification", :boolean, :default => true, :null => false Chris@909: t.column "admin", :boolean, :default => false, :null => false Chris@909: t.column "status", :integer, :default => 1, :null => false Chris@909: t.column "last_login_on", :datetime Chris@0: t.column "language", :string, :limit => 2, :default => "" Chris@909: t.column "auth_source_id", :integer Chris@909: t.column "created_on", :timestamp Chris@909: t.column "updated_on", :timestamp Chris@0: end Chris@909: Chris@909: create_table "versions", :force => true do |t| Chris@909: t.column "project_id", :integer, :default => 0, :null => false Chris@909: t.column "name", :string, :limit => 30, :default => "", :null => false Chris@909: t.column "description", :string, :default => "" Chris@909: t.column "effective_date", :date Chris@909: t.column "created_on", :timestamp Chris@909: t.column "updated_on", :timestamp Chris@909: end Chris@909: Chris@909: add_index "versions", ["project_id"], :name => "versions_project_id" Chris@909: Chris@909: create_table "workflows", :force => true do |t| Chris@909: t.column "tracker_id", :integer, :default => 0, :null => false Chris@909: t.column "old_status_id", :integer, :default => 0, :null => false Chris@909: t.column "new_status_id", :integer, :default => 0, :null => false Chris@909: t.column "role_id", :integer, :default => 0, :null => false Chris@909: end Chris@909: Chris@909: # project Chris@909: Permission.create :controller => "projects", :action => "show", :description => "label_overview", :sort => 100, :is_public => true Chris@909: Permission.create :controller => "projects", :action => "changelog", :description => "label_change_log", :sort => 105, :is_public => true Chris@909: Permission.create :controller => "reports", :action => "issue_report", :description => "label_report_plural", :sort => 110, :is_public => true Chris@909: Permission.create :controller => "projects", :action => "settings", :description => "label_settings", :sort => 150 Chris@909: Permission.create :controller => "projects", :action => "edit", :description => "button_edit", :sort => 151 Chris@909: # members Chris@909: Permission.create :controller => "projects", :action => "list_members", :description => "button_list", :sort => 200, :is_public => true Chris@909: Permission.create :controller => "projects", :action => "add_member", :description => "button_add", :sort => 220 Chris@909: Permission.create :controller => "members", :action => "edit", :description => "button_edit", :sort => 221 Chris@909: Permission.create :controller => "members", :action => "destroy", :description => "button_delete", :sort => 222 Chris@909: # versions Chris@909: Permission.create :controller => "projects", :action => "add_version", :description => "button_add", :sort => 320 Chris@909: Permission.create :controller => "versions", :action => "edit", :description => "button_edit", :sort => 321 Chris@909: Permission.create :controller => "versions", :action => "destroy", :description => "button_delete", :sort => 322 Chris@909: # issue categories Chris@909: Permission.create :controller => "projects", :action => "add_issue_category", :description => "button_add", :sort => 420 Chris@909: Permission.create :controller => "issue_categories", :action => "edit", :description => "button_edit", :sort => 421 Chris@909: Permission.create :controller => "issue_categories", :action => "destroy", :description => "button_delete", :sort => 422 Chris@909: # issues Chris@909: Permission.create :controller => "projects", :action => "list_issues", :description => "button_list", :sort => 1000, :is_public => true Chris@0: Permission.create :controller => "projects", :action => "export_issues_csv", :description => "label_export_csv", :sort => 1001, :is_public => true Chris@909: Permission.create :controller => "issues", :action => "show", :description => "button_view", :sort => 1005, :is_public => true Chris@909: Permission.create :controller => "issues", :action => "download", :description => "button_download", :sort => 1010, :is_public => true Chris@909: Permission.create :controller => "projects", :action => "add_issue", :description => "button_add", :sort => 1050, :mail_option => 1, :mail_enabled => 1 Chris@909: Permission.create :controller => "issues", :action => "edit", :description => "button_edit", :sort => 1055 Chris@909: Permission.create :controller => "issues", :action => "change_status", :description => "label_change_status", :sort => 1060, :mail_option => 1, :mail_enabled => 1 Chris@909: Permission.create :controller => "issues", :action => "destroy", :description => "button_delete", :sort => 1065 Chris@909: Permission.create :controller => "issues", :action => "add_attachment", :description => "label_attachment_new", :sort => 1070 Chris@909: Permission.create :controller => "issues", :action => "destroy_attachment", :description => "label_attachment_delete", :sort => 1075 Chris@909: # news Chris@909: Permission.create :controller => "projects", :action => "list_news", :description => "button_list", :sort => 1100, :is_public => true Chris@909: Permission.create :controller => "news", :action => "show", :description => "button_view", :sort => 1101, :is_public => true Chris@909: Permission.create :controller => "projects", :action => "add_news", :description => "button_add", :sort => 1120 Chris@909: Permission.create :controller => "news", :action => "edit", :description => "button_edit", :sort => 1121 Chris@909: Permission.create :controller => "news", :action => "destroy", :description => "button_delete", :sort => 1122 Chris@0: # documents Chris@909: Permission.create :controller => "projects", :action => "list_documents", :description => "button_list", :sort => 1200, :is_public => true Chris@909: Permission.create :controller => "documents", :action => "show", :description => "button_view", :sort => 1201, :is_public => true Chris@909: Permission.create :controller => "documents", :action => "download", :description => "button_download", :sort => 1202, :is_public => true Chris@909: Permission.create :controller => "projects", :action => "add_document", :description => "button_add", :sort => 1220 Chris@909: Permission.create :controller => "documents", :action => "edit", :description => "button_edit", :sort => 1221 Chris@909: Permission.create :controller => "documents", :action => "destroy", :description => "button_delete", :sort => 1222 Chris@909: Permission.create :controller => "documents", :action => "add_attachment", :description => "label_attachment_new", :sort => 1223 Chris@909: Permission.create :controller => "documents", :action => "destroy_attachment", :description => "label_attachment_delete", :sort => 1224 Chris@909: # files Chris@909: Permission.create :controller => "projects", :action => "list_files", :description => "button_list", :sort => 1300, :is_public => true Chris@909: Permission.create :controller => "versions", :action => "download", :description => "button_download", :sort => 1301, :is_public => true Chris@909: Permission.create :controller => "projects", :action => "add_file", :description => "button_add", :sort => 1320 Chris@909: Permission.create :controller => "versions", :action => "destroy_file", :description => "button_delete", :sort => 1322 Chris@909: Chris@909: # create default administrator account Chris@0: user = User.create :login => "admin", Chris@0: :hashed_password => "d033e22ae348aeb5660fc2140aec35850c4da997", Chris@0: :admin => true, Chris@0: :firstname => "Redmine", Chris@0: :lastname => "Admin", Chris@0: :mail => "admin@example.net", Chris@0: :mail_notification => true, Chris@0: :status => 1 Chris@0: end Chris@0: Chris@909: def self.down Chris@0: drop_table :attachments Chris@909: drop_table :auth_sources Chris@909: drop_table :custom_fields Chris@0: drop_table :custom_fields_projects Chris@909: drop_table :custom_fields_trackers Chris@909: drop_table :custom_values Chris@909: drop_table :documents Chris@909: drop_table :enumerations Chris@909: drop_table :issue_categories Chris@909: drop_table :issue_histories Chris@909: drop_table :issue_statuses Chris@909: drop_table :issues Chris@909: drop_table :members Chris@909: drop_table :news Chris@909: drop_table :permissions Chris@909: drop_table :permissions_roles Chris@909: drop_table :projects Chris@909: drop_table :roles Chris@909: drop_table :trackers Chris@0: drop_table :tokens Chris@909: drop_table :users Chris@909: drop_table :versions Chris@0: drop_table :workflows Chris@0: end Chris@0: end