diff options
| author | Michel Etienne | 2014-07-23 10:38:39 +0200 |
|---|---|---|
| committer | Michel Etienne | 2014-07-23 10:38:39 +0200 |
| commit | 98c377c231abd19343a6163c396b4489fca14ef2 (patch) | |
| tree | cf00ac71cfb92a89c8acde8d306956a80846824e /db | |
| parent | 08c0bce019481d54f07d67de79061b791dc51a9d (diff) | |
| download | chouette-core-98c377c231abd19343a6163c396b4489fca14ef2.tar.bz2 | |
manage tags on time_table , Mantis 26833
Diffstat (limited to 'db')
5 files changed, 101 insertions, 1 deletions
diff --git a/db/migrate/20140721080943_acts_as_taggable_on_migration.ninoxe_engine.rb b/db/migrate/20140721080943_acts_as_taggable_on_migration.ninoxe_engine.rb new file mode 100644 index 000000000..cf116560a --- /dev/null +++ b/db/migrate/20140721080943_acts_as_taggable_on_migration.ninoxe_engine.rb @@ -0,0 +1,32 @@ +# This migration comes from ninoxe_engine (originally 20140718141703) +# This migration comes from acts_as_taggable_on_engine (originally 1) +class ActsAsTaggableOnMigration < ActiveRecord::Migration + def self.up + create_table :tags do |t| + t.string :name + end + + create_table :taggings do |t| + t.references :tag + + # You should make sure that the column created is + # long enough to store the required class names. + t.references :taggable, polymorphic: true + t.references :tagger, polymorphic: true + + # Limit is created to prevent MySQL error on index + # length for MyISAM table type: http://bit.ly/vgW2Ql + t.string :context, limit: 128 + + t.datetime :created_at + end + + add_index :taggings, :tag_id + add_index :taggings, [:taggable_id, :taggable_type, :context] + end + + def self.down + drop_table :taggings + drop_table :tags + end +end diff --git a/db/migrate/20140721080944_add_missing_unique_indices.ninoxe_engine.rb b/db/migrate/20140721080944_add_missing_unique_indices.ninoxe_engine.rb new file mode 100644 index 000000000..f85bb4c75 --- /dev/null +++ b/db/migrate/20140721080944_add_missing_unique_indices.ninoxe_engine.rb @@ -0,0 +1,21 @@ +# This migration comes from ninoxe_engine (originally 20140718141704) +# This migration comes from acts_as_taggable_on_engine (originally 2) +class AddMissingUniqueIndices < ActiveRecord::Migration + def self.up + add_index :tags, :name, unique: true + + remove_index :taggings, :tag_id + remove_index :taggings, [:taggable_id, :taggable_type, :context] + add_index :taggings, + [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type], + unique: true, name: 'taggings_idx' + end + + def self.down + remove_index :tags, :name + + remove_index :taggings, name: 'taggings_idx' + add_index :taggings, :tag_id + add_index :taggings, [:taggable_id, :taggable_type, :context] + end +end diff --git a/db/migrate/20140721080945_add_taggings_counter_cache_to_tags.ninoxe_engine.rb b/db/migrate/20140721080945_add_taggings_counter_cache_to_tags.ninoxe_engine.rb new file mode 100644 index 000000000..27d7e4d1e --- /dev/null +++ b/db/migrate/20140721080945_add_taggings_counter_cache_to_tags.ninoxe_engine.rb @@ -0,0 +1,16 @@ +# This migration comes from ninoxe_engine (originally 20140718141705) +# This migration comes from acts_as_taggable_on_engine (originally 3) +class AddTaggingsCounterCacheToTags < ActiveRecord::Migration + def self.up + add_column :tags, :taggings_count, :integer, default: 0 + + ActsAsTaggableOn::Tag.reset_column_information + ActsAsTaggableOn::Tag.find_each do |tag| + ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings) + end + end + + def self.down + remove_column :tags, :taggings_count + end +end diff --git a/db/migrate/20140721080946_add_missing_taggable_index.ninoxe_engine.rb b/db/migrate/20140721080946_add_missing_taggable_index.ninoxe_engine.rb new file mode 100644 index 000000000..6aba71e6f --- /dev/null +++ b/db/migrate/20140721080946_add_missing_taggable_index.ninoxe_engine.rb @@ -0,0 +1,11 @@ +# This migration comes from ninoxe_engine (originally 20140718141706) +# This migration comes from acts_as_taggable_on_engine (originally 4) +class AddMissingTaggableIndex < ActiveRecord::Migration + def self.up + add_index :taggings, [:taggable_id, :taggable_type, :context] + end + + def self.down + remove_index :taggings, [:taggable_id, :taggable_type, :context] + end +end diff --git a/db/schema.rb b/db/schema.rb index 343ccdceb..be5e89c97 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140626081658) do +ActiveRecord::Schema.define(:version => 20140721080946) do create_table "access_links", :force => true do |t| t.integer "access_point_id", :limit => 8 @@ -412,6 +412,26 @@ ActiveRecord::Schema.define(:version => 20140626081658) do add_index "stop_points", ["objectid"], :name => "stop_points_objectid_key", :unique => true + create_table "taggings", :force => true do |t| + t.integer "tag_id" + t.integer "taggable_id" + t.string "taggable_type" + t.integer "tagger_id" + t.string "tagger_type" + t.string "context", :limit => 128 + t.datetime "created_at" + end + + add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], :name => "taggings_idx", :unique => true + add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" + + create_table "tags", :force => true do |t| + t.string "name" + t.integer "taggings_count", :default => 0 + end + + add_index "tags", ["name"], :name => "index_tags_on_name", :unique => true + create_table "time_slots", :force => true do |t| t.string "objectid", :null => false t.integer "object_version" |
