リビジョン c30fdae6
| app/models/glossary_term.rb | ||
|---|---|---|
|
class GlossaryTerm < ActiveRecord::Base
|
||
|
belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id'
|
||
|
belongs_to :project
|
||
|
belongs_to :author, class_name: 'User', foreign_key: 'author_id'
|
||
|
|
||
|
# class method from Redmine::Acts::Attachable::ClassMethods
|
||
|
acts_as_attachable view_permission: :view_glossary, edit_permission: :manage_glossary, delete_permission: :manage_glossary
|
||
| db/migrate/001_create_glossary_terms.rb | ||
|---|---|---|
|
class CreateGlossaryTerms < ActiveRecord::Migration[5.1]
|
||
|
def change
|
||
|
create_table :glossary_terms do |t|
|
||
|
t.string :name, null: false
|
||
|
t.text :description
|
||
|
|
||
|
t.timestamps null: false
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| db/migrate/001_create_terms.rb | ||
|---|---|---|
|
class CreateTerms < ActiveRecord::Migration[4.2]
|
||
|
def self.up
|
||
|
# CreateTermCategories
|
||
|
create_table :term_categories, :force => true do |t|
|
||
|
t.column :project_id, :integer, :default => 0, :null => false
|
||
|
t.column :name, :string, :default => '', :null => false
|
||
|
t.column :position, :integer, :default => 1
|
||
|
end
|
||
|
|
||
|
add_index "term_categories", ["project_id"], :name => "categories_project_id"
|
||
|
|
||
|
create_table :terms, :force => true do |t|
|
||
|
t.column :project_id, :integer, :default => 0, :null => false
|
||
|
t.column :category_id, :integer
|
||
|
t.column :author_id, :integer, :default => 0, :null => false
|
||
|
t.column :updater_id, :integer
|
||
|
t.column :name, :string, :default => '', :null => false
|
||
|
t.column :name_en, :string, :default => ''
|
||
|
t.column :datatype, :string, :default => ''
|
||
|
t.column :codename, :string, :default => ''
|
||
|
t.column :description, :text
|
||
|
t.column :created_on, :timestamp
|
||
|
t.column :updated_on, :timestamp
|
||
|
end
|
||
|
|
||
|
add_index "terms", ["project_id"], :name => "terms_project_id"
|
||
|
|
||
|
end
|
||
|
|
||
|
def self.down
|
||
|
drop_table :term_categories
|
||
|
drop_table :terms
|
||
|
end
|
||
|
end
|
||
| db/migrate/002_create_glossary_categories.rb | ||
|---|---|---|
|
class CreateGlossaryCategories < ActiveRecord::Migration[5.1]
|
||
|
def change
|
||
|
create_table :glossary_categories do |t|
|
||
|
t.string :name
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| db/migrate/002_create_glossary_styles.rb | ||
|---|---|---|
|
class CreateGlossaryStyles < ActiveRecord::Migration[4.2]
|
||
|
def self.up
|
||
|
create_table :glossary_styles do |t|
|
||
|
t.column :show_desc, :boolean, :default => false
|
||
|
t.column :groupby, :integer, :default => 1
|
||
|
t.column :project_scope, :integer, :default => 0
|
||
|
t.column :sort_item_0, :string, :default => ''
|
||
|
t.column :sort_item_1, :string, :default => ''
|
||
|
t.column :sort_item_2, :string, :default => ''
|
||
|
t.column :user_id, :integer, :default => 0
|
||
|
end
|
||
|
|
||
|
add_column :terms, :rubi, :string, :default => ''
|
||
|
add_column :terms, :abbr_whole, :string, :default => ''
|
||
|
|
||
|
end
|
||
|
|
||
|
|
||
|
def self.down
|
||
|
drop_table :glossary_styles
|
||
|
remove_column :terms, :abbr_whole
|
||
|
remove_column :terms, :rubi
|
||
|
end
|
||
|
end
|
||
| db/migrate/003_add_category_to_glossary_terms.rb | ||
|---|---|---|
|
class AddCategoryToGlossaryTerms < ActiveRecord::Migration[5.1]
|
||
|
def change
|
||
|
add_reference :glossary_terms, :category, foreign_key: true
|
||
|
end
|
||
|
end
|
||
| db/migrate/003_terms_add_columns.rb | ||
|---|---|---|
|
class TermsAddColumns < ActiveRecord::Migration[4.2]
|
||
|
def self.up
|
||
|
add_column :terms, :tech_en, :string, :default => ''
|
||
|
add_column :terms, :name_cn, :string, :default => ''
|
||
|
add_column :terms, :name_fr, :string, :default => ''
|
||
|
end
|
||
|
|
||
|
|
||
|
def self.down
|
||
|
remove_column :terms, :tech_en
|
||
|
remove_column :terms, :name_cn
|
||
|
remove_column :terms, :name_fr
|
||
|
end
|
||
|
end
|
||
| db/migrate/004_add_project_to_terms_and_categories.rb | ||
|---|---|---|
|
class AddProjectToTermsAndCategories < ActiveRecord::Migration[5.1]
|
||
|
def change
|
||
|
add_reference :glossary_terms, :project, foreign_key: true
|
||
|
add_reference :glossary_categories, :project, foreign_key: true
|
||
|
end
|
||
|
end
|
||
| db/migrate/004_rename_glossary_terms_from_terms.rb | ||
|---|---|---|
|
class RenameGlossaryTermsFromTerms < ActiveRecord::Migration[5.2]
|
||
|
def change
|
||
|
remove_column :terms, :tech_en, :string
|
||
|
remove_column :terms, :name_cn, :string
|
||
|
remove_column :terms, :name_fr, :string
|
||
|
rename_column :terms, :created_on, :created_at
|
||
|
rename_column :terms, :updated_on, :updated_at
|
||
|
rename_table :terms, :glossary_terms
|
||
|
end
|
||
|
end
|
||
| db/migrate/005_add_columns_to_glossary_terms.rb | ||
|---|---|---|
|
class AddColumnsToGlossaryTerms < ActiveRecord::Migration[5.1]
|
||
|
def change
|
||
|
add_column :glossary_terms, :name_en, :string, default: ''
|
||
|
add_column :glossary_terms, :rubi, :string, default: ''
|
||
|
add_column :glossary_terms, :abbr_whole, :string, default: ''
|
||
|
add_column :glossary_terms, :datatype, :string, default: ''
|
||
|
add_column :glossary_terms, :codename, :string, default: ''
|
||
|
end
|
||
|
end
|
||
| db/migrate/005_rename_glossary_categories_from_term_categories.rb | ||
|---|---|---|
|
class RenameGlossaryCategoriesFromTermCategories < ActiveRecord::Migration[5.2]
|
||
|
def change
|
||
|
rename_table :term_categories, :glossary_categories
|
||
|
end
|
||
|
end
|
||
| db/migrate/006_add_position_to_glossary_categories.rb | ||
|---|---|---|
|
class AddPositionToGlossaryCategories < ActiveRecord::Migration[5.2]
|
||
|
|
||
|
def change
|
||
|
add_column :glossary_categories, :position, :integer, default: nil
|
||
|
end
|
||
|
end
|
||
| db/migrate/006_rename_glossary_view_settings_from_glossary_styles.rb | ||
|---|---|---|
|
class RenameGlossaryViewSettingsFromGlossaryStyles < ActiveRecord::Migration[5.2]
|
||
|
def change
|
||
|
rename_table :glossary_styles, :glossary_view_settings
|
||
|
end
|
||
|
end
|
||
[phase-21]Make it possible to migrate from previous version of glossary plugin