mattermost-mobile-upstream/app/database/migration/server/index.ts
Pablo Vélez 7df4a0ab97
Some checks are pending
ci / lint-typecheck (push) Waiting to run
ci / detox-lint-typecheck (push) Waiting to run
ci / test (push) Waiting to run
Mm 68219 show placeholder for redacted files (#9719)
* MM-68219 - Add redacted files placeholder and related functionality

* add feature flag control and e2e tests

* adjust placeholder design, polish code, fix permalink preview issue

* polish code and add missing test

* use import path with right path

* gate post refetch behind the feature flag, refetch the open thread and avoid observeCount

* restore filesInfo for the permalink files prop added upstream

* fix stale redaction on background servers, consume the flag on every fetch path and share the viewport emitter

* replace the in-memory redaction flag with a persisted per-post epoch so ABAC file decisions survive restarts and stale posts stay hidden

* raise the redaction epoch on every resync, capture the epoch counter, only invalidate channels on role changes, and store the newer epoch when a re-verified post is otherwise unchanged

* store superseded responses unverified instead of dropping them, keep the since-fetch when re-verifying, verify permalink embeds against the linked channel, and capture the websocket epoch on arrival

* nvalidate file decisions when a user attribute field changes or all its values are cleared

* batch channel invalidations, close file viewers only when affected, reset the epoch on unstamped redaction changes, and only  re-verify the newest page's attachment posts

* re-check older channel posts a page at a time instead of one request per post

* skip the unstamped epoch lookup for posts with no files, redacted count or permalink

* keep the attribute-view retry after later invalidations, retry linked posts unless refused for the current epoch, and stop older payloads from rolling back edits via the redaction check

* MM-70905 - disable and grey out the attachment button when an ABAC pe… (#10195)

* MM-70905 - disable and grey out the attachment button when an ABAC permission policy denies uploads in the channel

* only back off render permission fetches when the server request fails, and log other errors without retrying

* remove the disableServer helper and have removeServer do both steps

* split defaultAllowed into allowWhenUnenforced and allowWhenNotEvaluated, and treat render permissions as unenforced  on servers without the decisions API

* MM-69627: Add playbook task requirements support on mobile (#10035)

* MM-69627: Add playbook task requirements support on mobile

Allow filling required task fields when checking off checklist items during
a run, gated by the same Playbooks beta setting used on web.

Co-authored-by: Cursor <cursoragent@cursor.com>

* MM-69627: Address PR review feedback for task requirements

Propagate settings write failures, harden fill-requirements save/title handling, and add missing unit coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>

* MM-69627: Fix TypeScript errors in new unit tests

Co-authored-by: Cursor <cursoragent@cursor.com>

* MM-69627: Use defineMessages for fill requirements titles

Keep i18n extraction able to find the header titles after moving them to the route.

Co-authored-by: Cursor <cursoragent@cursor.com>

* MM-69627: Address review feedback for task requirements

Update checklist items locally when saving requirement values instead of
refetching the run, add missing query/navigation tests, and apply small
callback/reduce cleanups from review.

Co-authored-by: Cursor <cursoragent@cursor.com>

* MM-69627: Fix task requirements review follow-ups

Propagate local checklist write failures, clear a stale task-requirements
flag when playbooks is unsupported, and cap fill values at the desktop/
server max length.

Co-authored-by: Cursor <cursoragent@cursor.com>

* MM-69627: Move requirement field into its own component

Keep one component per file on the fill-requirements screen.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>

* MM-69122: Add file element support to interactive dialogs (#9898)

* Implement Interactive Dialog - file upload

* update demo plugin version for e2etests

* fix and add e2etests

* review fixes

* Fix version bump checkout when a tag shares the branch name (#10229)

* Fix Android crashes caused by animated custom emoji (#10030)

* Route GIF decoding through Glide

- Keep APNG4Android for APNG, animated WebP, and animated AVIF support.
- Prepend Glide's GIF decoders to avoid APNG4Android's native GIF overflow.

* Clear Expo image resources with Glide targets

- Detach drawables when Glide clears their custom target.
- Prevent recycled GIF frame resources from remaining attached to Expo image views.

* Preserve foreground image during GIF target recycling

---------

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
Co-authored-by: Nuno Simões <nuno.simoes@mattermost.com>
Co-authored-by: MangelSpec <74370284+MangelSpec@users.noreply.github.com>

* detox - fix clobbering of feature flags that cause failures in other suites.  Also small fix of a incorrectly set test-id

---------

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
Co-authored-by: Nuno Simões <nuno.simoes@mattermost.com>
Co-authored-by: MangelSpec <74370284+MangelSpec@users.noreply.github.com>
Co-authored-by: Nate Schlossberg <nate.schlossberg@mattermost.com>
2026-10-15 15:59:13 -07:00

477 lines
17 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// NOTE : To implement migration, please follow this document
// https://nozbe.github.io/WatermelonDB/Advanced/Migrations.html
import {BOARDS_TABLES} from '@boards/constants/database';
import {addColumns, createTable, schemaMigrations, unsafeExecuteSql} from '@nozbe/watermelondb/Schema/migrations';
import {AGENTS_TABLES} from '@agents/constants/database';
import {MM_TABLES} from '@constants/database';
import {PLAYBOOK_TABLES} from '@playbooks/constants/database';
const {
CHANNEL,
CHANNEL_BOOKMARK,
CHANNEL_INFO,
CUSTOM_PROFILE_ATTRIBUTE,
CUSTOM_PROFILE_FIELD,
DRAFT,
FILE,
MY_CHANNEL,
POST,
PROPERTY_FIELD,
PROPERTY_VALUE,
SCHEDULED_POST,
} = MM_TABLES.SERVER;
const {PLAYBOOK_RUN, PLAYBOOK_CHECKLIST, PLAYBOOK_CHECKLIST_ITEM, PLAYBOOK_RUN_ATTRIBUTE, PLAYBOOK_RUN_ATTRIBUTE_VALUE} = PLAYBOOK_TABLES;
const {AI_BOT, AI_THREAD} = AGENTS_TABLES;
const {BOARD_VIEW} = BOARDS_TABLES;
export default schemaMigrations({migrations: [
{
toVersion: 23,
steps: [
// Existing rows default to 0, below DEFAULT_REDACTION_EPOCH_STATE (used while no epoch
// System row exists), so posts cached before this migration start unverified.
addColumns({
table: POST,
columns: [
{name: 'redaction_verified_epoch', type: 'number'},
],
}),
addColumns({
table: MY_CHANNEL,
columns: [
{name: 'redaction_required_epoch', type: 'number'},
],
}),
],
},
{
toVersion: 22,
steps: [
addColumns({
table: PLAYBOOK_CHECKLIST_ITEM,
columns: [
{name: 'requirements', type: 'string', isOptional: true},
],
}),
],
},
{
toVersion: 21,
steps: [
addColumns({
table: MY_CHANNEL,
columns: [
{name: 'urgent_mention_count', type: 'number'},
],
}),
],
},
{
toVersion: 20,
steps: [
createTable({
name: BOARD_VIEW,
columns: [
{name: 'channel_id', type: 'string', isIndexed: true},
{name: 'type', type: 'string'},
{name: 'creator_id', type: 'string'},
{name: 'title', type: 'string'},
{name: 'description', type: 'string', isOptional: true},
{name: 'sort_order', type: 'number'},
{name: 'props', type: 'string', isOptional: true},
{name: 'create_at', type: 'number'},
{name: 'update_at', type: 'number', isIndexed: true},
{name: 'delete_at', type: 'number'},
],
}),
createTable({
name: PROPERTY_FIELD,
columns: [
{name: 'group_id', type: 'string'},
{name: 'name', type: 'string'},
{name: 'type', type: 'string'},
{name: 'attrs', type: 'string', isOptional: true},
{name: 'object_type', type: 'string'},
{name: 'target_id', type: 'string', isIndexed: true},
{name: 'target_type', type: 'string'},
{name: 'protected', type: 'boolean'},
{name: 'permission_field', type: 'string', isOptional: true},
{name: 'permission_values', type: 'string', isOptional: true},
{name: 'permission_options', type: 'string', isOptional: true},
{name: 'create_at', type: 'number'},
{name: 'update_at', type: 'number', isIndexed: true},
{name: 'delete_at', type: 'number'},
{name: 'created_by', type: 'string'},
{name: 'updated_by', type: 'string'},
],
}),
createTable({
name: PROPERTY_VALUE,
columns: [
{name: 'field_id', type: 'string', isIndexed: true},
{name: 'target_id', type: 'string', isIndexed: true},
{name: 'target_type', type: 'string'},
{name: 'group_id', type: 'string'},
{name: 'value', type: 'string'},
{name: 'create_at', type: 'number'},
{name: 'update_at', type: 'number'},
{name: 'delete_at', type: 'number'},
{name: 'created_by', type: 'string'},
{name: 'updated_by', type: 'string'},
],
}),
],
},
{
toVersion: 19,
steps: [
createTable({
name: AI_BOT,
columns: [
{name: 'display_name', type: 'string'},
{name: 'username', type: 'string'},
{name: 'last_icon_update', type: 'number'},
{name: 'dm_channel_id', type: 'string', isIndexed: true},
{name: 'channel_access_level', type: 'number'},
{name: 'channel_ids', type: 'string'},
{name: 'user_access_level', type: 'number'},
{name: 'user_ids', type: 'string'},
{name: 'team_ids', type: 'string'},
],
}),
createTable({
name: AI_THREAD,
columns: [
{name: 'message', type: 'string'},
{name: 'title', type: 'string'},
{name: 'channel_id', type: 'string', isIndexed: true},
{name: 'reply_count', type: 'number'},
{name: 'update_at', type: 'number', isIndexed: true},
],
}),
],
},
{
toVersion: 18,
steps: [
addColumns({
table: MY_CHANNEL,
columns: [
{name: 'autotranslation_disabled', type: 'boolean'},
],
}),
addColumns({
table: CHANNEL,
columns: [
{name: 'autotranslation', type: 'boolean'},
],
}),
],
},
{
toVersion: 17,
steps: [
addColumns({
table: PLAYBOOK_RUN_ATTRIBUTE_VALUE,
columns: [
{name: 'update_at', type: 'number'},
],
}),
],
},
{
toVersion: 16,
steps: [
addColumns({
table: SCHEDULED_POST,
columns: [
{name: 'type', type: 'string', isOptional: true},
],
}),
addColumns({
table: DRAFT,
columns: [
{name: 'type', type: 'string', isOptional: true},
],
}),
],
},
{
toVersion: 15,
steps: [
addColumns({
table: PLAYBOOK_RUN,
columns: [
{name: 'type', type: 'string'},
],
}),
],
},
{
toVersion: 14,
steps: [
createTable({
name: PLAYBOOK_RUN_ATTRIBUTE,
columns: [
{name: 'group_id', type: 'string'},
{name: 'name', type: 'string'},
{name: 'type', type: 'string'},
{name: 'target_id', type: 'string'},
{name: 'target_type', type: 'string'},
{name: 'create_at', type: 'number'},
{name: 'update_at', type: 'number'},
{name: 'delete_at', type: 'number'},
{name: 'attrs', type: 'string', isOptional: true},
],
}),
createTable({
name: PLAYBOOK_RUN_ATTRIBUTE_VALUE,
columns: [
{name: 'attribute_id', type: 'string', isIndexed: true},
{name: 'run_id', type: 'string', isIndexed: true},
{name: 'value', type: 'string'},
],
}),
],
},
{
toVersion: 13,
steps: [
addColumns({
table: PLAYBOOK_CHECKLIST_ITEM,
columns: [
{name: 'condition_action', type: 'string'},
{name: 'condition_reason', type: 'string'},
],
}),
],
},
{
toVersion: 12,
steps: [
createTable({
name: PLAYBOOK_RUN,
columns: [
{name: 'playbook_id', type: 'string'},
{name: 'name', type: 'string'},
{name: 'description', type: 'string'},
{name: 'is_active', type: 'boolean', isIndexed: true},
{name: 'owner_user_id', type: 'string'},
{name: 'team_id', type: 'string'},
{name: 'channel_id', type: 'string', isIndexed: true},
{name: 'post_id', type: 'string', isOptional: true},
{name: 'create_at', type: 'number'},
{name: 'end_at', type: 'number'},
{name: 'active_stage', type: 'number'},
{name: 'active_stage_title', type: 'string'},
{name: 'participant_ids', type: 'string'}, // JSON string
{name: 'summary', type: 'string'},
{name: 'current_status', type: 'string', isIndexed: true},
{name: 'last_status_update_at', type: 'number'},
{name: 'previous_reminder', type: 'number'},
{name: 'items_order', type: 'string'},
{name: 'retrospective_enabled', type: 'boolean'},
{name: 'retrospective', type: 'string'},
{name: 'retrospective_published_at', type: 'number'},
{name: 'update_at', type: 'number'},
{name: 'sync', type: 'string', isIndexed: true, isOptional: true},
{name: 'last_sync_at', type: 'number', isOptional: true},
],
}),
createTable({
name: PLAYBOOK_CHECKLIST,
columns: [
{name: 'run_id', type: 'string', isIndexed: true},
{name: 'items_order', type: 'string'},
{name: 'title', type: 'string'},
{name: 'update_at', type: 'number'},
{name: 'sync', type: 'string', isIndexed: true, isOptional: true},
{name: 'last_sync_at', type: 'number', isOptional: true},
],
}),
createTable({
name: PLAYBOOK_CHECKLIST_ITEM,
columns: [
{name: 'checklist_id', type: 'string', isIndexed: true},
{name: 'title', type: 'string'},
{name: 'state', type: 'string', isIndexed: true},
{name: 'state_modified', type: 'number'},
{name: 'assignee_id', type: 'string', isOptional: true},
{name: 'assignee_modified', type: 'number'},
{name: 'command', type: 'string', isOptional: true},
{name: 'command_last_run', type: 'number'},
{name: 'description', type: 'string'},
{name: 'due_date', type: 'number'},
{name: 'completed_at', type: 'number'},
{name: 'task_actions', type: 'string', isOptional: true}, // JSON string
{name: 'update_at', type: 'number'},
{name: 'sync', type: 'string', isIndexed: true, isOptional: true},
{name: 'last_sync_at', type: 'number', isOptional: true},
],
}),
addColumns({
table: MY_CHANNEL,
columns: [
{name: 'last_playbook_runs_fetch_at', type: 'number'},
],
}),
],
},
{
toVersion: 11,
steps: [
addColumns({
table: CHANNEL,
columns: [
{name: 'abac_policy_enforced', type: 'boolean', isOptional: true},
],
}),
],
},
{
toVersion: 10,
steps: [
addColumns({
table: FILE,
columns: [
{name: 'is_blocked', type: 'boolean'},
],
}),
],
},
{
toVersion: 9,
steps: [
createTable({
name: SCHEDULED_POST,
columns: [
{name: 'channel_id', type: 'string', isIndexed: true},
{name: 'message', type: 'string'},
{name: 'files', type: 'string'},
{name: 'root_id', type: 'string', isIndexed: true},
{name: 'metadata', type: 'string', isOptional: true},
{name: 'create_at', type: 'number'},
{name: 'update_at', type: 'number'},
{name: 'scheduled_at', type: 'number'},
{name: 'processed_at', type: 'number'},
{name: 'error_code', type: 'string'},
],
}),
],
},
{
toVersion: 8,
steps: [
createTable({
name: CUSTOM_PROFILE_ATTRIBUTE,
columns: [
{name: 'field_id', type: 'string', isIndexed: true},
{name: 'user_id', type: 'string', isIndexed: true},
{name: 'value', type: 'string'},
],
}),
createTable({
name: CUSTOM_PROFILE_FIELD,
columns: [
{name: 'group_id', type: 'string', isIndexed: true},
{name: 'name', type: 'string'},
{name: 'type', type: 'string'},
{name: 'target_id', type: 'string'},
{name: 'target_type', type: 'string'},
{name: 'create_at', type: 'number'},
{name: 'update_at', type: 'number'},
{name: 'delete_at', type: 'number', isOptional: true},
{name: 'attrs', type: 'string', isOptional: true},
],
}),
],
},
{
toVersion: 7,
steps: [
addColumns({
table: CHANNEL,
columns: [
{name: 'banner_info', type: 'string', isOptional: true},
],
}),
],
},
{
toVersion: 6,
steps: [
unsafeExecuteSql('CREATE INDEX IF NOT EXISTS Post_type ON Post (type);'),
],
},
{
toVersion: 5,
steps: [
addColumns({
table: DRAFT,
columns: [
{name: 'update_at', type: 'number'},
],
}),
],
},
{
toVersion: 4,
steps: [
createTable({
name: CHANNEL_BOOKMARK,
columns: [
{name: 'create_at', type: 'number'},
{name: 'update_at', type: 'number'},
{name: 'delete_at', type: 'number'},
{name: 'channel_id', type: 'string', isIndexed: true},
{name: 'owner_id', type: 'string'},
{name: 'file_id', type: 'string', isOptional: true},
{name: 'display_name', type: 'string'},
{name: 'sort_order', type: 'number'},
{name: 'link_url', type: 'string', isOptional: true},
{name: 'image_url', type: 'string', isOptional: true},
{name: 'emoji', type: 'string', isOptional: true},
{name: 'type', type: 'string'},
{name: 'original_id', type: 'string', isOptional: true},
{name: 'parent_id', type: 'string', isOptional: true},
],
}),
],
},
{
toVersion: 3,
steps: [
addColumns({
table: POST,
columns: [
{name: 'message_source', type: 'string'},
],
}),
],
},
{
toVersion: 2,
steps: [
addColumns({
table: CHANNEL_INFO,
columns: [
{name: 'files_count', type: 'number'},
],
}),
addColumns({
table: DRAFT,
columns: [
{name: 'metadata', type: 'string', isOptional: true},
],
}),
],
},
]});