0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 21:45:25 +08:00
discourse/migrations/tooling/config/schema/intermediate_db/tables/embed_quotes.rb
Gerhard Schlager 4032dc2b05 MT: Rework the embed linkage tables around an embed owner
The post_* linkage tables from #41177 become embed_* tables keyed by
(owner_type, owner_id), because placeholders will also live in user
bios and group/category/badge descriptions later. On top of the rename:

- quotes carry source coordinates (topic id + post number) and links a
  typed target, so the importer can resolve both once the id maps exist
- new hashtag and emoji linkage tables; mention_type, hashtag_type and
  link_target become integer enums and the string MentionType is gone
- EmbedBuffer records for one owner kind, PlaceholderResolver resolves
  and renders per owner and reports unresolved embeds and orphaned
  placeholders
- the posts and custom_emojis tables stay ignored until their
  conversion steps land in a follow-up PR
- the lazy source-name lookups (users, groups, categories with their
  slug paths, synonym-folded tags) live in their own NameResolver, and
  the resolver spec is split by phase under placeholder_resolver/
2026-07-22 12:56:54 +02:00

30 lines
1.5 KiB
Ruby
Vendored

# frozen_string_literal: true
# `[quote]` embeds. These point at no Discourse entity; they are just text the
# importer rewrites once the `original_id -> discourse_id` maps exist. `placeholder`
# holds the token spliced into the owner's markdown (a post body today, a user bio
# etc. later); see `Migrations::Placeholder`. `owner_type`/`owner_id` name that
# owning record. `quoted_username` and `quoted_name` are the source's fallback
# display, used when the quoted user can't be mapped to a Discourse user. The
# username doubles as the lookup key: when `quoted_user_id` is nil, the importer
# resolves it to the user's `original_id` (in memory, never written back).
#
# The quoted post is identified either by its source `original_id` (`quoted_post_id`,
# filled by converters that know it) or by the source coordinates the attribution
# carries (`quoted_topic_id` + `quoted_post_number`, the source's own numbering).
# The importer resolves the coordinates to a `quoted_post_id` before rendering.
Migrations::Tooling::Schema.table :embed_quotes do
synthetic!
add_column :owner_type, :integer, required: true, enum: :embed_owner
add_column :owner_id, :numeric, required: true
add_column :placeholder, :text, required: true
add_column :quoted_post_id, :numeric
add_column :quoted_topic_id, :numeric
add_column :quoted_post_number, :integer
add_column :quoted_user_id, :numeric
add_column :quoted_username, :text
add_column :quoted_name, :text
index :owner_type, :owner_id
end