[phase-21]Make it possible to migrate from previous version of glossary plugin
This commit is contained in:
parent
e8658550a3
commit
c30fdae698
@ -1,6 +1,7 @@
|
|||||||
class GlossaryTerm < ActiveRecord::Base
|
class GlossaryTerm < ActiveRecord::Base
|
||||||
belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id'
|
belongs_to :category, class_name: 'GlossaryCategory', foreign_key: 'category_id'
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
belongs_to :author, class_name: 'User', foreign_key: 'author_id'
|
||||||
|
|
||||||
# class method from Redmine::Acts::Attachable::ClassMethods
|
# class method from Redmine::Acts::Attachable::ClassMethods
|
||||||
acts_as_attachable view_permission: :view_glossary, edit_permission: :manage_glossary, delete_permission: :manage_glossary
|
acts_as_attachable view_permission: :view_glossary, edit_permission: :manage_glossary, delete_permission: :manage_glossary
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
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
|
|
34
db/migrate/001_create_terms.rb
Normal file
34
db/migrate/001_create_terms.rb
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
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
|
@ -1,7 +0,0 @@
|
|||||||
class CreateGlossaryCategories < ActiveRecord::Migration[5.1]
|
|
||||||
def change
|
|
||||||
create_table :glossary_categories do |t|
|
|
||||||
t.string :name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
24
db/migrate/002_create_glossary_styles.rb
Normal file
24
db/migrate/002_create_glossary_styles.rb
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
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
|
@ -1,5 +0,0 @@
|
|||||||
class AddCategoryToGlossaryTerms < ActiveRecord::Migration[5.1]
|
|
||||||
def change
|
|
||||||
add_reference :glossary_terms, :category, foreign_key: true
|
|
||||||
end
|
|
||||||
end
|
|
14
db/migrate/003_terms_add_columns.rb
Normal file
14
db/migrate/003_terms_add_columns.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
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
|
@ -1,6 +0,0 @@
|
|||||||
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
|
|
10
db/migrate/004_rename_glossary_terms_from_terms.rb
Normal file
10
db/migrate/004_rename_glossary_terms_from_terms.rb
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
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
|
@ -1,9 +0,0 @@
|
|||||||
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
|
|
@ -0,0 +1,5 @@
|
|||||||
|
class RenameGlossaryCategoriesFromTermCategories < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
rename_table :term_categories, :glossary_categories
|
||||||
|
end
|
||||||
|
end
|
@ -1,6 +0,0 @@
|
|||||||
class AddPositionToGlossaryCategories < ActiveRecord::Migration[5.2]
|
|
||||||
|
|
||||||
def change
|
|
||||||
add_column :glossary_categories, :position, :integer, default: nil
|
|
||||||
end
|
|
||||||
end
|
|
@ -0,0 +1,5 @@
|
|||||||
|
class RenameGlossaryViewSettingsFromGlossaryStyles < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
rename_table :glossary_styles, :glossary_view_settings
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user