Merge remote-tracking branch 'origin/main' into feature/084
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
class CreateTagImplications < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :tag_implications do |t|
|
||||
t.references :tag, null: false, foreign_key: { to_table: :tags }
|
||||
t.references :parent_tag, null: false, foreign_key: { to_table: :tags }
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class RenameIpAdressColumnToIpAddresses < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
rename_column :ip_addresses, :ip_adress, :ip_address
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,27 @@
|
||||
class AddUniqueIndexToTagImplications < ActiveRecord::Migration[8.0]
|
||||
def up
|
||||
execute <<~SQL
|
||||
DELETE
|
||||
ti1
|
||||
FROM
|
||||
tag_implications ti1
|
||||
INNER JOIN
|
||||
tag_implications ti2
|
||||
ON
|
||||
ti1.tag_id = ti2.tag_id
|
||||
AND ti1.parent_tag_id = ti2.parent_tag_id
|
||||
AND ti1.id > ti2.id
|
||||
;
|
||||
SQL
|
||||
|
||||
add_index :tag_implications, [:tag_id, :parent_tag_id],
|
||||
unique: true,
|
||||
name: 'index_tag_implications_on_tag_id_and_parent_tag_id'
|
||||
end
|
||||
|
||||
def down
|
||||
# NOTE: 重複削除は復元されなぃ.
|
||||
remove_index :tag_implications,
|
||||
name: 'index_tag_implications_on_tag_id_and_parent_tag_id'
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user