# HG changeset patch # User luisf # Date 1311877317 -3600 # Node ID 23a9272bf7666435d90de204f3a2736ebbbb95b5 # Parent c3abeb11bc2e38439ae9776680f02b6c1449fd93 Feature #237: migration, new table with BibtexEntry Types and rake task to populate the table. diff -r c3abeb11bc2e -r 23a9272bf766 vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb Thu Jul 28 19:21:57 2011 +0100 @@ -0,0 +1,2 @@ +class BibtexEntryType < ActiveRecord::Base +end diff -r c3abeb11bc2e -r 23a9272bf766 vendor/plugins/redmine_bibliography/db/migrate/004_create_bibtex_entries.rb --- a/vendor/plugins/redmine_bibliography/db/migrate/004_create_bibtex_entries.rb Thu Jul 28 15:04:24 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/db/migrate/004_create_bibtex_entries.rb Thu Jul 28 19:21:57 2011 +0100 @@ -2,7 +2,7 @@ def self.up create_table :bibtex_entries do |t| t.column :publication_id, :integer - t.column :entry_type, :string + t.column :entry_type, :integer t.column :address, :string t.column :annote, :string t.column :booktitle, :string diff -r c3abeb11bc2e -r 23a9272bf766 vendor/plugins/redmine_bibliography/db/migrate/006_create_bibtex_entry_types.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/db/migrate/006_create_bibtex_entry_types.rb Thu Jul 28 19:21:57 2011 +0100 @@ -0,0 +1,13 @@ +class CreateBibtexEntryTypes < ActiveRecord::Migration + def self.up + create_table :bibtex_entry_types do |t| + t.string :name + + t.timestamps + end + end + + def self.down + drop_table :bibtex_entry_types + end +end diff -r c3abeb11bc2e -r 23a9272bf766 vendor/plugins/redmine_bibliography/db/seed_data/bibtex_entry_types_list.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/db/seed_data/bibtex_entry_types_list.txt Thu Jul 28 19:21:57 2011 +0100 @@ -0,0 +1,14 @@ +article|1 +book|2 +booklet|3 +inbook|4 +incollection|5 +conference|6 +inproceedings|7 +manual|8 +masterthesis|9 +misc|10 +phdthesis|11 +proceedings|12 +techreport|13 +unpublished|14 diff -r c3abeb11bc2e -r 23a9272bf766 vendor/plugins/redmine_bibliography/lib/tasks/seed_bibtex_entry_types.rake --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/lib/tasks/seed_bibtex_entry_types.rake Thu Jul 28 19:21:57 2011 +0100 @@ -0,0 +1,21 @@ +namespace :redmine do + namespace :plugins do + namespace :redmine_bibliography do + + task :seed_bibtex_entry_types => :environment do + desc "Seeds the Bibtex Entry Types Table" + + quoted = ActiveRecord::Base.connection.quote_table_name('bibtex_entry_types') + ActiveRecord::Base.connection.execute("TRUNCATE #{quoted}") + + open(File.dirname(__FILE__) + "/../../db/seed_data/bibtex_entry_types_list.txt") do |bibtex_entry_types| + bibtex_entry_types.read.each_line do |bibtex_entry_type| + bibtype=bibtex_entry_type.split('|') + BibtexEntryType.create(:name => bibtype[0].chomp, :id => bibtype[1].chomp) + end + end + end + + end + end +end