このコミットが含まれているのは:
2026-07-13 12:44:33 +09:00
コミット 9a6e6f6053
4個のファイルの変更137行の追加3行の削除
+47
ファイルの表示
@@ -0,0 +1,47 @@
class CreatePostUrlSanitisationRules < ActiveRecord::Migration[8.0]
def up
create_table :post_url_sanitisation_rules,
id: :integer,
primary_key: :priority do |t|
t.string :source_pattern, null: false
t.string :replacement, null: false
t.timestamps
t.datetime :discarded_at
t.index :source_pattern, unique: true
t.index :discarded_at
end
now = ActiveRecord::Base.connection.quote(Time.current)
execute <<~SQL
INSERT INTO
post_url_sanitisation_rules(priority, source_pattern, replacement, created_at, updated_at)
VALUES
(10, '\\Ahttps?://youtu\\\\.be/([^/?#]+)(?:[?#].*)?\\z',
'https://www.youtube.com/watch?v=\\\\1',
#{ now }, #{ now })
, (20, '\\Ahttps?://(?:www\\\\.|m\\\\.)?youtube\\\\.com/live/([^/?#]+)(?:[?#].*)?\\z',
'https://www.youtube.com/watch?v=\\\\1',
#{ now }, #{ now })
, (30, '\\Ahttps?://(?:www\\\\.|m\\\\.)?youtube\\\\.com/shorts/([^/?#]+)(?:[?#].*)?\\z',
'https://www.youtube.com/watch?v=\\\\1',
#{ now }, #{ now })
, (40, '\\Ahttps?://(?:www\\\\.|m\\\\.)?youtube\\\\.com/embed/([^/?#]+)(?:[?#].*)?\\z',
'https://www.youtube.com/watch?v=\\\\1',
#{ now }, #{ now })
, (50, '\\Ahttps?://(?:www\\\\.|m\\\\.)?youtube\\\\.com/watch\\\\?(?:[^#&]+&)*v=([^&#]+)(?:[&#].*)?\\z',
'https://www.youtube.com/watch?v=\\\\1',
#{ now }, #{ now })
, (60, '\\Ahttps?://nico\\\\.ms/([^/?#]+)(?:[?#].*)?\\z',
'https://www.nicovideo.jp/watch/\\\\1',
#{ now }, #{ now })
, (70, '\\Ahttps?://(?:www\\\\.)?nicovideo\\\\.jp/watch/([^?#/]+)(?:[?#].*)?\\z',
'https://www.nicovideo.jp/watch/\\\\1',
#{ now }, #{ now })
;
SQL
end
def down
drop_table :post_url_sanitisation_rules
end
end
生成ファイル
+11 -1
ファイルの表示
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.0].define(version: 2026_07_05_000000) do
ActiveRecord::Schema[8.0].define(version: 2026_07_13_000000) do
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
@@ -331,6 +331,16 @@ ActiveRecord::Schema[8.0].define(version: 2026_07_05_000000) do
t.index ["tag_id"], name: "index_post_tags_on_tag_id"
end
create_table "post_url_sanitisation_rules", primary_key: "priority", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.string "source_pattern", null: false
t.string "replacement", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "discarded_at"
t.index ["discarded_at"], name: "index_post_url_sanitisation_rules_on_discarded_at"
t.index ["source_pattern"], name: "index_post_url_sanitisation_rules_on_source_pattern", unique: true
end
create_table "post_versions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
t.bigint "post_id", null: false
t.integer "version_no", null: false