2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-10-04 17:32:34 +08:00
Commit graph

72 commits

Author SHA1 Message Date
Gerhard Schlager
5fee59b220
DEV: Query human users in "discourse" converter correctly (#35111) 2025-10-01 21:18:28 +02:00
Gerhard Schlager
236a89d5e3
DEV: Allow overriding globally excluded columns in IntermediateDB (#35114) 2025-10-01 21:18:09 +02:00
Gerhard Schlager
26f617a03f
DEV: Optimize IntermediateDB before running importer (#35112) 2025-10-01 21:17:59 +02:00
Selase Krakani
d6003f414f
DEV: Add archetype index (#35113) 2025-10-01 13:28:53 +00:00
Gerhard Schlager
ecb2c1144d DEV: Add YARD documentation for IntermediateDB models 2025-10-01 15:25:28 +02:00
Gerhard Schlager
5b3dbb2c6f DEV: Add ability to generate enums for IntermediateDB
This also adds the ability to generate YARD documentation for IntermediateDB models.
2025-10-01 15:25:28 +02:00
Selase Krakani
3ca1f8bf42
DEV: Add support for converting and importing topic_users (#35038)
This adds converter(Discourse-only, for now) and importer steps for
`topic_users`
2025-10-01 11:14:25 +00:00
Selase Krakani
fb820c63c3
DEV: Add support for converting and importing topic_tags (#35041)
This adds converter(Discourse-only, for now) and importer steps for
`topic_tags`.
2025-10-01 11:05:27 +00:00
Selase Krakani
2d7d6c2ee9
DEV: Add support for converting and importing topic_allowed_groups (#35039)
This adds converter(Discourse-only, for now) and importer steps for
`topic_allowed_groups`
2025-10-01 11:01:51 +00:00
Selase Krakani
9e85544f72
DEV: Add support for converting and importing topic_allowed_users (#35040)
This adds converter(Discourse-only, for now) and importer steps for
`topic_allowed_users`
2025-09-30 17:01:38 +00:00
Selase Krakani
e70b60ff7f
DEV: Add support for converting and importing topics (#34767)
This adds converter(Discourse-only, for now) and importer steps for
`topics`.
2025-09-30 11:52:22 +00:00
Selase Krakani
964d2ebd23
DEV: Add support for converting and importing linked user_custom_fields (#34339)
First pass at converting and importing user customer fields linked to
user fields


Depends on https://github.com/discourse/discourse/pull/34739
2025-09-28 23:52:23 +00:00
Selase Krakani
e7fe9f41b3
DEV: Sync IntermediateDB to support user_fields.show_on_signup (#34845)
Some checks failed
Licenses / run (push) Has been cancelled
Linting / run (push) Has been cancelled
Migration Tests / Tests (push) Has been cancelled
Publish Assets / publish-assets (push) Has been cancelled
Tests / core backend (push) Has been cancelled
Tests / plugins backend (push) Has been cancelled
Tests / core frontend (Chrome) (push) Has been cancelled
Tests / plugins frontend (push) Has been cancelled
Tests / themes frontend (push) Has been cancelled
Tests / core system (push) Has been cancelled
Tests / plugins system (push) Has been cancelled
Tests / themes system (push) Has been cancelled
Tests / core frontend (Firefox ESR) (push) Has been cancelled
Tests / core frontend (Firefox Evergreen) (push) Has been cancelled
Tests / chat system (push) Has been cancelled
Tests / merge (push) Has been cancelled
Support newly added column on the `user_fields` core table
2025-09-24 17:28:28 +00:00
Selase Krakani
77e6d185a6
DEV: Add Intermediate DB support for user_associated_accounts (#34425)
Implement Discourse converter step and import step for
`user_associated_accounts`
2025-09-15 01:00:25 +00:00
Selase Krakani
99ace1be12
DEV: Add support for table-level constraints (#34739)
Some checks failed
Licenses / run (push) Has been cancelled
Linting / run (push) Has been cancelled
Migration Tests / Tests (push) Has been cancelled
Publish Assets / publish-assets (push) Has been cancelled
Tests / core backend (push) Has been cancelled
Tests / plugins backend (push) Has been cancelled
Tests / core frontend (Chrome) (push) Has been cancelled
Tests / plugins frontend (push) Has been cancelled
Tests / themes frontend (push) Has been cancelled
Tests / core system (push) Has been cancelled
Tests / plugins system (push) Has been cancelled
Tests / themes system (push) Has been cancelled
Tests / core frontend (Firefox ESR) (push) Has been cancelled
Tests / core frontend (Firefox Evergreen) (push) Has been cancelled
Tests / chat system (push) Has been cancelled
Tests / merge (push) Has been cancelled
Allow table-level check constraints in the Intermediate DB


In https://github.com/discourse/discourse/pull/34339, I’ve worked on
distinguishing between `user_custom_fields` tied to `user_fields` and
arbitrary `user_custom_fields` entries.

To support this, I’ve made both `field_id` and `name` nullable, which
requires a table-level constraint to ensure each entry has either a
`field_id` (referencing `user_fields`) or an arbitrary `name` for the
value.

This first pass supports only named  table-level `CHECK` constraints.

## Usage

```yaml
user_custom_fields:
      columns:
        exclude:
          - "id"
        modify:
          - name: "name"
            nullable: true
        add:
          - name: "field_id"
            datatype: numeric
          - name: "is_multiselect_field"
            datatype: boolean
      indexes:
      # ...
      constraints:
        - name: "require_field_id_or_name"
          condition: "field_id IS NOT NULL OR name IS NOT NULL"
        - name: "disallow_both_field_id_and_name"
          type: check      # default, only `check` supported for now
          condition: "NOT (field_id IS NOT NULL AND name IS NOT NULL)"
```



```sql
CREATE TABLE user_custom_fields
(
    created_at           DATETIME,
    field_id             NUMERIC,
    is_multiselect_field BOOLEAN,
    name                 TEXT,
    user_id              NUMERIC  NOT NULL,
    value                TEXT,
    CONSTRAINT require_field_id_or_name CHECK (field_id IS NOT NULL OR name IS NOT NULL),
    CONSTRAINT disallow_both_field_id_and_name CHECK (NOT (field_id IS NOT NULL AND name IS NOT NULL))
);
```
2025-09-12 20:14:51 +00:00
Gerhard Schlager
0723fdf9f4
DEV: Remove "example" converter (#34647) 2025-09-01 11:50:58 +02:00
Gerhard Schlager
bb6c5c9fa1
DEV: Dynamically test all IntermediateDB entities (#34624)
Some checks failed
Licenses / run (push) Has been cancelled
Linting / run (push) Has been cancelled
Migration Tests / Tests (push) Has been cancelled
Publish Assets / publish-assets (push) Has been cancelled
Tests / core backend (push) Has been cancelled
Tests / plugins backend (push) Has been cancelled
Tests / core frontend (Chrome) (push) Has been cancelled
Tests / plugins frontend (push) Has been cancelled
Tests / themes frontend (push) Has been cancelled
Tests / core system (push) Has been cancelled
Tests / plugins system (push) Has been cancelled
Tests / themes system (push) Has been cancelled
Tests / core frontend (Firefox ESR) (push) Has been cancelled
Tests / core frontend (Firefox Evergreen) (push) Has been cancelled
Tests / chat system (push) Has been cancelled
Tests / merge (push) Has been cancelled
2025-08-29 17:25:05 +02:00
Gerhard Schlager
8f00667e83
DEV: Make SQL constant in IntermediateDB models private (#34610) 2025-08-28 18:12:01 +02:00
Selase Krakani
3e0dff8ee9
DEV: Add support for converting and importing user_fields (#34295)
This adds converter(Discourse-only, for now) and importer steps for
`user_fields`

The change also includes additional steps for `user_field_options`

---------

Co-authored-by: Gerhard Schlager <gerhard.schlager@discourse.org>
2025-08-27 11:47:32 +00:00
Selase Krakani
713b4088af
DEV: Add support for converting and importing tag_users (#34101)
This adds converter(Discourse-only, for now) and importer steps for
`tag_users`
2025-08-26 17:14:33 +00:00
Selase Krakani
04eabc3c96
DEV: Add support for converting and importing tag_group_memberships (#34007)
This adds converter(Discourse-only, for now) and importer steps for
`tag_group_memberships`
2025-08-26 16:42:05 +00:00
Selase Krakani
ef503f2f8f
DEV: Add support for converting and importing tag_group_permissions (#34100)
This adds converter(Discourse-only, for now) and importer steps for
`tag_group_permissions`
2025-08-26 16:15:32 +00:00
Selase Krakani
f34a476c20
DEV: Add support for converting and importing badge_groupings (#34190)
This adds converter(Discourse-only, for now) and importer steps for
`badge_groupings`
2025-08-26 15:28:16 +00:00
Selase Krakani
b7459203ec
DEV: Add support for converting and importing tag_groups (#33991)
This adds converter(Discourse-only, for now) and importer steps for
tag_groups
2025-08-26 15:13:25 +00:00
Selase Krakani
c3c62165fb
DEV: Add an after_copy_data hook to CopyStep (#34491)
Allow CopyStep implementations to perform finalization actions after all
rows have been copied
2025-08-26 14:44:48 +00:00
Selase Krakani
513ace2462
DEV: Remove theme_color_schemes table from Intermediate DB config (#34538)
The `theme_color_schemes` table was dropped in
7ee52c8f85
2025-08-26 14:32:03 +00:00
Selase Krakani
c2fe06f15c
DEV: Add support for converting and importing tags (#33984)
This adds converter(Discourse-only, for now) and importer steps for tags
2025-08-21 20:59:04 +00:00
Selase Krakani
62ceb97e11
DEV: Remove redundant newlines in generated indexes (#34344)
Before:
```sql
CREATE TABLE muted_users
(
    created_at    DATETIME,
    muted_user_id NUMERIC  NOT NULL,
    user_id       NUMERIC  NOT NULL
);

CREATE TABLE user_custom_fields
(
    created_at           DATETIME,
    field_id             NUMERIC,
    is_multiselect_field BOOLEAN,
    name                 TEXT     NOT NULL,
    user_id              NUMERIC  NOT NULL,
    value                TEXT
);

CREATE UNIQUE INDEX ucf_multiselect_by_field_id_index ON user_custom_fields (user_id, field_id, value) WHERE is_multiselect_field = TRUE AND field_id IS NOT NULL;

CREATE UNIQUE INDEX ucf_not_multiselect_by_field_id_index ON user_custom_fields (user_id, field_id) WHERE is_multiselect_field = FALSE AND field_id IS NOT NULL;

CREATE UNIQUE INDEX ucf_multiselect_by_name_index ON user_custom_fields (user_id, name, value) WHERE is_multiselect_field = TRUE;

CREATE UNIQUE INDEX ucf_not_multiselect_by_name_index ON user_custom_fields (user_id, name) WHERE is_multiselect_field = FALSE;

CREATE TABLE user_emails
(
    email      TEXT     NOT NULL,
    user_id    NUMERIC  NOT NULL,
    created_at DATETIME,
    "primary"  BOOLEAN,
    PRIMARY KEY (user_id, email)
);
```

After:
```sql
CREATE TABLE muted_users
(
    created_at    DATETIME,
    muted_user_id NUMERIC  NOT NULL,
    user_id       NUMERIC  NOT NULL
);

CREATE TABLE user_custom_fields
(
    created_at           DATETIME,
    field_id             NUMERIC,
    is_multiselect_field BOOLEAN,
    name                 TEXT     NOT NULL,
    user_id              NUMERIC  NOT NULL,
    value                TEXT
);

CREATE UNIQUE INDEX ucf_multiselect_by_field_id_index ON user_custom_fields (user_id, field_id, value) WHERE is_multiselect_field = TRUE AND field_id IS NOT NULL; 
CREATE UNIQUE INDEX ucf_not_multiselect_by_field_id_index ON user_custom_fields (user_id, field_id) WHERE is_multiselect_field = FALSE AND field_id IS NOT NULL; 
CREATE UNIQUE INDEX ucf_multiselect_by_name_index ON user_custom_fields (user_id, name, value) WHERE is_multiselect_field = TRUE; 
CREATE UNIQUE INDEX ucf_not_multiselect_by_name_index ON user_custom_fields (user_id, name) WHERE is_multiselect_field = FALSE;

CREATE TABLE user_emails
(
    email      TEXT     NOT NULL,
    user_id    NUMERIC  NOT NULL,
    created_at DATETIME,
    "primary"  BOOLEAN,
    PRIMARY KEY (user_id, email)
);
```
2025-08-19 23:34:29 +00:00
Selase Krakani
f0e59d89a5
DEV: Add new user_options column to intermediate DB schema (#34124)
Regenerate intermediate DB schema to reflect newly added `user_options`
column
2025-08-07 12:55:48 +00:00
Martin Brennan
7121cfd4ab
FEATURE: User preference for editor Markdown monospace font (#34051)
This commit responds to feedback in the Discourse Meta discussion

https://meta.discourse.org/t/monospace-font-in-the-markdown-only-editor/359936

This change introduces a user preference that allows users to choose
whether the Markdown editor uses a monospace font. The default setting
is `true` for new sites, but set to `false` for existing sites to avoid
disrupting current users' experiences.

Admins can change the `default_other_enable_markdown_monospace_font`
site setting to manage this for all users.
2025-08-04 14:56:21 +10:00
Martin Brennan
6f92b20486
DEV: Drop old enable_experimental_sidebar user option (#34052)
This is no longer used anywhere in the codebase.
2025-08-04 13:48:57 +10:00
Selase Krakani
ea5b5b6c00
DEV: Add muted_users converter and importer steps (#33709)
This adds converter(Discourse-only, for now) and importer steps for
muted_users
2025-07-28 11:35:24 +00:00
Selase Krakani
e05582ab5d
DEV: Add group_users converter and importer steps (#33687)
This adds converter(Discourse-only, for now) and importer steps for
`group_users`
2025-07-28 11:08:54 +00:00
Selase Krakani
a5c0326da1
DEV: Add groups converter and importer steps (#33373)
This adds converter(Discourse-only, for now) and importer steps for
`groups`
2025-07-28 10:42:30 +00:00
Selase Krakani
57a04e7ec8
DEV: SetStore backed implementation of requires_set (#33626)
This change updates `requires_set` internals to use our custom set
implementations via `Migrations::SetStore`
2025-07-28 10:41:46 +00:00
Gerhard Schlager
53d7a756d6
DEV: Add Migrations::SetStore to work with nested sets of data (#33593)
There are concrete implementations for a simple set, a key-value store,
and nested sets with 2 or 3 keys. The API stays the same for all
implementations and the performances is more or less the same as without
the wrapper (at least with YJIT enabled).
2025-07-24 12:11:41 +02:00
Gerhard Schlager
bb7afcf2a1
DEV: Add newly promoted core plugins to IntermediateDB config (#33798) 2025-07-24 12:10:37 +02:00
Selase Krakani
53c557ff6c
DEV: Add custom_category_fields converter and importer steps (#33362)
This adds converter(Discourse-only, for now) and importer steps for
`category_custom_fields`
2025-07-24 00:20:46 +00:00
Selase Krakani
acb23b5b4a
DEV: Add newly promoted core plugins to intermediate DB config (#33654)
Update `intermedate_db.yml` config with newly promoted core plugins
names and tables to the intermediate DB config.

It also updates the existing `user_options` table with the newly
introduced `notification_level_when_assigned` column.
2025-07-16 17:33:51 +00:00
Selase Krakani
8253b14732
DEV: Add category_users converter and importer steps (#33367)
This adds converter(Discourse-only, for now) and importer steps for
`category_users`
2025-07-15 13:21:50 +00:00
Selase Krakani
5ad072aab4
DEV: Add categories converter and importer steps (#33067)
This adds a converter (Discourse only, for now) and importer steps for categories, along with a category upload references import step.
2025-06-26 16:37:24 +02:00
Gerhard Schlager
c79c1d63d0
DEV: Import user avatars from IntermediateDB (#33319)
This also enhances the converter step, which stores the Gravatar if it is
set and used. It also fixes the import of uploads which didn't use the
correct user ID.

---------

Co-authored-by: Selase Krakani <849886+s3lase@users.noreply.github.com>
2025-06-25 23:37:27 +02:00
Selase Krakani
404dcc7623
DEV: Add badges converter and importer steps (#33019)
This adds converter(just Discourse for now) and importer steps for
`badges`
2025-06-25 13:15:24 +02:00
Gerhard Schlager
2fa0dc58d4
DEV: Allow multiple users to have the same email in IntermediateDB (#33318)
The import script will merge the users based on email
2025-06-24 22:59:00 +02:00
Gerhard Schlager
b31189e0b4
DEV: Add --reset option to import command (#33317)
It deletes the MappingDB before executing the import. That's useful
during development when you repeat the import multiple times.
2025-06-24 22:58:32 +02:00
Gerhard Schlager
95f4460394
DEV: Import uploads from UploadsDB (#33259) 2025-06-20 22:59:57 +02:00
Gerhard Schlager
a51fb04864
DEV: Store avatar in users converter step (#33176) 2025-06-20 22:59:36 +02:00
Selase Krakani
d304e708be
FIX: Stop silently dropping first two rows during load_mapping (#33076)
Currently, the first two rows returned by `DiscourseDB#query_array` are
silently dropped during the column size check in
`DiscourseDB#load_mapping`. This happens because the rows object, while
an enumerator, isn't fully compliant, it doesn't rewind during
introspection. As a result, calls like `#first`, `#peek`, or `#any?`
advance the iterator.

Ideally, we’d fix this by updating the `query_array` enumeration
implementation. However, customizing the enumerator to be fully
compliant would likely introduce unnecessary perf overhead for all use
cases. So, this fix works around that limitation by building the map a
little differently.
2025-06-09 23:26:59 +02:00
Selase Krakani
631d2e3369
FIX: Exclude reviewable_notes from intermediate DB schema (#33068) 2025-06-04 10:31:28 +08:00
Selase Krakani
a48f33fda0
FIX: Ensure copy_data callbacks run even when all rows are skipped (#33002)
Currently, if a batch "copy" of an import step results in all rows being
skipped, the `after_commit_of_skipped_rows` callback is never triggered.
This happens because the callback is nested inside a block that only
runs when at least one row is inserted.

This change ensures the DB copy operation returns both inserted and
skipped rows, allowing the caller to respond appropriately in either
case.

---------

Co-authored-by: Gerhard Schlager <gerhard.schlager@discourse.org>
2025-06-02 23:07:28 +02:00