Merge remote-tracking branch 'origin/main' into feature/055
このコミットが含まれているのは:
@@ -0,0 +1,53 @@
|
||||
class DeleteInactiveRecordsFromPostTags < ActiveRecord::Migration[8.0]
|
||||
def up
|
||||
execute <<~SQL
|
||||
DELETE
|
||||
FROM
|
||||
post_tags
|
||||
WHERE
|
||||
discarded_at IS NOT NULL
|
||||
SQL
|
||||
|
||||
remove_index :post_tags, [:tag_id, :discarded_at]
|
||||
remove_index :post_tags, [:post_id, :discarded_at]
|
||||
remove_index :post_tags, name: 'idx_post_tags_active_unique'
|
||||
remove_index :post_tags, :discarded_at
|
||||
|
||||
remove_foreign_key :post_tags, column: :deleted_user_id
|
||||
remove_index :post_tags, :deleted_user_id
|
||||
|
||||
remove_column :post_tags, :active_unique_key
|
||||
remove_column :post_tags, :is_active
|
||||
remove_column :post_tags, :discarded_at
|
||||
remove_column :post_tags, :deleted_user_id
|
||||
remove_column :post_tags, :updated_at
|
||||
|
||||
execute <<~SQL
|
||||
ALTER TABLE
|
||||
post_tags
|
||||
MODIFY COLUMN
|
||||
id BIGINT NOT NULL
|
||||
SQL
|
||||
|
||||
execute <<~SQL
|
||||
ALTER TABLE
|
||||
post_tags
|
||||
DROP PRIMARY KEY
|
||||
SQL
|
||||
|
||||
remove_column :post_tags, :id
|
||||
|
||||
execute <<~SQL
|
||||
ALTER TABLE
|
||||
post_tags
|
||||
ADD PRIMARY KEY
|
||||
(post_id, tag_id)
|
||||
SQL
|
||||
|
||||
remove_index :post_tags, :post_id
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration, '戻せません.'
|
||||
end
|
||||
end
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class AddForeignKeyOnPostIdAndTagIdInPostTagSections < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
remove_foreign_key :post_tag_sections, :posts, column: :post_id
|
||||
remove_foreign_key :post_tag_sections, :tags, column: :tag_id
|
||||
|
||||
add_foreign_key :post_tag_sections, :post_tags,
|
||||
column: [:post_id, :tag_id],
|
||||
primary_key: [:post_id, :tag_id],
|
||||
on_delete: :cascade
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,46 @@
|
||||
class DeleteDiscardedRecordsFromTags < ActiveRecord::Migration[8.0]
|
||||
def up
|
||||
remove_foreign_key :tag_versions, :tags, column: :tag_id
|
||||
remove_foreign_key :nico_tag_versions, :tags, column: :tag_id
|
||||
remove_foreign_key :material_versions, :tags, column: :tag_id
|
||||
|
||||
execute <<~SQL
|
||||
DELETE
|
||||
ntr
|
||||
FROM
|
||||
nico_tag_relations ntr
|
||||
INNER JOIN
|
||||
tags t
|
||||
ON
|
||||
t.discarded_at IS NOT NULL
|
||||
AND t.id IN (ntr.tag_id, ntr.nico_tag_id)
|
||||
SQL
|
||||
|
||||
execute <<~SQL
|
||||
DELETE
|
||||
ti
|
||||
FROM
|
||||
tag_implications ti
|
||||
INNER JOIN
|
||||
tags t
|
||||
ON
|
||||
t.discarded_at IS NOT NULL
|
||||
AND t.id IN (ti.tag_id, ti.parent_tag_id)
|
||||
SQL
|
||||
|
||||
execute <<~SQL
|
||||
DELETE
|
||||
FROM
|
||||
tags
|
||||
WHERE
|
||||
discarded_at IS NOT NULL
|
||||
SQL
|
||||
|
||||
remove_index :tags, :discarded_at
|
||||
remove_column :tags, :discarded_at
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration, '戻せません.'
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
class DeleteDiscardedRecordsFromTagNames < ActiveRecord::Migration[8.0]
|
||||
def up
|
||||
execute <<~SQL
|
||||
DELETE
|
||||
FROM
|
||||
tag_names
|
||||
WHERE
|
||||
discarded_at IS NOT NULL
|
||||
SQL
|
||||
|
||||
remove_index :tag_names, :discarded_at
|
||||
remove_column :tag_names, :discarded_at
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration, '戻せません.'
|
||||
end
|
||||
end
|
||||
新しいイシューから参照
ユーザーをブロックする