about summary refs log tree commit diff stats
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20180707142415_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb36
-rw-r--r--db/migrate/20180707142416_add_missing_unique_indices.acts_as_taggable_on_engine.rb26
-rw-r--r--db/migrate/20180707142417_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb20
-rw-r--r--db/migrate/20180707142418_add_missing_taggable_index.acts_as_taggable_on_engine.rb15
-rw-r--r--db/migrate/20180707142419_change_collation_for_tag_names.acts_as_taggable_on_engine.rb15
-rw-r--r--db/migrate/20180707142420_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb23
-rw-r--r--db/schema.rb27
7 files changed, 161 insertions, 1 deletions
diff --git a/db/migrate/20180707142415_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb b/db/migrate/20180707142415_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb new file mode 100644 index 0000000..461eae4 --- /dev/null +++ b/db/migrate/20180707142415_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb
@@ -0,0 +1,36 @@
1# This migration comes from acts_as_taggable_on_engine (originally 1)
2if ActiveRecord.gem_version >= Gem::Version.new('5.0')
3 class ActsAsTaggableOnMigration < ActiveRecord::Migration[4.2]; end
4else
5 class ActsAsTaggableOnMigration < ActiveRecord::Migration; end
6end
7ActsAsTaggableOnMigration.class_eval do
8 def self.up
9 create_table :tags do |t|
10 t.string :name
11 end
12
13 create_table :taggings do |t|
14 t.references :tag
15
16 # You should make sure that the column created is
17 # long enough to store the required class names.
18 t.references :taggable, polymorphic: true
19 t.references :tagger, polymorphic: true
20
21 # Limit is created to prevent MySQL error on index
22 # length for MyISAM table type: http://bit.ly/vgW2Ql
23 t.string :context, limit: 128
24
25 t.datetime :created_at
26 end
27
28 add_index :taggings, :tag_id
29 add_index :taggings, [:taggable_id, :taggable_type, :context]
30 end
31
32 def self.down
33 drop_table :taggings
34 drop_table :tags
35 end
36end
diff --git a/db/migrate/20180707142416_add_missing_unique_indices.acts_as_taggable_on_engine.rb b/db/migrate/20180707142416_add_missing_unique_indices.acts_as_taggable_on_engine.rb new file mode 100644 index 0000000..514ac57 --- /dev/null +++ b/db/migrate/20180707142416_add_missing_unique_indices.acts_as_taggable_on_engine.rb
@@ -0,0 +1,26 @@
1# This migration comes from acts_as_taggable_on_engine (originally 2)
2if ActiveRecord.gem_version >= Gem::Version.new('5.0')
3 class AddMissingUniqueIndices < ActiveRecord::Migration[4.2]; end
4else
5 class AddMissingUniqueIndices < ActiveRecord::Migration; end
6end
7AddMissingUniqueIndices.class_eval do
8 def self.up
9 add_index :tags, :name, unique: true
10
11 remove_index :taggings, :tag_id if index_exists?(:taggings, :tag_id)
12 remove_index :taggings, [:taggable_id, :taggable_type, :context]
13 add_index :taggings,
14 [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
15 unique: true, name: 'taggings_idx'
16 end
17
18 def self.down
19 remove_index :tags, :name
20
21 remove_index :taggings, name: 'taggings_idx'
22
23 add_index :taggings, :tag_id unless index_exists?(:taggings, :tag_id)
24 add_index :taggings, [:taggable_id, :taggable_type, :context]
25 end
26end
diff --git a/db/migrate/20180707142417_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb b/db/migrate/20180707142417_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb new file mode 100644 index 0000000..1d9b556 --- /dev/null +++ b/db/migrate/20180707142417_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb
@@ -0,0 +1,20 @@
1# This migration comes from acts_as_taggable_on_engine (originally 3)
2if ActiveRecord.gem_version >= Gem::Version.new('5.0')
3 class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2]; end
4else
5 class AddTaggingsCounterCacheToTags < ActiveRecord::Migration; end
6end
7AddTaggingsCounterCacheToTags.class_eval do
8 def self.up
9 add_column :tags, :taggings_count, :integer, default: 0
10
11 ActsAsTaggableOn::Tag.reset_column_information
12 ActsAsTaggableOn::Tag.find_each do |tag|
13 ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings)
14 end
15 end
16
17 def self.down
18 remove_column :tags, :taggings_count
19 end
20end
diff --git a/db/migrate/20180707142418_add_missing_taggable_index.acts_as_taggable_on_engine.rb b/db/migrate/20180707142418_add_missing_taggable_index.acts_as_taggable_on_engine.rb new file mode 100644 index 0000000..5f46569 --- /dev/null +++ b/db/migrate/20180707142418_add_missing_taggable_index.acts_as_taggable_on_engine.rb
@@ -0,0 +1,15 @@
1# This migration comes from acts_as_taggable_on_engine (originally 4)
2if ActiveRecord.gem_version >= Gem::Version.new('5.0')
3 class AddMissingTaggableIndex < ActiveRecord::Migration[4.2]; end
4else
5 class AddMissingTaggableIndex < ActiveRecord::Migration; end
6end
7AddMissingTaggableIndex.class_eval do
8 def self.up
9 add_index :taggings, [:taggable_id, :taggable_type, :context]
10 end
11
12 def self.down
13 remove_index :taggings, [:taggable_id, :taggable_type, :context]
14 end
15end
diff --git a/db/migrate/20180707142419_change_collation_for_tag_names.acts_as_taggable_on_engine.rb b/db/migrate/20180707142419_change_collation_for_tag_names.acts_as_taggable_on_engine.rb new file mode 100644 index 0000000..f119b16 --- /dev/null +++ b/db/migrate/20180707142419_change_collation_for_tag_names.acts_as_taggable_on_engine.rb
@@ -0,0 +1,15 @@
1# This migration comes from acts_as_taggable_on_engine (originally 5)
2# This migration is added to circumvent issue #623 and have special characters
3# work properly
4if ActiveRecord.gem_version >= Gem::Version.new('5.0')
5 class ChangeCollationForTagNames < ActiveRecord::Migration[4.2]; end
6else
7 class ChangeCollationForTagNames < ActiveRecord::Migration; end
8end
9ChangeCollationForTagNames.class_eval do
10 def up
11 if ActsAsTaggableOn::Utils.using_mysql?
12 execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")
13 end
14 end
15end
diff --git a/db/migrate/20180707142420_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb b/db/migrate/20180707142420_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb new file mode 100644 index 0000000..94e1f2e --- /dev/null +++ b/db/migrate/20180707142420_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb
@@ -0,0 +1,23 @@
1# This migration comes from acts_as_taggable_on_engine (originally 6)
2if ActiveRecord.gem_version >= Gem::Version.new('5.0')
3 class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end
4else
5 class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end
6end
7AddMissingIndexesOnTaggings.class_eval do
8 def change
9 add_index :taggings, :tag_id unless index_exists? :taggings, :tag_id
10 add_index :taggings, :taggable_id unless index_exists? :taggings, :taggable_id
11 add_index :taggings, :taggable_type unless index_exists? :taggings, :taggable_type
12 add_index :taggings, :tagger_id unless index_exists? :taggings, :tagger_id
13 add_index :taggings, :context unless index_exists? :taggings, :context
14
15 unless index_exists? :taggings, [:tagger_id, :tagger_type]
16 add_index :taggings, [:tagger_id, :tagger_type]
17 end
18
19 unless index_exists? :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
20 add_index :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
21 end
22 end
23end
diff --git a/db/schema.rb b/db/schema.rb index 0279d8e..192c9c1 100644 --- a/db/schema.rb +++ b/db/schema.rb
@@ -10,7 +10,7 @@
10# 10#
11# It's strongly recommended that you check this file into your version control system. 11# It's strongly recommended that you check this file into your version control system.
12 12
13ActiveRecord::Schema.define(version: 20180704144707) do 13ActiveRecord::Schema.define(version: 20180707142420) do
14 14
15 create_table "blogs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t| 15 create_table "blogs", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin" do |t|
16 t.string "title" 16 t.string "title"
@@ -238,6 +238,31 @@ ActiveRecord::Schema.define(version: 20180704144707) do
238 t.datetime "updated_at", null: false 238 t.datetime "updated_at", null: false
239 end 239 end
240 240
241 create_table "taggings", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
242 t.integer "tag_id"
243 t.string "taggable_type"
244 t.integer "taggable_id"
245 t.string "tagger_type"
246 t.integer "tagger_id"
247 t.string "context", limit: 128
248 t.datetime "created_at"
249 t.index ["context"], name: "index_taggings_on_context"
250 t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true
251 t.index ["tag_id"], name: "index_taggings_on_tag_id"
252 t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
253 t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy"
254 t.index ["taggable_id"], name: "index_taggings_on_taggable_id"
255 t.index ["taggable_type"], name: "index_taggings_on_taggable_type"
256 t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type"
257 t.index ["tagger_id"], name: "index_taggings_on_tagger_id"
258 end
259
260 create_table "tags", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
261 t.string "name", limit: 255, collation: "utf8_bin"
262 t.integer "taggings_count", default: 0
263 t.index ["name"], name: "index_tags_on_name", unique: true
264 end
265
241 create_table "updates", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t| 266 create_table "updates", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci" do |t|
242 t.bigint "stream_id" 267 t.bigint "stream_id"
243 t.text "body" 268 t.text "body"