snapshot of https://github.com/mattermost/mattermost.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
This commit is contained in:
13
server/channels/db/assets.go
Normal file
13
server/channels/db/assets.go
Normal file
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package db
|
||||
|
||||
import "embed"
|
||||
|
||||
//go:embed migrations
|
||||
var assets embed.FS
|
||||
|
||||
func Assets() embed.FS {
|
||||
return assets
|
||||
}
|
||||
61
server/channels/db/migrations/README.md
Normal file
61
server/channels/db/migrations/README.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Database Migration Rules
|
||||
|
||||
Enforce these rules to prevent table locks and performance degradation on large production databases (100M+ posts).
|
||||
|
||||
## General Rules
|
||||
|
||||
- Each migration should do one thing. Don't combine unrelated schema changes.
|
||||
- Prefer additive changes (new columns, new tables) over destructive ones.
|
||||
- Schema migrations must **ALWAYS** be backwards compatible until the last ESR.
|
||||
- Test migrations against a database with realistic data volume, not just a dev-sized dataset. An `EXPLAIN ANALYZE` that looks fine on 12M posts may behave very differently at 100M posts.
|
||||
- If a shipped migration is broken, do not modify it. Add a new migration to correct.
|
||||
|
||||
## File Naming and Structure
|
||||
|
||||
Migration files follow the convention `{sequence_number}_{description}.{up|down}.sql` and live in `db/migrations/{driver_name}/`. After creating migration files, run `make migrations-extract` to update `db/migrations/migrations.list`. Merge upstream before submitting a PR to avoid sequence number collisions.
|
||||
|
||||
## Table Locking
|
||||
|
||||
Never write a migration that locks an entire table. Common operations that acquire table-level locks:
|
||||
|
||||
- `ALTER COLUMN` (type change) — rewrites the table
|
||||
- `CREATE INDEX` without `CONCURRENTLY`
|
||||
- `ADD FOREIGN KEY` without `NOT VALID`
|
||||
- `LOCK TABLE`
|
||||
|
||||
## Column Type Changes
|
||||
|
||||
As noted above, `ALTER COLUMN` (type change) rewrites the entire table and blocks concurrent DML: strongly avoid. A real-world example took 8+ hours on a large customer database. When unavoidable, use a multi-release phased approach:
|
||||
|
||||
1. Release N: add the new column.
|
||||
2. Release N+1: backfill data via background jobs; use triggers for ongoing updates.
|
||||
3. Release N+2 (ESR): start using the new column in code.
|
||||
4. Release N+3 (ESR): drop the old column.
|
||||
|
||||
## Batch Updates
|
||||
|
||||
Never do a full-table `UPDATE` in a migration. Process data in batches in a job at runtime:
|
||||
|
||||
```sql
|
||||
UPDATE foo SET col = value
|
||||
WHERE id IN (
|
||||
SELECT id FROM foo WHERE id > :offset ORDER BY id ASC LIMIT 100
|
||||
);
|
||||
```
|
||||
|
||||
Store the offset and resume across job runs.
|
||||
|
||||
## Adding Unique Constraints
|
||||
|
||||
Do not add a unique constraint directly. Create the index concurrently first, then attach it:
|
||||
|
||||
```sql
|
||||
CREATE UNIQUE INDEX CONCURRENTLY constraint_name ON foo (bar);
|
||||
ALTER TABLE foo ADD UNIQUE USING INDEX constraint_name;
|
||||
```
|
||||
|
||||
Note that this cannot be done inside a transaction block, so it must be in a separate migration file. Use the `-- morph:nontransactional` comment to disable transactions for that migration.
|
||||
|
||||
## Foreign Key Constraints
|
||||
|
||||
Avoid foreign key constraints. Adding a foreign key takes a `SHARE ROW EXCLUSIVE` lock, limiting concurrent activity to SELECT queries only. If truly needed, consider adding the constraint with `NOT VALID` to avoid the full-table scan under lock.
|
||||
439
server/channels/db/migrations/migrations.list
Normal file
439
server/channels/db/migrations/migrations.list
Normal file
@@ -0,0 +1,439 @@
|
||||
# Autogenerated file to synchronize migrations sequence in the PR workflow, please do not edit.
|
||||
channels/db/migrations/postgres/000001_create_teams.down.sql
|
||||
channels/db/migrations/postgres/000001_create_teams.up.sql
|
||||
channels/db/migrations/postgres/000002_create_team_members.down.sql
|
||||
channels/db/migrations/postgres/000002_create_team_members.up.sql
|
||||
channels/db/migrations/postgres/000003_create_cluster_discovery.down.sql
|
||||
channels/db/migrations/postgres/000003_create_cluster_discovery.up.sql
|
||||
channels/db/migrations/postgres/000004_create_command_webhooks.down.sql
|
||||
channels/db/migrations/postgres/000004_create_command_webhooks.up.sql
|
||||
channels/db/migrations/postgres/000005_create_compliances.down.sql
|
||||
channels/db/migrations/postgres/000005_create_compliances.up.sql
|
||||
channels/db/migrations/postgres/000006_create_emojis.down.sql
|
||||
channels/db/migrations/postgres/000006_create_emojis.up.sql
|
||||
channels/db/migrations/postgres/000007_create_user_groups.down.sql
|
||||
channels/db/migrations/postgres/000007_create_user_groups.up.sql
|
||||
channels/db/migrations/postgres/000008_create_group_members.down.sql
|
||||
channels/db/migrations/postgres/000008_create_group_members.up.sql
|
||||
channels/db/migrations/postgres/000009_create_group_teams.down.sql
|
||||
channels/db/migrations/postgres/000009_create_group_teams.up.sql
|
||||
channels/db/migrations/postgres/000010_create_group_channels.down.sql
|
||||
channels/db/migrations/postgres/000010_create_group_channels.up.sql
|
||||
channels/db/migrations/postgres/000011_create_link_metadata.down.sql
|
||||
channels/db/migrations/postgres/000011_create_link_metadata.up.sql
|
||||
channels/db/migrations/postgres/000012_create_commands.down.sql
|
||||
channels/db/migrations/postgres/000012_create_commands.up.sql
|
||||
channels/db/migrations/postgres/000013_create_incoming_webhooks.down.sql
|
||||
channels/db/migrations/postgres/000013_create_incoming_webhooks.up.sql
|
||||
channels/db/migrations/postgres/000014_create_outgoing_webhooks.down.sql
|
||||
channels/db/migrations/postgres/000014_create_outgoing_webhooks.up.sql
|
||||
channels/db/migrations/postgres/000015_create_systems.down.sql
|
||||
channels/db/migrations/postgres/000015_create_systems.up.sql
|
||||
channels/db/migrations/postgres/000016_create_reactions.down.sql
|
||||
channels/db/migrations/postgres/000016_create_reactions.up.sql
|
||||
channels/db/migrations/postgres/000017_create_roles.down.sql
|
||||
channels/db/migrations/postgres/000017_create_roles.up.sql
|
||||
channels/db/migrations/postgres/000018_create_schemes.down.sql
|
||||
channels/db/migrations/postgres/000018_create_schemes.up.sql
|
||||
channels/db/migrations/postgres/000019_create_licenses.down.sql
|
||||
channels/db/migrations/postgres/000019_create_licenses.up.sql
|
||||
channels/db/migrations/postgres/000020_create_posts.down.sql
|
||||
channels/db/migrations/postgres/000020_create_posts.up.sql
|
||||
channels/db/migrations/postgres/000021_create_product_notice_view_state.down.sql
|
||||
channels/db/migrations/postgres/000021_create_product_notice_view_state.up.sql
|
||||
channels/db/migrations/postgres/000022_create_sessions.down.sql
|
||||
channels/db/migrations/postgres/000022_create_sessions.up.sql
|
||||
channels/db/migrations/postgres/000023_create_terms_of_service.down.sql
|
||||
channels/db/migrations/postgres/000023_create_terms_of_service.up.sql
|
||||
channels/db/migrations/postgres/000024_create_audits.down.sql
|
||||
channels/db/migrations/postgres/000024_create_audits.up.sql
|
||||
channels/db/migrations/postgres/000025_create_oauth_access_data.down.sql
|
||||
channels/db/migrations/postgres/000025_create_oauth_access_data.up.sql
|
||||
channels/db/migrations/postgres/000026_create_preferences.down.sql
|
||||
channels/db/migrations/postgres/000026_create_preferences.up.sql
|
||||
channels/db/migrations/postgres/000027_create_status.down.sql
|
||||
channels/db/migrations/postgres/000027_create_status.up.sql
|
||||
channels/db/migrations/postgres/000028_create_tokens.down.sql
|
||||
channels/db/migrations/postgres/000028_create_tokens.up.sql
|
||||
channels/db/migrations/postgres/000029_create_bots.down.sql
|
||||
channels/db/migrations/postgres/000029_create_bots.up.sql
|
||||
channels/db/migrations/postgres/000030_create_user_access_tokens.down.sql
|
||||
channels/db/migrations/postgres/000030_create_user_access_tokens.up.sql
|
||||
channels/db/migrations/postgres/000031_create_remote_clusters.down.sql
|
||||
channels/db/migrations/postgres/000031_create_remote_clusters.up.sql
|
||||
channels/db/migrations/postgres/000032_create_sharedchannels.down.sql
|
||||
channels/db/migrations/postgres/000032_create_sharedchannels.up.sql
|
||||
channels/db/migrations/postgres/000033_create_sidebar_channels.down.sql
|
||||
channels/db/migrations/postgres/000033_create_sidebar_channels.up.sql
|
||||
channels/db/migrations/postgres/000034_create_oauthauthdata.down.sql
|
||||
channels/db/migrations/postgres/000034_create_oauthauthdata.up.sql
|
||||
channels/db/migrations/postgres/000035_create_sharedchannelattachments.down.sql
|
||||
channels/db/migrations/postgres/000035_create_sharedchannelattachments.up.sql
|
||||
channels/db/migrations/postgres/000036_create_sharedchannelusers.down.sql
|
||||
channels/db/migrations/postgres/000036_create_sharedchannelusers.up.sql
|
||||
channels/db/migrations/postgres/000037_create_sharedchannelremotes.down.sql
|
||||
channels/db/migrations/postgres/000037_create_sharedchannelremotes.up.sql
|
||||
channels/db/migrations/postgres/000038_create_jobs.down.sql
|
||||
channels/db/migrations/postgres/000038_create_jobs.up.sql
|
||||
channels/db/migrations/postgres/000039_create_channel_member_history.down.sql
|
||||
channels/db/migrations/postgres/000039_create_channel_member_history.up.sql
|
||||
channels/db/migrations/postgres/000040_create_sidebar_categories.down.sql
|
||||
channels/db/migrations/postgres/000040_create_sidebar_categories.up.sql
|
||||
channels/db/migrations/postgres/000041_create_upload_sessions.down.sql
|
||||
channels/db/migrations/postgres/000041_create_upload_sessions.up.sql
|
||||
channels/db/migrations/postgres/000042_create_threads.down.sql
|
||||
channels/db/migrations/postgres/000042_create_threads.up.sql
|
||||
channels/db/migrations/postgres/000043_thread_memberships.down.sql
|
||||
channels/db/migrations/postgres/000043_thread_memberships.up.sql
|
||||
channels/db/migrations/postgres/000044_create_user_terms_of_service.down.sql
|
||||
channels/db/migrations/postgres/000044_create_user_terms_of_service.up.sql
|
||||
channels/db/migrations/postgres/000045_create_plugin_key_value_store.down.sql
|
||||
channels/db/migrations/postgres/000045_create_plugin_key_value_store.up.sql
|
||||
channels/db/migrations/postgres/000046_create_users.down.sql
|
||||
channels/db/migrations/postgres/000046_create_users.up.sql
|
||||
channels/db/migrations/postgres/000047_create_file_info.down.sql
|
||||
channels/db/migrations/postgres/000047_create_file_info.up.sql
|
||||
channels/db/migrations/postgres/000048_create_oauth_apps.down.sql
|
||||
channels/db/migrations/postgres/000048_create_oauth_apps.up.sql
|
||||
channels/db/migrations/postgres/000049_create_channels.down.sql
|
||||
channels/db/migrations/postgres/000049_create_channels.up.sql
|
||||
channels/db/migrations/postgres/000050_create_channelmembers.down.sql
|
||||
channels/db/migrations/postgres/000050_create_channelmembers.up.sql
|
||||
channels/db/migrations/postgres/000051_create_msg_root_count.down.sql
|
||||
channels/db/migrations/postgres/000051_create_msg_root_count.up.sql
|
||||
channels/db/migrations/postgres/000052_create_public_channels.down.sql
|
||||
channels/db/migrations/postgres/000052_create_public_channels.up.sql
|
||||
channels/db/migrations/postgres/000053_create_retention_policies.down.sql
|
||||
channels/db/migrations/postgres/000053_create_retention_policies.up.sql
|
||||
channels/db/migrations/postgres/000054_create_crt_channelmembership_count.down.sql
|
||||
channels/db/migrations/postgres/000054_create_crt_channelmembership_count.up.sql
|
||||
channels/db/migrations/postgres/000055_create_crt_thread_count_and_unreads.down.sql
|
||||
channels/db/migrations/postgres/000055_create_crt_thread_count_and_unreads.up.sql
|
||||
channels/db/migrations/postgres/000056_upgrade_channels_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000056_upgrade_channels_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000057_upgrade_command_webhooks_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000057_upgrade_command_webhooks_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000058_upgrade_channelmembers_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000058_upgrade_channelmembers_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000059_upgrade_users_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000059_upgrade_users_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000060_upgrade_jobs_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000060_upgrade_jobs_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000061_upgrade_link_metadata_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000061_upgrade_link_metadata_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000062_upgrade_sessions_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000062_upgrade_sessions_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000063_upgrade_threads_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000063_upgrade_threads_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000064_upgrade_status_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000064_upgrade_status_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000065_upgrade_groupchannels_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000065_upgrade_groupchannels_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000066_upgrade_posts_v6.0.down.sql
|
||||
channels/db/migrations/postgres/000066_upgrade_posts_v6.0.up.sql
|
||||
channels/db/migrations/postgres/000067_upgrade_channelmembers_v6.1.down.sql
|
||||
channels/db/migrations/postgres/000067_upgrade_channelmembers_v6.1.up.sql
|
||||
channels/db/migrations/postgres/000068_upgrade_teammembers_v6.1.down.sql
|
||||
channels/db/migrations/postgres/000068_upgrade_teammembers_v6.1.up.sql
|
||||
channels/db/migrations/postgres/000069_upgrade_jobs_v6.1.down.sql
|
||||
channels/db/migrations/postgres/000069_upgrade_jobs_v6.1.up.sql
|
||||
channels/db/migrations/postgres/000070_upgrade_cte_v6.1.down.sql
|
||||
channels/db/migrations/postgres/000070_upgrade_cte_v6.1.up.sql
|
||||
channels/db/migrations/postgres/000071_upgrade_sessions_v6.1.down.sql
|
||||
channels/db/migrations/postgres/000071_upgrade_sessions_v6.1.up.sql
|
||||
channels/db/migrations/postgres/000072_upgrade_schemes_v6.3.down.sql
|
||||
channels/db/migrations/postgres/000072_upgrade_schemes_v6.3.up.sql
|
||||
channels/db/migrations/postgres/000073_upgrade_plugin_key_value_store_v6.3.down.sql
|
||||
channels/db/migrations/postgres/000073_upgrade_plugin_key_value_store_v6.3.up.sql
|
||||
channels/db/migrations/postgres/000074_upgrade_users_v6.3.down.sql
|
||||
channels/db/migrations/postgres/000074_upgrade_users_v6.3.up.sql
|
||||
channels/db/migrations/postgres/000075_alter_upload_sessions_index.down.sql
|
||||
channels/db/migrations/postgres/000075_alter_upload_sessions_index.up.sql
|
||||
channels/db/migrations/postgres/000076_upgrade_lastrootpostat.down.sql
|
||||
channels/db/migrations/postgres/000076_upgrade_lastrootpostat.up.sql
|
||||
channels/db/migrations/postgres/000077_upgrade_users_v6.5.down.sql
|
||||
channels/db/migrations/postgres/000077_upgrade_users_v6.5.up.sql
|
||||
channels/db/migrations/postgres/000078_create_oauth_mattermost_app_id.down.sql
|
||||
channels/db/migrations/postgres/000078_create_oauth_mattermost_app_id.up.sql
|
||||
channels/db/migrations/postgres/000079_usergroups_displayname_index.down.sql
|
||||
channels/db/migrations/postgres/000079_usergroups_displayname_index.up.sql
|
||||
channels/db/migrations/postgres/000080_posts_createat_id.down.sql
|
||||
channels/db/migrations/postgres/000080_posts_createat_id.up.sql
|
||||
channels/db/migrations/postgres/000081_threads_deleteat.down.sql
|
||||
channels/db/migrations/postgres/000081_threads_deleteat.up.sql
|
||||
channels/db/migrations/postgres/000082_upgrade_oauth_mattermost_app_id.down.sql
|
||||
channels/db/migrations/postgres/000082_upgrade_oauth_mattermost_app_id.up.sql
|
||||
channels/db/migrations/postgres/000083_threads_threaddeleteat.down.sql
|
||||
channels/db/migrations/postgres/000083_threads_threaddeleteat.up.sql
|
||||
channels/db/migrations/postgres/000084_recent_searches.down.sql
|
||||
channels/db/migrations/postgres/000084_recent_searches.up.sql
|
||||
channels/db/migrations/postgres/000085_fileinfo_add_archived_column.down.sql
|
||||
channels/db/migrations/postgres/000085_fileinfo_add_archived_column.up.sql
|
||||
channels/db/migrations/postgres/000086_add_cloud_limits_archived.down.sql
|
||||
channels/db/migrations/postgres/000086_add_cloud_limits_archived.up.sql
|
||||
channels/db/migrations/postgres/000087_sidebar_categories_index.down.sql
|
||||
channels/db/migrations/postgres/000087_sidebar_categories_index.up.sql
|
||||
channels/db/migrations/postgres/000088_remaining_migrations.down.sql
|
||||
channels/db/migrations/postgres/000088_remaining_migrations.up.sql
|
||||
channels/db/migrations/postgres/000089_add-channelid-to-reaction.down.sql
|
||||
channels/db/migrations/postgres/000089_add-channelid-to-reaction.up.sql
|
||||
channels/db/migrations/postgres/000090_create_enums.down.sql
|
||||
channels/db/migrations/postgres/000090_create_enums.up.sql
|
||||
channels/db/migrations/postgres/000091_create_post_reminder.down.sql
|
||||
channels/db/migrations/postgres/000091_create_post_reminder.up.sql
|
||||
channels/db/migrations/postgres/000092_add_createat_to_teamembers.down.sql
|
||||
channels/db/migrations/postgres/000092_add_createat_to_teamembers.up.sql
|
||||
channels/db/migrations/postgres/000093_notify_admin.down.sql
|
||||
channels/db/migrations/postgres/000093_notify_admin.up.sql
|
||||
channels/db/migrations/postgres/000094_threads_teamid.down.sql
|
||||
channels/db/migrations/postgres/000094_threads_teamid.up.sql
|
||||
channels/db/migrations/postgres/000095_remove_posts_parentid.down.sql
|
||||
channels/db/migrations/postgres/000095_remove_posts_parentid.up.sql
|
||||
channels/db/migrations/postgres/000096_threads_threadteamid.down.sql
|
||||
channels/db/migrations/postgres/000096_threads_threadteamid.up.sql
|
||||
channels/db/migrations/postgres/000097_create_posts_priority.down.sql
|
||||
channels/db/migrations/postgres/000097_create_posts_priority.up.sql
|
||||
channels/db/migrations/postgres/000098_create_post_acknowledgements.down.sql
|
||||
channels/db/migrations/postgres/000098_create_post_acknowledgements.up.sql
|
||||
channels/db/migrations/postgres/000099_create_drafts.down.sql
|
||||
channels/db/migrations/postgres/000099_create_drafts.up.sql
|
||||
channels/db/migrations/postgres/000100_add_draft_priority_column.down.sql
|
||||
channels/db/migrations/postgres/000100_add_draft_priority_column.up.sql
|
||||
channels/db/migrations/postgres/000101_create_true_up_review_history.down.sql
|
||||
channels/db/migrations/postgres/000101_create_true_up_review_history.up.sql
|
||||
channels/db/migrations/postgres/000102_posts_originalid_index.down.sql
|
||||
channels/db/migrations/postgres/000102_posts_originalid_index.up.sql
|
||||
channels/db/migrations/postgres/000103_add_sentat_to_notifyadmin.down.sql
|
||||
channels/db/migrations/postgres/000103_add_sentat_to_notifyadmin.up.sql
|
||||
channels/db/migrations/postgres/000104_upgrade_notifyadmin.down.sql
|
||||
channels/db/migrations/postgres/000104_upgrade_notifyadmin.up.sql
|
||||
channels/db/migrations/postgres/000105_remove_tokens.down.sql
|
||||
channels/db/migrations/postgres/000105_remove_tokens.up.sql
|
||||
channels/db/migrations/postgres/000106_fileinfo_channelid.down.sql
|
||||
channels/db/migrations/postgres/000106_fileinfo_channelid.up.sql
|
||||
channels/db/migrations/postgres/000107_threadmemberships_cleanup.down.sql
|
||||
channels/db/migrations/postgres/000107_threadmemberships_cleanup.up.sql
|
||||
channels/db/migrations/postgres/000108_remove_orphaned_oauth_preferences.down.sql
|
||||
channels/db/migrations/postgres/000108_remove_orphaned_oauth_preferences.up.sql
|
||||
channels/db/migrations/postgres/000109_create_persistent_notifications.down.sql
|
||||
channels/db/migrations/postgres/000109_create_persistent_notifications.up.sql
|
||||
channels/db/migrations/postgres/000111_update_vacuuming.down.sql
|
||||
channels/db/migrations/postgres/000111_update_vacuuming.up.sql
|
||||
channels/db/migrations/postgres/000112_rework_desktop_tokens.down.sql
|
||||
channels/db/migrations/postgres/000112_rework_desktop_tokens.up.sql
|
||||
channels/db/migrations/postgres/000113_create_retentionidsfordeletion_table.down.sql
|
||||
channels/db/migrations/postgres/000113_create_retentionidsfordeletion_table.up.sql
|
||||
channels/db/migrations/postgres/000114_sharedchannelremotes_drop_nextsyncat_description.down.sql
|
||||
channels/db/migrations/postgres/000114_sharedchannelremotes_drop_nextsyncat_description.up.sql
|
||||
channels/db/migrations/postgres/000115_user_reporting_changes.down.sql
|
||||
channels/db/migrations/postgres/000115_user_reporting_changes.up.sql
|
||||
channels/db/migrations/postgres/000116_create_outgoing_oauth_connections.down.sql
|
||||
channels/db/migrations/postgres/000116_create_outgoing_oauth_connections.up.sql
|
||||
channels/db/migrations/postgres/000117_msteams_shared_channels.down.sql
|
||||
channels/db/migrations/postgres/000117_msteams_shared_channels.up.sql
|
||||
channels/db/migrations/postgres/000118_create_index_poststats.down.sql
|
||||
channels/db/migrations/postgres/000118_create_index_poststats.up.sql
|
||||
channels/db/migrations/postgres/000119_msteams_shared_channels_opts.down.sql
|
||||
channels/db/migrations/postgres/000119_msteams_shared_channels_opts.up.sql
|
||||
channels/db/migrations/postgres/000120_create_channelbookmarks_table.down.sql
|
||||
channels/db/migrations/postgres/000120_create_channelbookmarks_table.up.sql
|
||||
channels/db/migrations/postgres/000121_remove_true_up_review_history.down.sql
|
||||
channels/db/migrations/postgres/000121_remove_true_up_review_history.up.sql
|
||||
channels/db/migrations/postgres/000122_preferences_value_length.down.sql
|
||||
channels/db/migrations/postgres/000122_preferences_value_length.up.sql
|
||||
channels/db/migrations/postgres/000123_remove_upload_file_permission.down.sql
|
||||
channels/db/migrations/postgres/000123_remove_upload_file_permission.up.sql
|
||||
channels/db/migrations/postgres/000124_remove_manage_team_permission.down.sql
|
||||
channels/db/migrations/postgres/000124_remove_manage_team_permission.up.sql
|
||||
channels/db/migrations/postgres/000125_remoteclusters_add_default_team_id.down.sql
|
||||
channels/db/migrations/postgres/000125_remoteclusters_add_default_team_id.up.sql
|
||||
channels/db/migrations/postgres/000126_sharedchannels_remotes_add_deleteat.down.sql
|
||||
channels/db/migrations/postgres/000126_sharedchannels_remotes_add_deleteat.up.sql
|
||||
channels/db/migrations/postgres/000127_add_mfa_used_ts_to_users.down.sql
|
||||
channels/db/migrations/postgres/000127_add_mfa_used_ts_to_users.up.sql
|
||||
channels/db/migrations/postgres/000128_create_scheduled_posts.down.sql
|
||||
channels/db/migrations/postgres/000128_create_scheduled_posts.up.sql
|
||||
channels/db/migrations/postgres/000129_add_property_system_architecture.down.sql
|
||||
channels/db/migrations/postgres/000129_add_property_system_architecture.up.sql
|
||||
channels/db/migrations/postgres/000130_system_console_stats.down.sql
|
||||
channels/db/migrations/postgres/000130_system_console_stats.up.sql
|
||||
channels/db/migrations/postgres/000131_create_index_pagination_on_property_values.down.sql
|
||||
channels/db/migrations/postgres/000131_create_index_pagination_on_property_values.up.sql
|
||||
channels/db/migrations/postgres/000132_create_index_pagination_on_property_fields.down.sql
|
||||
channels/db/migrations/postgres/000132_create_index_pagination_on_property_fields.up.sql
|
||||
channels/db/migrations/postgres/000133_add_channel_banner_fields.down.sql
|
||||
channels/db/migrations/postgres/000133_add_channel_banner_fields.up.sql
|
||||
channels/db/migrations/postgres/000134_create_access_control_policies.down.sql
|
||||
channels/db/migrations/postgres/000134_create_access_control_policies.up.sql
|
||||
channels/db/migrations/postgres/000135_sidebarchannels_categoryid.down.sql
|
||||
channels/db/migrations/postgres/000135_sidebarchannels_categoryid.up.sql
|
||||
channels/db/migrations/postgres/000136_create_attribute_view.down.sql
|
||||
channels/db/migrations/postgres/000136_create_attribute_view.up.sql
|
||||
channels/db/migrations/postgres/000137_update_attribute_view.down.sql
|
||||
channels/db/migrations/postgres/000137_update_attribute_view.up.sql
|
||||
channels/db/migrations/postgres/000138_add_default_category_name_to_channel.down.sql
|
||||
channels/db/migrations/postgres/000138_add_default_category_name_to_channel.up.sql
|
||||
channels/db/migrations/postgres/000139_remoteclusters_add_last_global_user_sync_at.down.sql
|
||||
channels/db/migrations/postgres/000139_remoteclusters_add_last_global_user_sync_at.up.sql
|
||||
channels/db/migrations/postgres/000140_add_lastmemberssyncat_to_sharedchannelremotes.down.sql
|
||||
channels/db/migrations/postgres/000140_add_lastmemberssyncat_to_sharedchannelremotes.up.sql
|
||||
channels/db/migrations/postgres/000141_add_remoteid_channelid_to_post_acknowledgements.down.sql
|
||||
channels/db/migrations/postgres/000141_add_remoteid_channelid_to_post_acknowledgements.up.sql
|
||||
channels/db/migrations/postgres/000142_create_content_flagging_tables.down.sql
|
||||
channels/db/migrations/postgres/000142_create_content_flagging_tables.up.sql
|
||||
channels/db/migrations/postgres/000143_content_flagging_table_index.down.sql
|
||||
channels/db/migrations/postgres/000143_content_flagging_table_index.up.sql
|
||||
channels/db/migrations/postgres/000144_add_dcr_fields_to_oauth_apps.down.sql
|
||||
channels/db/migrations/postgres/000144_add_dcr_fields_to_oauth_apps.up.sql
|
||||
channels/db/migrations/postgres/000145_add_pkce_to_oauthauthdata.down.sql
|
||||
channels/db/migrations/postgres/000145_add_pkce_to_oauthauthdata.up.sql
|
||||
channels/db/migrations/postgres/000146_add_audience_and_resource_to_oauth.down.sql
|
||||
channels/db/migrations/postgres/000146_add_audience_and_resource_to_oauth.up.sql
|
||||
channels/db/migrations/postgres/000147_create_autotranslation_tables.down.sql
|
||||
channels/db/migrations/postgres/000147_create_autotranslation_tables.up.sql
|
||||
channels/db/migrations/postgres/000148_add_burn_on_read_messages.down.sql
|
||||
channels/db/migrations/postgres/000148_add_burn_on_read_messages.up.sql
|
||||
channels/db/migrations/postgres/000149_create_recaps.down.sql
|
||||
channels/db/migrations/postgres/000149_create_recaps.up.sql
|
||||
channels/db/migrations/postgres/000150_add_translation_state.down.sql
|
||||
channels/db/migrations/postgres/000150_add_translation_state.up.sql
|
||||
channels/db/migrations/postgres/000151_add_autotranslationdisabled_to_channelmembers.down.sql
|
||||
channels/db/migrations/postgres/000151_add_autotranslationdisabled_to_channelmembers.up.sql
|
||||
channels/db/migrations/postgres/000152_translations_primary_key_change.down.sql
|
||||
channels/db/migrations/postgres/000152_translations_primary_key_change.up.sql
|
||||
channels/db/migrations/postgres/000153_add_translation_channel_id.down.sql
|
||||
channels/db/migrations/postgres/000153_add_translation_channel_id.up.sql
|
||||
channels/db/migrations/postgres/000154_drop_translation_updateat_index.down.sql
|
||||
channels/db/migrations/postgres/000154_drop_translation_updateat_index.up.sql
|
||||
channels/db/migrations/postgres/000155_create_translation_channel_updateat_index.down.sql
|
||||
channels/db/migrations/postgres/000155_create_translation_channel_updateat_index.up.sql
|
||||
channels/db/migrations/postgres/000156_add_schemeid_to_roles.down.sql
|
||||
channels/db/migrations/postgres/000156_add_schemeid_to_roles.up.sql
|
||||
channels/db/migrations/postgres/000157_backfill_roles_schemeid.down.sql
|
||||
channels/db/migrations/postgres/000157_backfill_roles_schemeid.up.sql
|
||||
channels/db/migrations/postgres/000158_add_roles_schemeid_index.down.sql
|
||||
channels/db/migrations/postgres/000158_add_roles_schemeid_index.up.sql
|
||||
channels/db/migrations/postgres/000159_deduplicate_policy_names.down.sql
|
||||
channels/db/migrations/postgres/000159_deduplicate_policy_names.up.sql
|
||||
channels/db/migrations/postgres/000160_add_user_tracking_to_properties.down.sql
|
||||
channels/db/migrations/postgres/000160_add_user_tracking_to_properties.up.sql
|
||||
channels/db/migrations/postgres/000161_add_object_type_to_property_fields.down.sql
|
||||
channels/db/migrations/postgres/000161_add_object_type_to_property_fields.up.sql
|
||||
channels/db/migrations/postgres/000162_drop_property_fields_old_unique_index.down.sql
|
||||
channels/db/migrations/postgres/000162_drop_property_fields_old_unique_index.up.sql
|
||||
channels/db/migrations/postgres/000163_create_property_fields_legacy_index.down.sql
|
||||
channels/db/migrations/postgres/000163_create_property_fields_legacy_index.up.sql
|
||||
channels/db/migrations/postgres/000164_create_property_fields_typed_index.down.sql
|
||||
channels/db/migrations/postgres/000164_create_property_fields_typed_index.up.sql
|
||||
channels/db/migrations/postgres/000165_add_protected_and_permissions_to_property_fields.down.sql
|
||||
channels/db/migrations/postgres/000165_add_protected_and_permissions_to_property_fields.up.sql
|
||||
channels/db/migrations/postgres/000166_create_views.down.sql
|
||||
channels/db/migrations/postgres/000166_create_views.up.sql
|
||||
channels/db/migrations/postgres/000167_create_views_channel_id_delete_at_index.down.sql
|
||||
channels/db/migrations/postgres/000167_create_views_channel_id_delete_at_index.up.sql
|
||||
channels/db/migrations/postgres/000168_add_linked_field_id_to_property_fields.down.sql
|
||||
channels/db/migrations/postgres/000168_add_linked_field_id_to_property_fields.up.sql
|
||||
channels/db/migrations/postgres/000169_create_linked_field_id_index.down.sql
|
||||
channels/db/migrations/postgres/000169_create_linked_field_id_index.up.sql
|
||||
channels/db/migrations/postgres/000170_add_property_groups_version.down.sql
|
||||
channels/db/migrations/postgres/000170_add_property_groups_version.up.sql
|
||||
channels/db/migrations/postgres/000171_drop_property_fields_protected_index.down.sql
|
||||
channels/db/migrations/postgres/000171_drop_property_fields_protected_index.up.sql
|
||||
channels/db/migrations/postgres/000172_add_recaps_viewed_at.down.sql
|
||||
channels/db/migrations/postgres/000172_add_recaps_viewed_at.up.sql
|
||||
channels/db/migrations/postgres/000173_create_recaps_user_id_viewed_at_index.down.sql
|
||||
channels/db/migrations/postgres/000173_create_recaps_user_id_viewed_at_index.up.sql
|
||||
channels/db/migrations/postgres/000174_set_posts_statistics_targets.down.sql
|
||||
channels/db/migrations/postgres/000174_set_posts_statistics_targets.up.sql
|
||||
channels/db/migrations/postgres/000175_add_board_channel_types.down.sql
|
||||
channels/db/migrations/postgres/000175_add_board_channel_types.up.sql
|
||||
channels/db/migrations/postgres/000176_migrate_cpa_to_access_control.down.sql
|
||||
channels/db/migrations/postgres/000176_migrate_cpa_to_access_control.up.sql
|
||||
channels/db/migrations/postgres/000177_filter_attribute_view_by_object_type.down.sql
|
||||
channels/db/migrations/postgres/000177_filter_attribute_view_by_object_type.up.sql
|
||||
channels/db/migrations/postgres/000178_add_discoverable_to_channels.down.sql
|
||||
channels/db/migrations/postgres/000178_add_discoverable_to_channels.up.sql
|
||||
channels/db/migrations/postgres/000179_add_channels_discoverable_index.down.sql
|
||||
channels/db/migrations/postgres/000179_add_channels_discoverable_index.up.sql
|
||||
channels/db/migrations/postgres/000180_create_channel_join_requests.down.sql
|
||||
channels/db/migrations/postgres/000180_create_channel_join_requests.up.sql
|
||||
channels/db/migrations/postgres/000181_create_channel_join_requests_pending_unique_index.down.sql
|
||||
channels/db/migrations/postgres/000181_create_channel_join_requests_pending_unique_index.up.sql
|
||||
channels/db/migrations/postgres/000182_create_channel_join_requests_channel_status_index.down.sql
|
||||
channels/db/migrations/postgres/000182_create_channel_join_requests_channel_status_index.up.sql
|
||||
channels/db/migrations/postgres/000183_create_channel_join_requests_user_status_index.down.sql
|
||||
channels/db/migrations/postgres/000183_create_channel_join_requests_user_status_index.up.sql
|
||||
channels/db/migrations/postgres/000184_add_admin_to_permission_level.down.sql
|
||||
channels/db/migrations/postgres/000184_add_admin_to_permission_level.up.sql
|
||||
channels/db/migrations/postgres/000185_create_channel_guards.down.sql
|
||||
channels/db/migrations/postgres/000185_create_channel_guards.up.sql
|
||||
channels/db/migrations/postgres/000186_create_channel_guards_plugin_id_index.down.sql
|
||||
channels/db/migrations/postgres/000186_create_channel_guards_plugin_id_index.up.sql
|
||||
channels/db/migrations/postgres/000187_add_expiresat_to_user_access_tokens.down.sql
|
||||
channels/db/migrations/postgres/000187_add_expiresat_to_user_access_tokens.up.sql
|
||||
channels/db/migrations/postgres/000188_add_expiresat_index_to_user_access_tokens.down.sql
|
||||
channels/db/migrations/postgres/000188_add_expiresat_index_to_user_access_tokens.up.sql
|
||||
channels/db/migrations/postgres/000190_channel_bookmarks_board_target_id.down.sql
|
||||
channels/db/migrations/postgres/000190_channel_bookmarks_board_target_id.up.sql
|
||||
channels/db/migrations/postgres/000191_channel_bookmarks_target_id_index.down.sql
|
||||
channels/db/migrations/postgres/000191_channel_bookmarks_target_id_index.up.sql
|
||||
channels/db/migrations/postgres/000192_add_voip_device_id_to_sessions.down.sql
|
||||
channels/db/migrations/postgres/000192_add_voip_device_id_to_sessions.up.sql
|
||||
channels/db/migrations/postgres/000193_add_property_groups_schema_version.down.sql
|
||||
channels/db/migrations/postgres/000193_add_property_groups_schema_version.up.sql
|
||||
channels/db/migrations/postgres/000194_add_type_id_index_to_access_control_policies.down.sql
|
||||
channels/db/migrations/postgres/000194_add_type_id_index_to_access_control_policies.up.sql
|
||||
channels/db/migrations/postgres/000195_threadmemberships_cleanup_v2.down.sql
|
||||
channels/db/migrations/postgres/000195_threadmemberships_cleanup_v2.up.sql
|
||||
channels/db/migrations/postgres/000196_add_lastused_to_incoming_webhooks.down.sql
|
||||
channels/db/migrations/postgres/000196_add_lastused_to_incoming_webhooks.up.sql
|
||||
channels/db/migrations/postgres/000197_add_rank_to_property_field_type.down.sql
|
||||
channels/db/migrations/postgres/000197_add_rank_to_property_field_type.up.sql
|
||||
channels/db/migrations/postgres/000198_convert_classification_fields_to_rank.down.sql
|
||||
channels/db/migrations/postgres/000198_convert_classification_fields_to_rank.up.sql
|
||||
channels/db/migrations/postgres/000199_rename_classification_linked_fields.down.sql
|
||||
channels/db/migrations/postgres/000199_rename_classification_linked_fields.up.sql
|
||||
channels/db/migrations/postgres/000200_add_rank_to_attribute_view.down.sql
|
||||
channels/db/migrations/postgres/000200_add_rank_to_attribute_view.up.sql
|
||||
channels/db/migrations/postgres/000201_create_property_fields_groupid_updateat_id_index.down.sql
|
||||
channels/db/migrations/postgres/000201_create_property_fields_groupid_updateat_id_index.up.sql
|
||||
channels/db/migrations/postgres/000202_create_property_values_groupid_updateat_id_index.down.sql
|
||||
channels/db/migrations/postgres/000202_create_property_values_groupid_updateat_id_index.up.sql
|
||||
channels/db/migrations/postgres/000203_add_lastnotifiedat_to_user_access_tokens.down.sql
|
||||
channels/db/migrations/postgres/000203_add_lastnotifiedat_to_user_access_tokens.up.sql
|
||||
channels/db/migrations/postgres/000204_add_channel_type_space_enum.down.sql
|
||||
channels/db/migrations/postgres/000204_add_channel_type_space_enum.up.sql
|
||||
channels/db/migrations/postgres/000205_create_scheduled_recaps.down.sql
|
||||
channels/db/migrations/postgres/000205_create_scheduled_recaps.up.sql
|
||||
channels/db/migrations/postgres/000206_create_scheduled_recaps_user_id_index.down.sql
|
||||
channels/db/migrations/postgres/000206_create_scheduled_recaps_user_id_index.up.sql
|
||||
channels/db/migrations/postgres/000207_create_scheduled_recaps_next_run_at_index.down.sql
|
||||
channels/db/migrations/postgres/000207_create_scheduled_recaps_next_run_at_index.up.sql
|
||||
channels/db/migrations/postgres/000208_create_scheduled_recaps_enabled_next_run_index.down.sql
|
||||
channels/db/migrations/postgres/000208_create_scheduled_recaps_enabled_next_run_index.up.sql
|
||||
channels/db/migrations/postgres/000209_create_scheduled_recaps_user_delete_index.down.sql
|
||||
channels/db/migrations/postgres/000209_create_scheduled_recaps_user_delete_index.up.sql
|
||||
channels/db/migrations/postgres/000210_add_recap_skip_fields.down.sql
|
||||
channels/db/migrations/postgres/000210_add_recap_skip_fields.up.sql
|
||||
channels/db/migrations/postgres/000211_add_recaps_scheduled_recap_id_index.down.sql
|
||||
channels/db/migrations/postgres/000211_add_recaps_scheduled_recap_id_index.up.sql
|
||||
channels/db/migrations/postgres/000212_add_scheduled_post_recurrence.down.sql
|
||||
channels/db/migrations/postgres/000212_add_scheduled_post_recurrence.up.sql
|
||||
channels/db/migrations/postgres/000213_add_scheduled_post_pending_index.down.sql
|
||||
channels/db/migrations/postgres/000213_add_scheduled_post_pending_index.up.sql
|
||||
channels/db/migrations/postgres/000214_drop_channelmembers_autotranslation.down.sql
|
||||
channels/db/migrations/postgres/000214_drop_channelmembers_autotranslation.up.sql
|
||||
channels/db/migrations/postgres/000215_drop_channelmembers_autotranslation_column.down.sql
|
||||
channels/db/migrations/postgres/000215_drop_channelmembers_autotranslation_column.up.sql
|
||||
channels/db/migrations/postgres/000216_split_attribute_view_by_object_type.down.sql
|
||||
channels/db/migrations/postgres/000216_split_attribute_view_by_object_type.up.sql
|
||||
channels/db/migrations/postgres/000217_resize_message_columns.down.sql
|
||||
channels/db/migrations/postgres/000217_resize_message_columns.up.sql
|
||||
channels/db/migrations/postgres/000218_create_post_delivery_tracking_channels.down.sql
|
||||
channels/db/migrations/postgres/000218_create_post_delivery_tracking_channels.up.sql
|
||||
channels/db/migrations/postgres/000219_add_fileinfo_createat_id_index.down.sql
|
||||
channels/db/migrations/postgres/000219_add_fileinfo_createat_id_index.up.sql
|
||||
channels/db/migrations/postgres/000220_add_channels_createat_id_index.down.sql
|
||||
channels/db/migrations/postgres/000220_add_channels_createat_id_index.up.sql
|
||||
channels/db/migrations/postgres/000221_add_disable_join_leave_messages_to_channels.down.sql
|
||||
channels/db/migrations/postgres/000221_add_disable_join_leave_messages_to_channels.up.sql
|
||||
@@ -0,0 +1,14 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_teams_name ON teams (name);
|
||||
|
||||
ALTER TABLE teams DROP COLUMN IF EXISTS allowopeninvite;
|
||||
ALTER TABLE teams DROP COLUMN IF EXISTS lastteamiconupdate;
|
||||
ALTER TABLE teams DROP COLUMN IF EXISTS description;
|
||||
ALTER TABLE teams DROP COLUMN IF EXISTS groupconstrained;
|
||||
|
||||
DROP INDEX IF EXISTS idx_teams_invite_id;
|
||||
DROP INDEX IF EXISTS idx_teams_update_at;
|
||||
DROP INDEX IF EXISTS idx_teams_create_at;
|
||||
DROP INDEX IF EXISTS idx_teams_delete_at;
|
||||
DROP INDEX IF EXISTS idx_teams_scheme_id;
|
||||
|
||||
DROP TABLE IF EXISTS teams;
|
||||
@@ -0,0 +1,89 @@
|
||||
CREATE TABLE IF NOT EXISTS teams (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
deleteat bigint,
|
||||
displayname VARCHAR(64),
|
||||
name VARCHAR(64),
|
||||
description VARCHAR(255),
|
||||
email VARCHAR(128),
|
||||
type VARCHAR(255),
|
||||
companyname VARCHAR(64),
|
||||
alloweddomains VARCHAR(1000),
|
||||
inviteid VARCHAR(32),
|
||||
schemeid VARCHAR(26),
|
||||
UNIQUE(name)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_teams_invite_id ON teams (inviteid);
|
||||
CREATE INDEX IF NOT EXISTS idx_teams_update_at ON teams (updateat);
|
||||
CREATE INDEX IF NOT EXISTS idx_teams_create_at ON teams (createat);
|
||||
CREATE INDEX IF NOT EXISTS idx_teams_delete_at ON teams (deleteat);
|
||||
CREATE INDEX IF NOT EXISTS idx_teams_scheme_id ON teams (schemeid);
|
||||
|
||||
ALTER TABLE teams ADD COLUMN IF NOT EXISTS allowopeninvite boolean;
|
||||
ALTER TABLE teams ADD COLUMN IF NOT EXISTS lastteamiconupdate bigint;
|
||||
ALTER TABLE teams ADD COLUMN IF NOT EXISTS description VARCHAR(255);
|
||||
ALTER TABLE teams ADD COLUMN IF NOT EXISTS groupconstrained boolean;
|
||||
|
||||
DROP INDEX IF EXISTS idx_teams_name;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
column_exist boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO column_exist
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'teams'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'alloweddomains'
|
||||
AND NOT data_type = 'varchar(1000)';
|
||||
IF column_exist THEN
|
||||
ALTER TABLE teams ALTER COLUMN alloweddomains TYPE VARCHAR(1000);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
column_exist boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO column_exist
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'teams'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'groupconstrained'
|
||||
AND NOT data_type = 'boolean';
|
||||
IF column_exist THEN
|
||||
ALTER TABLE teams ALTER COLUMN groupconstrained TYPE boolean;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
column_exist boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO column_exist
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'teams'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'type'
|
||||
AND NOT data_type = 'varchar(255)';
|
||||
IF column_exist THEN
|
||||
ALTER TABLE teams ALTER COLUMN type TYPE VARCHAR(255);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
column_exist boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO column_exist
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'teams'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'schemeid'
|
||||
AND NOT data_type = 'varchar(26)';
|
||||
IF column_exist THEN
|
||||
ALTER TABLE teams ALTER COLUMN schemeid TYPE varchar(26);
|
||||
END IF;
|
||||
END $$;
|
||||
@@ -0,0 +1,11 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_teammembers_team_id ON teammembers (teamid);
|
||||
|
||||
ALTER TABLE teammembers DROP COLUMN IF EXISTS schemeuser;
|
||||
ALTER TABLE teammembers DROP COLUMN IF EXISTS schemeadmin;
|
||||
ALTER TABLE teammembers DROP COLUMN IF EXISTS schemeguest;
|
||||
ALTER TABLE teammembers DROP COLUMN IF EXISTS deleteat;
|
||||
|
||||
DROP INDEX IF EXISTS idx_teammembers_user_id;
|
||||
DROP INDEX IF EXISTS idx_teammembers_delete_at;
|
||||
|
||||
DROP TABLE IF EXISTS teammembers;
|
||||
@@ -0,0 +1,17 @@
|
||||
CREATE TABLE IF NOT EXISTS teammembers (
|
||||
teamid VARCHAR(26) NOT NULL,
|
||||
userid VARCHAR(26) NOT NULL,
|
||||
roles VARCHAR(64),
|
||||
deleteat bigint,
|
||||
PRIMARY KEY (teamid, userid)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_teammembers_user_id ON TeamMembers (userid);
|
||||
CREATE INDEX IF NOT EXISTS idx_teammembers_delete_at ON TeamMembers (deleteat);
|
||||
|
||||
ALTER TABLE teammembers ADD COLUMN IF NOT EXISTS schemeuser boolean;
|
||||
ALTER TABLE teammembers ADD COLUMN IF NOT EXISTS schemeadmin boolean;
|
||||
ALTER TABLE teammembers ADD COLUMN IF NOT EXISTS schemeguest boolean;
|
||||
ALTER TABLE teammembers ADD COLUMN IF NOT EXISTS deleteat bigint;
|
||||
|
||||
DROP INDEX IF EXISTS idx_teammembers_team_id;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS clusterdiscovery;
|
||||
@@ -0,0 +1,10 @@
|
||||
CREATE TABLE IF NOT EXISTS clusterdiscovery (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
type VARCHAR(64),
|
||||
clustername VARCHAR(64),
|
||||
hostname VARCHAR(512),
|
||||
gossipport integer,
|
||||
port integer,
|
||||
createat bigint,
|
||||
lastpingat bigint
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS commandwebhooks;
|
||||
@@ -0,0 +1,12 @@
|
||||
CREATE TABLE IF NOT EXISTS commandwebhooks (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
createat bigint,
|
||||
commandid VARCHAR(26),
|
||||
userid VARCHAR(26),
|
||||
channelid VARCHAR(26),
|
||||
rootid VARCHAR(26),
|
||||
parentid VARCHAR(26),
|
||||
usecount integer
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_command_webhook_create_at ON commandwebhooks (createat);
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS compliances;
|
||||
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE IF NOT EXISTS compliances (
|
||||
id VARCHAR(26) NOT NULL,
|
||||
createat bigint,
|
||||
userid VARCHAR(26),
|
||||
status VARCHAR(64),
|
||||
count integer,
|
||||
"desc" VARCHAR(512),
|
||||
type VARCHAR(64),
|
||||
startat bigint,
|
||||
endat bigint,
|
||||
keywords VARCHAR(512),
|
||||
emails VARCHAR(1024),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
@@ -0,0 +1,3 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_emoji_name ON emoji (name);
|
||||
|
||||
DROP TABLE IF EXISTS emoji;
|
||||
@@ -0,0 +1,17 @@
|
||||
CREATE TABLE IF NOT EXISTS emoji (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
deleteat bigint,
|
||||
creatorid VARCHAR(26),
|
||||
name VARCHAR(64),
|
||||
UNIQUE(name, deleteat)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_emoji_update_at ON emoji (updateat);
|
||||
CREATE INDEX IF NOT EXISTS idx_emoji_create_at ON emoji (createat);
|
||||
CREATE INDEX IF NOT EXISTS idx_emoji_delete_at ON emoji (deleteat);
|
||||
|
||||
DROP INDEX IF EXISTS Name_2;
|
||||
|
||||
DROP INDEX IF EXISTS idx_emoji_name;
|
||||
@@ -0,0 +1,3 @@
|
||||
DROP INDEX IF EXISTS idx_usergroups_remote_id;
|
||||
DROP INDEX IF EXISTS idx_usergroups_delete_at;
|
||||
DROP TABLE IF EXISTS usergroups;
|
||||
@@ -0,0 +1,18 @@
|
||||
CREATE TABLE IF NOT EXISTS usergroups (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
name VARCHAR(64),
|
||||
displayname VARCHAR(128),
|
||||
description VARCHAR(1024),
|
||||
source VARCHAR(64),
|
||||
remoteid VARCHAR(48),
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
deleteat bigint,
|
||||
allowreference bool,
|
||||
UNIQUE(name),
|
||||
UNIQUE(source, remoteid)
|
||||
);
|
||||
|
||||
ALTER TABLE usergroups ADD COLUMN IF NOT EXISTS allowreference bool;
|
||||
CREATE INDEX IF NOT EXISTS idx_usergroups_remote_id ON usergroups (remoteid);
|
||||
CREATE INDEX IF NOT EXISTS idx_usergroups_delete_at ON usergroups (deleteat);
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS groupmembers;
|
||||
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE IF NOT EXISTS groupmembers (
|
||||
groupid VARCHAR(26),
|
||||
userid VARCHAR(26),
|
||||
createat bigint,
|
||||
deleteat bigint,
|
||||
PRIMARY KEY(groupid, userid)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_groupmembers_create_at ON groupmembers (createat);
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS groupteams;
|
||||
@@ -0,0 +1,15 @@
|
||||
CREATE TABLE IF NOT EXISTS groupteams (
|
||||
groupid VARCHAR(26),
|
||||
autoadd boolean,
|
||||
schemeadmin boolean,
|
||||
createat bigint,
|
||||
deleteat bigint,
|
||||
updateat bigint,
|
||||
teamid VARCHAR(26),
|
||||
PRIMARY KEY(groupid, teamid)
|
||||
);
|
||||
|
||||
ALTER TABLE groupteams ADD COLUMN IF NOT EXISTS schemeadmin boolean default false;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_groupteams_schemeadmin ON groupteams (schemeadmin);
|
||||
CREATE INDEX IF NOT EXISTS idx_groupteams_teamid ON groupteams (teamid);
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS groupchannels;
|
||||
@@ -0,0 +1,15 @@
|
||||
CREATE TABLE IF NOT EXISTS groupchannels (
|
||||
groupid VARCHAR(26),
|
||||
autoadd boolean,
|
||||
schemeadmin boolean,
|
||||
createat bigint,
|
||||
deleteat bigint,
|
||||
updateat bigint,
|
||||
channelid VARCHAR(26),
|
||||
PRIMARY KEY(groupid, channelid)
|
||||
);
|
||||
|
||||
ALTER TABLE groupchannels ADD COLUMN IF NOT EXISTS schemeadmin boolean;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_groupteams_schemeadmin ON groupchannels (schemeadmin);
|
||||
CREATE INDEX IF NOT EXISTS idx_groupchannels_channelid ON groupchannels (channelid);
|
||||
@@ -0,0 +1,3 @@
|
||||
DROP INDEX IF EXISTS idx_link_metadata_url_timestamp;
|
||||
|
||||
DROP TABLE IF EXISTS linkmetadata;
|
||||
@@ -0,0 +1,10 @@
|
||||
CREATE TABLE IF NOT EXISTS linkmetadata (
|
||||
hash bigint NOT NULL,
|
||||
url VARCHAR(2048),
|
||||
"timestamp" bigint,
|
||||
type VARCHAR(16),
|
||||
data VARCHAR(4096),
|
||||
PRIMARY KEY (hash)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_link_metadata_url_timestamp ON linkmetadata (url, "timestamp");
|
||||
@@ -0,0 +1,8 @@
|
||||
DROP INDEX IF EXISTS idx_commands_team_id;
|
||||
DROP INDEX IF EXISTS idx_commands_update_at;
|
||||
DROP INDEX IF EXISTS idx_commands_create_at;
|
||||
DROP INDEX IF EXISTS idx_commands_delete_at;
|
||||
|
||||
ALTER TABLE commands DROP COLUMN IF EXISTS pluginid;
|
||||
|
||||
DROP TABLE IF EXISTS commands;
|
||||
@@ -0,0 +1,28 @@
|
||||
CREATE TABLE IF NOT EXISTS commands (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
token VARCHAR(26),
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
deleteat bigint,
|
||||
creatorid VARCHAR(26),
|
||||
teamid VARCHAR(26),
|
||||
trigger VARCHAR(128),
|
||||
method VARCHAR(1),
|
||||
username VARCHAR(64),
|
||||
iconurl VARCHAR(1024),
|
||||
autocomplete bool,
|
||||
autocompletedesc VARCHAR(1024),
|
||||
autocompletehint VARCHAR(1024),
|
||||
displayname VARCHAR(64),
|
||||
description VARCHAR(128),
|
||||
url VARCHAR(1024)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_command_team_id ON commands (teamid);
|
||||
CREATE INDEX IF NOT EXISTS idx_command_update_at ON commands (updateat);
|
||||
CREATE INDEX IF NOT EXISTS idx_command_create_at ON commands (createat);
|
||||
CREATE INDEX IF NOT EXISTS idx_command_delete_at ON commands (deleteat);
|
||||
|
||||
ALTER TABLE commands ADD COLUMN IF NOT EXISTS pluginid VARCHAR(190);
|
||||
|
||||
UPDATE commands SET pluginid = '' WHERE pluginid IS NULL;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS incomingwebhooks;
|
||||
@@ -0,0 +1,72 @@
|
||||
CREATE TABLE IF NOT EXISTS incomingwebhooks (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
deleteat bigint,
|
||||
userid VARCHAR(26),
|
||||
channelid VARCHAR(26),
|
||||
teamid VARCHAR(26),
|
||||
displayname VARCHAR(64),
|
||||
description VARCHAR(128)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_incoming_webhook_user_id ON incomingwebhooks (userid);
|
||||
CREATE INDEX IF NOT EXISTS idx_incoming_webhook_team_id ON incomingwebhooks (teamid);
|
||||
CREATE INDEX IF NOT EXISTS idx_incoming_webhook_update_at ON incomingwebhooks (updateat);
|
||||
CREATE INDEX IF NOT EXISTS idx_incoming_webhook_create_at ON incomingwebhooks (createat);
|
||||
CREATE INDEX IF NOT EXISTS idx_incoming_webhook_delete_at ON incomingwebhooks (deleteat);
|
||||
|
||||
ALTER TABLE incomingwebhooks ADD COLUMN IF NOT EXISTS username VARCHAR(255);
|
||||
ALTER TABLE incomingwebhooks ADD COLUMN IF NOT EXISTS iconurl VARCHAR(1024);
|
||||
ALTER TABLE incomingwebhooks ADD COLUMN IF NOT EXISTS channellocked boolean;
|
||||
ALTER TABLE incomingwebhooks ALTER COLUMN description TYPE VARCHAR(500);
|
||||
|
||||
DO $$
|
||||
<<checks>>
|
||||
DECLARE
|
||||
wrong_usernames_count integer := 0;
|
||||
wrong_icon_urls_count integer := 0;
|
||||
BEGIN
|
||||
SELECT COALESCE(
|
||||
SUM(
|
||||
CASE
|
||||
WHEN CHAR_LENGTH(username) > 255 THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
),
|
||||
0) INTO wrong_usernames_count
|
||||
FROM incomingwebhooks;
|
||||
|
||||
SELECT COALESCE(
|
||||
SUM(
|
||||
CASE
|
||||
WHEN CHAR_LENGTH(iconurl) > 1024 THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
),
|
||||
0) INTO wrong_icon_urls_count
|
||||
FROM incomingwebhooks;
|
||||
|
||||
IF wrong_usernames_count > 0 THEN
|
||||
RAISE EXCEPTION 'IncomingWebhooks column Username has data larger that 255 characters';
|
||||
END IF;
|
||||
|
||||
IF wrong_icon_urls_count > 0 THEN
|
||||
RAISE EXCEPTION 'IncomingWebhooks column IconURL has data larger that 1024 characters';
|
||||
END IF;
|
||||
END checks $$;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
column_exist boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO column_exist
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'incomingwebhooks'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'description'
|
||||
AND NOT data_type = 'VARCHAR(500)';
|
||||
IF column_exist THEN
|
||||
ALTER TABLE incomingwebhooks ALTER COLUMN description TYPE VARCHAR(500);
|
||||
END IF;
|
||||
END $$;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS outgoingwebhooks;
|
||||
@@ -0,0 +1,80 @@
|
||||
CREATE TABLE IF NOT EXISTS outgoingwebhooks (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
token VARCHAR(26),
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
deleteat bigint,
|
||||
creatorid VARCHAR(26),
|
||||
channelid VARCHAR(26),
|
||||
teamid VARCHAR(26),
|
||||
triggerwords VARCHAR(1024),
|
||||
callbackurls VARCHAR(1024),
|
||||
displayname VARCHAR(64)
|
||||
);
|
||||
|
||||
ALTER TABLE outgoingwebhooks ADD COLUMN IF NOT EXISTS contenttype VARCHAR(128);
|
||||
ALTER TABLE outgoingwebhooks ADD COLUMN IF NOT EXISTS triggerwhen integer;
|
||||
ALTER TABLE outgoingwebhooks ADD COLUMN IF NOT EXISTS username VARCHAR(64);
|
||||
ALTER TABLE outgoingwebhooks ADD COLUMN IF NOT EXISTS iconurl VARCHAR(1024);
|
||||
ALTER TABLE outgoingwebhooks ADD COLUMN IF NOT EXISTS description VARCHAR(500);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_outgoing_webhook_team_id ON outgoingwebhooks (teamid);
|
||||
CREATE INDEX IF NOT EXISTS idx_outgoing_webhook_update_at ON outgoingwebhooks (updateat);
|
||||
CREATE INDEX IF NOT EXISTS idx_outgoing_webhook_create_at ON outgoingwebhooks (createat);
|
||||
CREATE INDEX IF NOT EXISTS idx_outgoing_webhook_delete_at ON outgoingwebhooks (deleteat);
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
column_exist boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO column_exist
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'outgoingwebhooks'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'description'
|
||||
AND NOT data_type = 'VARCHAR(500)';
|
||||
IF column_exist THEN
|
||||
ALTER TABLE outgoingwebhooks ALTER COLUMN description TYPE VARCHAR(500);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
column_exist boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO column_exist
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'outgoingwebhooks'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'iconurl'
|
||||
AND NOT data_type = 'VARCHAR(1024)';
|
||||
IF column_exist THEN
|
||||
ALTER TABLE outgoingwebhooks ALTER COLUMN iconurl TYPE VARCHAR(1024);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF (
|
||||
SELECT column_default::bigint
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema=current_schema()
|
||||
AND table_name='outgoingwebhooks'
|
||||
AND column_name='username'
|
||||
) = 0 THEN
|
||||
ALTER TABLE outgoingwebhooks ALTER COLUMN username SET DEFAULT NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF (
|
||||
SELECT column_default::bigint
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema=current_schema()
|
||||
AND table_name='outgoingwebhooks'
|
||||
AND column_name='iconurl'
|
||||
) = 0 THEN
|
||||
ALTER TABLE outgoingwebhooks ALTER COLUMN iconurl SET DEFAULT NULL;
|
||||
END IF;
|
||||
END $$;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS systems;
|
||||
@@ -0,0 +1,5 @@
|
||||
CREATE TABLE IF NOT EXISTS systems (
|
||||
name VARCHAR(64),
|
||||
value VARCHAR(1024),
|
||||
PRIMARY KEY (name)
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS reactions;
|
||||
@@ -0,0 +1,31 @@
|
||||
CREATE TABLE IF NOT EXISTS reactions(
|
||||
userid VARCHAR(26) NOT NULL,
|
||||
postid VARCHAR(26) NOT NULL,
|
||||
emojiname VARCHAR(64) NOT NULL,
|
||||
createat bigint
|
||||
);
|
||||
|
||||
ALTER TABLE reactions ADD COLUMN IF NOT EXISTS updateat bigint;
|
||||
ALTER TABLE reactions ADD COLUMN IF NOT EXISTS deleteat bigint;
|
||||
|
||||
DO $$
|
||||
<<alter_pk>>
|
||||
DECLARE
|
||||
existing_index text;
|
||||
BEGIN
|
||||
SELECT string_agg(a.attname, ',') INTO existing_index
|
||||
FROM pg_constraint AS c
|
||||
CROSS JOIN
|
||||
(SELECT unnest(conkey) FROM pg_constraint WHERE conrelid = 'reactions'::regclass AND contype='p') AS cols(colnum)
|
||||
INNER JOIN pg_attribute AS a ON a.attrelid = c.conrelid AND cols.colnum = a.attnum
|
||||
WHERE c.contype = 'p'
|
||||
AND c.conrelid = 'reactions'::regclass;
|
||||
|
||||
IF COALESCE (existing_index, '') <> text('postid,userid,emojiname') THEN
|
||||
ALTER TABLE reactions
|
||||
DROP CONSTRAINT IF EXISTS reactions_pkey,
|
||||
ADD PRIMARY KEY (postid, userid, emojiname);
|
||||
END IF;
|
||||
END alter_pk $$;
|
||||
|
||||
ALTER TABLE reactions ADD COLUMN IF NOT EXISTS remoteid VARCHAR(26);
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS roles;
|
||||
@@ -0,0 +1,34 @@
|
||||
CREATE TABLE IF NOT EXISTS roles (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
name VARCHAR(64),
|
||||
displayname VARCHAR(128),
|
||||
description VARCHAR(1024),
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
deleteat bigint,
|
||||
permissions VARCHAR(4096),
|
||||
schememanaged boolean,
|
||||
UNIQUE(name)
|
||||
);
|
||||
|
||||
ALTER TABLE roles ADD COLUMN IF NOT EXISTS builtin boolean;
|
||||
|
||||
DO $$
|
||||
<< migrate_if_version_below_500 >>
|
||||
DECLARE
|
||||
current_db_version VARCHAR(100) := '';
|
||||
BEGIN
|
||||
SELECT
|
||||
value INTO current_db_version
|
||||
FROM
|
||||
systems
|
||||
WHERE
|
||||
name = 'Version';
|
||||
IF (string_to_array(current_db_version, '.') < string_to_array('5.0.0', '.')) THEN
|
||||
UPDATE Roles SET SchemeManaged = false
|
||||
WHERE Name NOT IN ('system_user', 'system_admin', 'team_user', 'team_admin', 'channel_user', 'channel_admin');
|
||||
END IF;
|
||||
END migrate_if_version_below_500
|
||||
$$;
|
||||
|
||||
ALTER TABLE roles ALTER COLUMN permissions TYPE TEXT;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS schemes;
|
||||
@@ -0,0 +1,25 @@
|
||||
CREATE TABLE IF NOT EXISTS schemes (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
name VARCHAR(64),
|
||||
displayname VARCHAR(128),
|
||||
description VARCHAR(1024),
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
deleteat bigint,
|
||||
scope VARCHAR(32),
|
||||
defaultteamadminrole VARCHAR(64),
|
||||
defaultteamuserrole VARCHAR(64),
|
||||
defaultchanneladminrole VARCHAR(64),
|
||||
defaultchanneluserrole VARCHAR(64),
|
||||
UNIQUE(name)
|
||||
);
|
||||
|
||||
ALTER TABLE schemes ADD COLUMN IF NOT EXISTS defaultteamguestrole VARCHAR(64);
|
||||
ALTER TABLE schemes ADD COLUMN IF NOT EXISTS defaultchannelguestrole VARCHAR(64);
|
||||
|
||||
ALTER TABLE schemes ALTER COLUMN defaultteamguestrole TYPE VARCHAR(64);
|
||||
ALTER TABLE schemes ALTER COLUMN defaultchannelguestrole TYPE VARCHAR(64);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_schemes_channel_guest_role ON schemes (defaultchannelguestrole);
|
||||
CREATE INDEX IF NOT EXISTS idx_schemes_channel_user_role ON schemes (defaultchanneluserrole);
|
||||
CREATE INDEX IF NOT EXISTS idx_schemes_channel_admin_role ON schemes (defaultchanneladminrole);
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS licenses;
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS licenses (
|
||||
id VARCHAR(26) NOT NULL,
|
||||
createat bigint,
|
||||
bytes VARCHAR(10000),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
@@ -0,0 +1,3 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_posts_channel_id ON posts (channelid);
|
||||
|
||||
DROP TABLE IF EXISTS posts;
|
||||
@@ -0,0 +1,51 @@
|
||||
CREATE TABLE IF NOT EXISTS posts (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
deleteat bigint,
|
||||
userid VARCHAR(26),
|
||||
channelid VARCHAR(26),
|
||||
rootid VARCHAR(26),
|
||||
parentid VARCHAR(26),
|
||||
originalid VARCHAR(26),
|
||||
message VARCHAR(65535),
|
||||
type VARCHAR(26),
|
||||
props VARCHAR(8000),
|
||||
hashtags VARCHAR(1000),
|
||||
filenames VARCHAR(4000)
|
||||
);
|
||||
|
||||
ALTER TABLE posts ADD COLUMN IF NOT EXISTS fileids VARCHAR(300);
|
||||
ALTER TABLE posts ADD COLUMN IF NOT EXISTS hasreactions boolean;
|
||||
ALTER TABLE posts ADD COLUMN IF NOT EXISTS editat bigint;
|
||||
ALTER TABLE posts ADD COLUMN IF NOT EXISTS ispinned boolean;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_posts_update_at ON posts(updateat);
|
||||
CREATE INDEX IF NOT EXISTS idx_posts_create_at ON posts(createat);
|
||||
CREATE INDEX IF NOT EXISTS idx_posts_delete_at ON posts(deleteat);
|
||||
CREATE INDEX IF NOT EXISTS idx_posts_root_id ON posts(rootid);
|
||||
CREATE INDEX IF NOT EXISTS idx_posts_user_id ON posts(userid);
|
||||
CREATE INDEX IF NOT EXISTS idx_posts_is_pinned ON posts(ispinned);
|
||||
CREATE INDEX IF NOT EXISTS idx_posts_channel_id_update_at ON posts(channelid, updateat);
|
||||
CREATE INDEX IF NOT EXISTS idx_posts_channel_id_delete_at_create_at ON posts(channelid, deleteat, createat);
|
||||
CREATE INDEX IF NOT EXISTS idx_posts_message_txt ON posts USING gin(to_tsvector('english', message));
|
||||
CREATE INDEX IF NOT EXISTS idx_posts_hashtags_txt ON posts USING gin(to_tsvector('english', hashtags));
|
||||
|
||||
ALTER TABLE posts ADD COLUMN IF NOT EXISTS remoteid VARCHAR(26);
|
||||
|
||||
DROP INDEX IF EXISTS idx_posts_channel_id;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
column_exist boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO column_exist
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'posts'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'fileids'
|
||||
AND NOT data_type = 'varchar(300)';
|
||||
IF column_exist THEN
|
||||
ALTER TABLE posts ALTER COLUMN fileids TYPE varchar(300);
|
||||
END IF;
|
||||
END $$;
|
||||
@@ -0,0 +1,4 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_notice_views_user_notice ON productnoticeviewstate (userid, noticeid);
|
||||
CREATE INDEX IF NOT EXISTS idx_notice_views_user_id ON productnoticeviewstate (userid);
|
||||
|
||||
DROP TABLE IF EXISTS productnoticeviewstate;
|
||||
@@ -0,0 +1,13 @@
|
||||
CREATE TABLE IF NOT EXISTS productnoticeviewstate (
|
||||
userid VARCHAR(26),
|
||||
noticeid VARCHAR(26),
|
||||
viewed integer,
|
||||
"timestamp" bigint,
|
||||
PRIMARY KEY (userid, noticeid)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_notice_views_notice_id ON productnoticeviewstate(noticeid);
|
||||
CREATE INDEX IF NOT EXISTS idx_notice_views_timestamp ON productnoticeviewstate("timestamp");
|
||||
|
||||
DROP INDEX IF EXISTS idx_notice_views_user_id;
|
||||
DROP INDEX IF EXISTS idx_notice_views_user_notice;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS sessions;
|
||||
@@ -0,0 +1,37 @@
|
||||
CREATE TABLE IF NOT EXISTS sessions (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
token VARCHAR(26),
|
||||
createat bigint,
|
||||
expiresat bigint,
|
||||
lastactivityat bigint,
|
||||
userid VARCHAR(26),
|
||||
deviceid VARCHAR(512),
|
||||
roles VARCHAR(64),
|
||||
isoauth boolean,
|
||||
props VARCHAR(1000)
|
||||
);
|
||||
|
||||
ALTER TABLE sessions ADD COLUMN IF NOT EXISTS expirednotify boolean;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_sessions_user_id ON sessions (userid);
|
||||
CREATE INDEX IF NOT EXISTS idx_sessions_token ON sessions (token);
|
||||
CREATE INDEX IF NOT EXISTS idx_sessions_expires_at ON sessions (expiresat);
|
||||
CREATE INDEX IF NOT EXISTS idx_sessions_create_at ON sessions (createat);
|
||||
CREATE INDEX IF NOT EXISTS idx_sessions_last_activity_at ON sessions (lastactivityat);
|
||||
|
||||
DO $$
|
||||
<< migrate_if_version_below_5120 >>
|
||||
DECLARE
|
||||
current_db_version VARCHAR(100) := '';
|
||||
BEGIN
|
||||
SELECT
|
||||
value INTO current_db_version
|
||||
FROM
|
||||
systems
|
||||
WHERE
|
||||
name = 'Version';
|
||||
IF (string_to_array(current_db_version, '.') < string_to_array('5.12.0', '.')) THEN
|
||||
DELETE FROM sessions where expiresat > 3000000000000;
|
||||
END IF;
|
||||
END migrate_if_version_below_5120
|
||||
$$;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS termsofservice;
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS termsofservice (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
createat bigint,
|
||||
userid VARCHAR(26),
|
||||
text VARCHAR(65535)
|
||||
);
|
||||
@@ -0,0 +1,3 @@
|
||||
DROP INDEX IF EXISTS idx_audits_user_id;
|
||||
|
||||
DROP TABLE IF EXISTS audits;
|
||||
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS audits (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
createat bigint,
|
||||
userid VARCHAR(26),
|
||||
action VARCHAR(512),
|
||||
extrainfo VARCHAR(1024),
|
||||
ipaddress VARCHAR(64),
|
||||
sessionid VARCHAR(26)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_audits_user_id ON audits (userid);
|
||||
@@ -0,0 +1,3 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_oauthaccessdata_client_id ON oauthaccessdata (clientid);
|
||||
|
||||
DROP TABLE IF EXISTS oauthaccessdata;
|
||||
@@ -0,0 +1,36 @@
|
||||
CREATE TABLE IF NOT EXISTS oauthaccessdata (
|
||||
token VARCHAR(26) NOT NULL,
|
||||
refreshtoken VARCHAR(26),
|
||||
redirecturi VARCHAR(256),
|
||||
PRIMARY KEY (token)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_oauthaccessdata_refresh_token ON oauthaccessdata (refreshtoken);
|
||||
|
||||
ALTER TABLE oauthaccessdata ADD COLUMN IF NOT EXISTS clientid VARCHAR(26);
|
||||
|
||||
ALTER TABLE oauthaccessdata ADD COLUMN IF NOT EXISTS userid VARCHAR(26);
|
||||
CREATE INDEX IF NOT EXISTS idx_oauthaccessdata_user_id ON oauthaccessdata (userid);
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT conname
|
||||
FROM pg_constraint
|
||||
WHERE conname = 'oauthaccessdata_clientid_userid_key'
|
||||
)
|
||||
THEN
|
||||
ALTER TABLE oauthaccessdata ADD CONSTRAINT oauthaccessdata_clientid_userid_key UNIQUE (clientid, userid);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
ALTER TABLE oauthaccessdata ADD COLUMN IF NOT EXISTS expiresat bigint;
|
||||
|
||||
DROP INDEX IF EXISTS idx_oauthaccessdata_auth_code;
|
||||
ALTER TABLE oauthaccessdata DROP COLUMN IF EXISTS authcode;
|
||||
|
||||
ALTER TABLE oauthaccessdata ADD COLUMN IF NOT EXISTS scope VARCHAR(128);
|
||||
|
||||
DROP INDEX IF EXISTS clientid_2;
|
||||
|
||||
DROP INDEX IF EXISTS idx_oauthaccessdata_client_id;
|
||||
@@ -0,0 +1,3 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_preferences_user_id ON preferences (userid);
|
||||
|
||||
DROP TABLE IF EXISTS preferences;
|
||||
@@ -0,0 +1,53 @@
|
||||
CREATE TABLE IF NOT EXISTS preferences (
|
||||
userid varchar(26) NOT NULL,
|
||||
category varchar(32) NOT NULL,
|
||||
name varchar(32) NOT NULL,
|
||||
value varchar(2000),
|
||||
PRIMARY KEY (userid, category, name)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_preferences_category ON preferences(category);
|
||||
CREATE INDEX IF NOT EXISTS idx_preferences_name ON preferences(name);
|
||||
|
||||
DO $$
|
||||
<<modify_column_type_if_type_is_different>>
|
||||
DECLARE
|
||||
type_exists boolean := false;
|
||||
col_exists boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO col_exists
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'preferences'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'value';
|
||||
|
||||
SELECT count(*) != 0 INTO type_exists
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'preferences'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'value'
|
||||
AND data_type = 'character varying'
|
||||
AND character_maximum_length = 2000;
|
||||
|
||||
IF col_exists AND NOT type_exists THEN
|
||||
ALTER TABLE preferences ALTER COLUMN value TYPE varchar(2000);
|
||||
END IF;
|
||||
END modify_column_type_if_type_is_different $$;
|
||||
|
||||
DO $$
|
||||
<<rename_solarized_theme>>
|
||||
DECLARE
|
||||
preference record;
|
||||
BEGIN
|
||||
FOR preference IN
|
||||
SELECT * FROM preferences WHERE category = 'theme' AND value LIKE '%solarized_%'
|
||||
LOOP
|
||||
UPDATE preferences
|
||||
SET value = replace(preference.value, 'solarized_', 'solarized-')
|
||||
WHERE userid = preference.userid
|
||||
AND category = preference.category
|
||||
AND name = preference.name;
|
||||
END LOOP;
|
||||
END rename_solarized_theme $$;
|
||||
|
||||
DROP INDEX IF EXISTS idx_preferences_user_id;
|
||||
@@ -0,0 +1,3 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_status_user_id ON status (userid);
|
||||
|
||||
DROP TABLE IF EXISTS status;
|
||||
@@ -0,0 +1,15 @@
|
||||
CREATE TABLE IF NOT EXISTS status (
|
||||
userid VARCHAR(26) PRIMARY KEY,
|
||||
status VARCHAR(32),
|
||||
manual boolean,
|
||||
lastactivityat bigint
|
||||
);
|
||||
|
||||
ALTER TABLE status DROP COLUMN IF EXISTS activechannel;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_status_status ON status(status);
|
||||
|
||||
ALTER TABLE status ADD COLUMN IF NOT EXISTS dndendtime bigint;
|
||||
ALTER TABLE status ADD COLUMN IF NOT EXISTS prevstatus VARCHAR(32);
|
||||
|
||||
DROP INDEX IF EXISTS idx_status_user_id;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS tokens;
|
||||
@@ -0,0 +1,33 @@
|
||||
CREATE TABLE IF NOT EXISTS tokens (
|
||||
token VARCHAR(64) PRIMARY KEY,
|
||||
createat bigint,
|
||||
type VARCHAR(64),
|
||||
extra VARCHAR(2048)
|
||||
);
|
||||
|
||||
ALTER TABLE tokens ALTER COLUMN extra TYPE VARCHAR(2048);
|
||||
|
||||
DO $$
|
||||
<<modify_column_type_if_type_is_different>>
|
||||
DECLARE
|
||||
type_exists boolean := false;
|
||||
col_exists boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO col_exists
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'tokens'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'extra';
|
||||
|
||||
SELECT count(*) != 0 INTO type_exists
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'tokens'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'extra'
|
||||
AND data_type = 'character varying'
|
||||
AND character_maximum_length = 2048;
|
||||
|
||||
IF col_exists AND NOT type_exists THEN
|
||||
ALTER TABLE tokens ALTER COLUMN extra TYPE VARCHAR(2048);
|
||||
END IF;
|
||||
END modify_column_type_if_type_is_different $$;
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE bots DROP COLUMN IF EXISTS lasticonupdate;
|
||||
|
||||
DROP TABLE IF EXISTS bots;
|
||||
@@ -0,0 +1,10 @@
|
||||
CREATE TABLE IF NOT EXISTS bots (
|
||||
userid VARCHAR(26) PRIMARY KEY,
|
||||
description VARCHAR(1024),
|
||||
ownerid VARCHAR(190),
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
deleteat bigint
|
||||
);
|
||||
|
||||
ALTER TABLE bots ADD COLUMN IF NOT EXISTS lasticonupdate bigint;
|
||||
@@ -0,0 +1,3 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_user_access_tokens_token ON useraccesstokens (token);
|
||||
|
||||
DROP TABLE IF EXISTS useraccesstokens;
|
||||
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS useraccesstokens (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
token VARCHAR(26) UNIQUE,
|
||||
userid VARCHAR(26),
|
||||
description VARCHAR(512)
|
||||
);
|
||||
|
||||
ALTER TABLE useraccesstokens ADD COLUMN IF NOT EXISTS isactive boolean;
|
||||
CREATE INDEX IF NOT EXISTS idx_user_access_tokens_user_id ON useraccesstokens(userid);
|
||||
|
||||
DROP INDEX IF EXISTS idx_user_access_tokens_token;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS remoteclusters;
|
||||
@@ -0,0 +1,16 @@
|
||||
CREATE TABLE IF NOT EXISTS remoteclusters (
|
||||
remoteid VARCHAR(26) NOT NULL,
|
||||
remoteteamid VARCHAR(26),
|
||||
name VARCHAR(64) NOT NULL,
|
||||
displayname VARCHAR(64),
|
||||
siteurl VARCHAR(512),
|
||||
createat bigint,
|
||||
lastpingat bigint,
|
||||
token VARCHAR(26),
|
||||
remotetoken VARCHAR(26),
|
||||
topics VARCHAR(512),
|
||||
creatorid VARCHAR(26),
|
||||
PRIMARY KEY (remoteid, name)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS remote_clusters_site_url_unique ON remoteclusters (siteurl, remoteteamid);
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS sharedchannels;
|
||||
@@ -0,0 +1,16 @@
|
||||
CREATE TABLE IF NOT EXISTS sharedchannels (
|
||||
channelid character varying(26) NOT NULL,
|
||||
teamid character varying(26),
|
||||
home boolean,
|
||||
readonly boolean,
|
||||
sharename character varying(64),
|
||||
sharedisplayname character varying(64),
|
||||
sharepurpose character varying(250),
|
||||
shareheader character varying(1024),
|
||||
creatorid character varying(26),
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
remoteid character varying(26),
|
||||
PRIMARY KEY (channelid),
|
||||
UNIQUE (sharename, teamid)
|
||||
);
|
||||
@@ -0,0 +1,19 @@
|
||||
DO $$
|
||||
<<modify_column_type_if_type_is_different>>
|
||||
DECLARE
|
||||
col_exist_and_type_different boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO col_exist_and_type_different
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'sidebarchannels'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'categoryid'
|
||||
AND data_type = 'character varying'
|
||||
AND NOT character_maximum_length = 26;
|
||||
|
||||
IF col_exist_and_type_different THEN
|
||||
ALTER TABLE sidebarchannels ALTER COLUMN categoryid TYPE varchar(26);
|
||||
END IF;
|
||||
END modify_column_type_if_type_is_different $$;
|
||||
|
||||
DROP TABLE IF EXISTS sidebarchannels;
|
||||
@@ -0,0 +1,25 @@
|
||||
CREATE TABLE IF NOT EXISTS sidebarchannels (
|
||||
channelid VARCHAR(26),
|
||||
userid VARCHAR(26),
|
||||
categoryid VARCHAR(26),
|
||||
sortorder bigint,
|
||||
PRIMARY KEY (channelid, userid, categoryid)
|
||||
);
|
||||
|
||||
DO $$
|
||||
<<modify_column_type_if_type_is_different>>
|
||||
DECLARE
|
||||
col_exist_and_type_different boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO col_exist_and_type_different
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'sidebarchannels'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'categoryid'
|
||||
AND data_type = 'character varying'
|
||||
AND NOT character_maximum_length = 128;
|
||||
|
||||
IF col_exist_and_type_different THEN
|
||||
ALTER TABLE sidebarchannels ALTER COLUMN categoryid TYPE varchar(128);
|
||||
END IF;
|
||||
END modify_column_type_if_type_is_different $$
|
||||
@@ -0,0 +1,3 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_oauthauthdata_client_id ON oauthauthdata (code);
|
||||
|
||||
DROP TABLE IF EXISTS oauthauthdata;
|
||||
@@ -0,0 +1,38 @@
|
||||
CREATE TABLE IF NOT EXISTS oauthauthdata (
|
||||
clientid varchar(26),
|
||||
userid varchar(26),
|
||||
code varchar(128) NOT NULL,
|
||||
expiresin integer,
|
||||
createat bigint,
|
||||
redirecturi varchar(256),
|
||||
state varchar(1024),
|
||||
scope varchar(128),
|
||||
PRIMARY KEY (code)
|
||||
);
|
||||
|
||||
DO $$
|
||||
<<modify_column_type_if_type_is_different>>
|
||||
DECLARE
|
||||
type_exists boolean := false;
|
||||
col_exists boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO col_exists
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'oauthauthdata'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'state';
|
||||
|
||||
SELECT count(*) != 0 INTO type_exists
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'oauthauthdata'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'state'
|
||||
AND data_type = 'character varying'
|
||||
AND character_maximum_length = 1024;
|
||||
|
||||
IF col_exists AND NOT type_exists THEN
|
||||
ALTER TABLE oauthauthdata ALTER COLUMN state TYPE varchar(1024);
|
||||
END IF;
|
||||
END modify_column_type_if_type_is_different $$;
|
||||
|
||||
DROP INDEX IF EXISTS idx_oauthauthdata_client_id;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS sharedchannelattachments;
|
||||
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE IF NOT EXISTS sharedchannelattachments (
|
||||
id varchar(26) NOT NULL,
|
||||
fileid varchar(26),
|
||||
remoteid varchar(26),
|
||||
createat bigint,
|
||||
lastsyncat bigint,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE (fileid, remoteid)
|
||||
);
|
||||
@@ -0,0 +1,5 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_sharedchannelusers_user_id ON sharedchannelusers (userid);
|
||||
|
||||
ALTER TABLE sharedchannelusers DROP COLUMN IF EXISTS channelid;
|
||||
|
||||
DROP TABLE IF EXISTS sharedchannelusers;
|
||||
@@ -0,0 +1,26 @@
|
||||
CREATE TABLE IF NOT EXISTS sharedchannelusers (
|
||||
id varchar(26) NOT NULL,
|
||||
userid varchar(26),
|
||||
remoteid varchar(26),
|
||||
createat bigint,
|
||||
lastsyncat bigint,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
ALTER TABLE sharedchannelusers ADD COLUMN IF NOT EXISTS channelid varchar(26);
|
||||
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT conname
|
||||
FROM pg_constraint
|
||||
WHERE conname = 'sharedchannelusers_userid_channelid_remoteid_key'
|
||||
)
|
||||
THEN
|
||||
ALTER TABLE sharedchannelusers ADD CONSTRAINT sharedchannelusers_userid_channelid_remoteid_key UNIQUE (userid, channelid, remoteid);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
DROP INDEX IF EXISTS idx_sharedchannelusers_user_id;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_sharedchannelusers_remote_id ON sharedchannelusers(remoteid);
|
||||
@@ -0,0 +1,4 @@
|
||||
ALTER TABLE sharedchannelremotes DROP COLUMN IF EXISTS LastPostId;
|
||||
ALTER TABLE sharedchannelremotes DROP COLUMN IF EXISTS LastPostUpdateAt;
|
||||
|
||||
DROP TABLE IF EXISTS sharedchannelremotes;
|
||||
@@ -0,0 +1,15 @@
|
||||
CREATE TABLE IF NOT EXISTS sharedchannelremotes (
|
||||
id character varying(26) NOT NULL,
|
||||
channelid character varying(26) NOT NULL,
|
||||
creatorid character varying(26),
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
isinviteaccepted boolean,
|
||||
isinviteconfirmed boolean,
|
||||
remoteid character varying(26),
|
||||
PRIMARY KEY(id, channelid),
|
||||
UNIQUE(channelid, remoteid)
|
||||
);
|
||||
|
||||
ALTER TABLE sharedchannelremotes ADD COLUMN IF NOT EXISTS LastPostUpdateAt bigint;
|
||||
ALTER TABLE sharedchannelremotes ADD COLUMN IF NOT EXISTS LastPostId character varying(26);
|
||||
@@ -0,0 +1,3 @@
|
||||
DROP INDEX IF EXISTS idx_jobs_type;
|
||||
|
||||
DROP TABLE IF EXISTS jobs;
|
||||
@@ -0,0 +1,13 @@
|
||||
CREATE TABLE IF NOT EXISTS jobs (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
type VARCHAR(32),
|
||||
priority bigint,
|
||||
createat bigint,
|
||||
startat bigint,
|
||||
lastactivityat bigint,
|
||||
status VARCHAR(32),
|
||||
progress bigint,
|
||||
data VARCHAR(1024)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_jobs_type ON jobs (type);
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS channelmemberhistory;
|
||||
@@ -0,0 +1,10 @@
|
||||
CREATE TABLE IF NOT EXISTS channelmemberhistory (
|
||||
channelid VARCHAR(26) NOT NULL,
|
||||
userid VARCHAR(26) NOT NULL,
|
||||
jointime bigint NOT NULL,
|
||||
leavetime bigint,
|
||||
PRIMARY KEY (channelid, userid, jointime)
|
||||
);
|
||||
|
||||
ALTER TABLE channelmemberhistory DROP COLUMN IF EXISTS email;
|
||||
ALTER TABLE channelmemberhistory DROP COLUMN IF EXISTS username;
|
||||
@@ -0,0 +1,22 @@
|
||||
ALTER TABLE sidebarcategories DROP COLUMN IF EXISTS collapsed;
|
||||
ALTER TABLE sidebarcategories DROP COLUMN IF EXISTS muted;
|
||||
|
||||
DO $$
|
||||
<<modify_column_type_if_type_is_different>>
|
||||
DECLARE
|
||||
col_exist_and_type_different boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO col_exist_and_type_different
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'sidebarcategories'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'id'
|
||||
AND data_type = 'character varying'
|
||||
AND NOT character_maximum_length = 26;
|
||||
|
||||
IF col_exist_and_type_different THEN
|
||||
ALTER TABLE sidebarcategories ALTER COLUMN id TYPE varchar(26);
|
||||
END IF;
|
||||
END modify_column_type_if_type_is_different $$;
|
||||
|
||||
DROP TABLE IF EXISTS sidebarcategories;
|
||||
@@ -0,0 +1,31 @@
|
||||
CREATE TABLE IF NOT EXISTS sidebarcategories (
|
||||
id VARCHAR(26),
|
||||
userid VARCHAR(26),
|
||||
teamid VARCHAR(26),
|
||||
sortorder bigint,
|
||||
sorting VARCHAR(64),
|
||||
type VARCHAR(64),
|
||||
displayname VARCHAR(64),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
DO $$
|
||||
<<modify_column_type_if_type_is_different>>
|
||||
DECLARE
|
||||
col_exist_and_type_different boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO col_exist_and_type_different
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'sidebarcategories'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'id'
|
||||
AND data_type = 'character varying'
|
||||
AND NOT character_maximum_length = 128;
|
||||
|
||||
IF col_exist_and_type_different THEN
|
||||
ALTER TABLE sidebarcategories ALTER COLUMN id TYPE varchar(128);
|
||||
END IF;
|
||||
END modify_column_type_if_type_is_different $$;
|
||||
|
||||
ALTER TABLE sidebarcategories ADD COLUMN IF NOT EXISTS muted boolean;
|
||||
ALTER TABLE sidebarcategories ADD COLUMN IF NOT EXISTS collapsed boolean;
|
||||
@@ -0,0 +1,4 @@
|
||||
ALTER TABLE uploadsessions DROP COLUMN IF EXISTS reqfileid;
|
||||
ALTER TABLE uploadsessions DROP COLUMN IF EXISTS remoteid;
|
||||
|
||||
DROP TABLE IF EXISTS uploadsessions;
|
||||
@@ -0,0 +1,35 @@
|
||||
CREATE TABLE IF NOT EXISTS uploadsessions (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
type VARCHAR(32),
|
||||
createat bigint,
|
||||
userid VARCHAR(26),
|
||||
channelid VARCHAR(26),
|
||||
filename VARCHAR(256),
|
||||
path VARCHAR(512),
|
||||
filesize bigint,
|
||||
fileoffset bigint
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_uploadsessions_user_id ON uploadsessions(userid);
|
||||
CREATE INDEX IF NOT EXISTS idx_uploadsessions_create_at ON uploadsessions(createat);
|
||||
CREATE INDEX IF NOT EXISTS idx_uploadsessions_type ON uploadsessions(type);
|
||||
|
||||
ALTER TABLE uploadsessions ADD COLUMN IF NOT EXISTS remoteid VARCHAR(26);
|
||||
ALTER TABLE uploadsessions ADD COLUMN IF NOT EXISTS reqfileid VARCHAR(26);
|
||||
|
||||
DO $$
|
||||
<< migrate_if_version_below_5350 >>
|
||||
DECLARE
|
||||
current_db_version VARCHAR(100) := '';
|
||||
BEGIN
|
||||
SELECT
|
||||
value INTO current_db_version
|
||||
FROM
|
||||
systems
|
||||
WHERE
|
||||
name = 'Version';
|
||||
IF (string_to_array(current_db_version, '.') < string_to_array('5.35.0', '.')) THEN
|
||||
UPDATE UploadSessions SET RemoteId='', ReqFileId='' WHERE RemoteId IS NULL;
|
||||
END IF;
|
||||
END migrate_if_version_below_5350
|
||||
$$;
|
||||
@@ -0,0 +1,5 @@
|
||||
DROP INDEX IF EXISTS idx_threads_channel_id;
|
||||
|
||||
ALTER TABLE threads DROP COLUMN IF EXISTS channelid;
|
||||
|
||||
DROP TABLE IF EXISTS threads;
|
||||
@@ -0,0 +1,35 @@
|
||||
CREATE TABLE IF NOT EXISTS threads (
|
||||
postid VARCHAR(26) PRIMARY KEY,
|
||||
replycount bigint,
|
||||
lastreplyat bigint,
|
||||
participants text
|
||||
);
|
||||
|
||||
ALTER TABLE threads ADD COLUMN IF NOT EXISTS channelid VARCHAR(26);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_threads_channel_id ON threads (channelid);
|
||||
|
||||
DO $$
|
||||
<< migrate_empty_threads >>
|
||||
DECLARE
|
||||
empty_threads_exist boolean := FALSE;
|
||||
BEGIN
|
||||
SELECT
|
||||
count(*) != 0 INTO empty_threads_exist
|
||||
FROM
|
||||
threads
|
||||
WHERE
|
||||
channelid IS NULL;
|
||||
IF empty_threads_exist THEN
|
||||
UPDATE
|
||||
threads
|
||||
SET
|
||||
channelId = posts.channelid
|
||||
FROM
|
||||
posts
|
||||
WHERE
|
||||
posts.id = threads.postid
|
||||
AND threads.channelid IS NULL;
|
||||
END IF;
|
||||
END migrate_empty_threads
|
||||
$$;
|
||||
@@ -0,0 +1,7 @@
|
||||
DROP INDEX IF EXISTS idx_thread_memberships_user_id;
|
||||
DROP INDEX IF EXISTS idx_thread_memberships_last_view_at;
|
||||
DROP INDEX IF EXISTS idx_thread_memberships_last_update_at;
|
||||
|
||||
ALTER TABLE threadmemberships DROP COLUMN IF EXISTS unreadmentions;
|
||||
|
||||
DROP TABLE IF EXISTS threadmemberships;
|
||||
@@ -0,0 +1,14 @@
|
||||
CREATE TABLE IF NOT EXISTS threadmemberships(
|
||||
postid VARCHAR(26) NOT NULL,
|
||||
userid VARCHAR(26) NOT NULL,
|
||||
following boolean,
|
||||
lastviewed bigint,
|
||||
lastupdated bigint,
|
||||
PRIMARY KEY (postid, userid)
|
||||
);
|
||||
|
||||
ALTER TABLE threadmemberships ADD COLUMN IF NOT EXISTS unreadmentions bigint;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_thread_memberships_last_update_at ON threadmemberships(lastupdated);
|
||||
CREATE INDEX IF NOT EXISTS idx_thread_memberships_last_view_at ON threadmemberships(lastviewed);
|
||||
CREATE INDEX IF NOT EXISTS idx_thread_memberships_user_id ON threadmemberships(userid);
|
||||
@@ -0,0 +1,3 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_user_terms_of_service_user_id ON usertermsofservice (userid);
|
||||
|
||||
DROP TABLE IF EXISTS usertermsofservice;
|
||||
@@ -0,0 +1,27 @@
|
||||
-- This migration depends on users table
|
||||
CREATE TABLE IF NOT EXISTS usertermsofservice (
|
||||
userid VARCHAR(26) PRIMARY KEY,
|
||||
termsofserviceid VARCHAR(26),
|
||||
createat bigint
|
||||
);
|
||||
|
||||
DO $$
|
||||
<<do_migrate_to_usertermsofservice_table>>
|
||||
DECLARE
|
||||
col_exist boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO col_exist
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'users'
|
||||
AND column_name = 'acceptedtermsofserviceid';
|
||||
|
||||
IF col_exist THEN
|
||||
INSERT INTO usertermsofservice
|
||||
SELECT id, acceptedtermsofserviceid as termsofserviceid, (extract(epoch from now()) * 1000)
|
||||
FROM users
|
||||
WHERE acceptedtermsofserviceid != ''
|
||||
AND acceptedtermsofserviceid IS NOT NULL;
|
||||
END IF;
|
||||
END do_migrate_to_usertermsofservice_table $$;
|
||||
|
||||
DROP INDEX IF EXISTS idx_user_terms_of_service_user_id;
|
||||
@@ -0,0 +1,15 @@
|
||||
DO $$BEGIN
|
||||
IF (
|
||||
SELECT column_default::bigint
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema=current_schema()
|
||||
AND table_name='pluginkeyvaluestore'
|
||||
AND column_name='expireat'
|
||||
) IS NULL THEN
|
||||
ALTER TABLE pluginkeyvaluestore ALTER COLUMN expireat SET DEFAULT 0;
|
||||
END IF;
|
||||
END$$;
|
||||
|
||||
ALTER TABLE pluginkeyvaluestore DROP COLUMN IF EXISTS expireat;
|
||||
|
||||
DROP TABLE IF EXISTS pluginkeyvaluestore;
|
||||
@@ -0,0 +1,20 @@
|
||||
CREATE TABLE IF NOT EXISTS pluginkeyvaluestore (
|
||||
pluginid VARCHAR(190) NOT NULL,
|
||||
pkey VARCHAR(50) NOT NULL,
|
||||
pvalue bytea,
|
||||
PRIMARY KEY (pluginid, pkey)
|
||||
);
|
||||
|
||||
ALTER TABLE pluginkeyvaluestore ADD COLUMN IF NOT EXISTS expireat bigint DEFAULT 0;
|
||||
|
||||
DO $$BEGIN
|
||||
IF (
|
||||
SELECT column_default::bigint
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema=current_schema()
|
||||
AND table_name='pluginkeyvaluestore'
|
||||
AND column_name='expireat'
|
||||
) = 0 THEN
|
||||
ALTER TABLE pluginkeyvaluestore ALTER COLUMN expireat SET DEFAULT NULL;
|
||||
END IF;
|
||||
END$$;
|
||||
@@ -0,0 +1,5 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_users_email ON users (email);
|
||||
|
||||
ALTER TABLE users DROP COLUMN IF EXISTS remoteid;
|
||||
|
||||
DROP TABLE IF EXISTS users;
|
||||
@@ -0,0 +1,88 @@
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
deleteat bigint,
|
||||
username VARCHAR(64) UNIQUE,
|
||||
password VARCHAR(128),
|
||||
authdata VARCHAR(128) UNIQUE,
|
||||
authservice VARCHAR(32),
|
||||
email VARCHAR(128) UNIQUE,
|
||||
emailverified boolean,
|
||||
nickname VARCHAR(64),
|
||||
firstname VARCHAR(64),
|
||||
lastname VARCHAR(64),
|
||||
roles VARCHAR(256),
|
||||
allowmarketing boolean,
|
||||
props VARCHAR(4000),
|
||||
notifyprops VARCHAR(2000),
|
||||
lastpasswordupdate bigint,
|
||||
lastpictureupdate bigint,
|
||||
failedattempts integer,
|
||||
locale VARCHAR(5),
|
||||
mfaactive boolean,
|
||||
mfasecret VARCHAR(128)
|
||||
);
|
||||
|
||||
ALTER TABLE users DROP COLUMN IF EXISTS lastactivityat;
|
||||
ALTER TABLE users DROP COLUMN IF EXISTS lastpingat;
|
||||
ALTER TABLE users ADD COLUMN IF NOT EXISTS position VARCHAR(128);
|
||||
ALTER TABLE users ADD COLUMN IF NOT EXISTS timezone VARCHAR(256) DEFAULT '{"automaticTimezone":"","manualTimezone":"","useAutomaticTimezone":"true"}';
|
||||
ALTER TABLE users ALTER COLUMN position TYPE VARCHAR(128);
|
||||
|
||||
DO $$
|
||||
<< migrate_if_version_below_4100 >>
|
||||
DECLARE
|
||||
current_db_version VARCHAR(100) := '';
|
||||
BEGIN
|
||||
SELECT
|
||||
value INTO current_db_version
|
||||
FROM
|
||||
systems
|
||||
WHERE
|
||||
name = 'Version';
|
||||
IF (string_to_array(current_db_version, '.') < string_to_array('4.10.0', '.')) THEN
|
||||
UPDATE Users SET AuthData=LOWER(AuthData) WHERE AuthService = 'saml';
|
||||
END IF;
|
||||
END migrate_if_version_below_4100
|
||||
$$;
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
column_exist boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO column_exist
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'users'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'roles'
|
||||
AND NOT data_type = 'varchar(256)';
|
||||
IF column_exist THEN
|
||||
ALTER TABLE users ALTER COLUMN roles TYPE varchar(256);
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_users_update_at ON users (updateat);
|
||||
CREATE INDEX IF NOT EXISTS idx_users_create_at ON users (createat);
|
||||
CREATE INDEX IF NOT EXISTS idx_users_delete_at ON users (deleteat);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_users_email_lower_textpattern ON users (lower(email) text_pattern_ops);
|
||||
CREATE INDEX IF NOT EXISTS idx_users_username_lower_textpattern ON users (lower(username) text_pattern_ops);
|
||||
CREATE INDEX IF NOT EXISTS idx_users_nickname_lower_textpattern ON users (lower(nickname) text_pattern_ops);
|
||||
CREATE INDEX IF NOT EXISTS idx_users_firstname_lower_textpattern ON users (lower(firstname) text_pattern_ops);
|
||||
CREATE INDEX IF NOT EXISTS idx_users_lastname_lower_textpattern ON users (lower(lastname) text_pattern_ops);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_users_all_txt ON users USING gin(to_tsvector('english', username || ' ' || firstname || ' ' || lastname || ' ' || nickname || ' ' || email));
|
||||
CREATE INDEX IF NOT EXISTS idx_users_all_no_full_name_txt ON users USING gin(to_tsvector('english', username || ' ' || nickname || ' ' || email));
|
||||
CREATE INDEX IF NOT EXISTS idx_users_names_txt ON users USING gin(to_tsvector('english', username || ' ' || firstname || ' ' || lastname || ' ' || nickname));
|
||||
CREATE INDEX IF NOT EXISTS idx_users_names_no_full_name_txt ON users USING gin(to_tsvector('english', username || ' ' || nickname));
|
||||
|
||||
DROP INDEX IF EXISTS idx_users_email_lower;
|
||||
DROP INDEX IF EXISTS idx_users_username_lower;
|
||||
DROP INDEX IF EXISTS idx_users_nickname_lower;
|
||||
DROP INDEX IF EXISTS idx_users_firstname_lower;
|
||||
DROP INDEX IF EXISTS idx_users_lastname_lower;
|
||||
|
||||
ALTER TABLE users ADD COLUMN IF NOT EXISTS remoteid VARCHAR(26);
|
||||
|
||||
DROP INDEX IF EXISTS idx_users_email;
|
||||
@@ -0,0 +1,14 @@
|
||||
ALTER TABLE fileinfo DROP COLUMN IF EXISTS remoteid;
|
||||
|
||||
DROP INDEX IF EXISTS idx_fileinfo_content_txt;
|
||||
ALTER TABLE fileinfo DROP COLUMN IF EXISTS content;
|
||||
ALTER TABLE fileinfo DROP COLUMN IF EXISTS minipreview;
|
||||
|
||||
DROP INDEX IF EXISTS idx_fileinfo_name_txt;
|
||||
DROP INDEX IF EXISTS idx_fileinfo_extension_at;
|
||||
DROP INDEX IF EXISTS idx_fileinfo_postid_at;
|
||||
DROP INDEX IF EXISTS idx_fileinfo_delete_at;
|
||||
DROP INDEX IF EXISTS idx_fileinfo_create_at;
|
||||
DROP INDEX IF EXISTS idx_fileinfo_update_at;
|
||||
|
||||
DROP TABLE IF EXISTS fileinfo;
|
||||
@@ -0,0 +1,33 @@
|
||||
CREATE TABLE IF NOT EXISTS fileinfo (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
creatorid VARCHAR(26),
|
||||
postid VARCHAR(26),
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
deleteat bigint,
|
||||
path VARCHAR(512),
|
||||
thumbnailpath VARCHAR(512),
|
||||
previewpath VARCHAR(512),
|
||||
name VARCHAR(256),
|
||||
extension VARCHAR(64),
|
||||
size bigint,
|
||||
mimetype VARCHAR(256),
|
||||
width integer,
|
||||
height integer,
|
||||
haspreviewimage boolean
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_fileinfo_update_at ON fileinfo (updateat);
|
||||
CREATE INDEX IF NOT EXISTS idx_fileinfo_create_at ON fileinfo (createat);
|
||||
CREATE INDEX IF NOT EXISTS idx_fileinfo_delete_at ON fileinfo (deleteat);
|
||||
CREATE INDEX IF NOT EXISTS idx_fileinfo_postid_at ON fileinfo (postid);
|
||||
CREATE INDEX IF NOT EXISTS idx_fileinfo_extension_at ON fileinfo (extension);
|
||||
CREATE INDEX IF NOT EXISTS idx_fileinfo_name_txt ON fileinfo USING gin(to_tsvector('english', name));
|
||||
|
||||
ALTER TABLE fileinfo ADD COLUMN IF NOT EXISTS minipreview bytea;
|
||||
ALTER TABLE fileinfo ADD COLUMN IF NOT EXISTS content text;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_fileinfo_content_txt ON fileinfo USING gin(to_tsvector('english', content));
|
||||
CREATE INDEX IF NOT EXISTS idx_fileinfo_name_splitted ON fileinfo USING gin (to_tsvector('english'::regconfig, translate((name)::text, '.,-'::text, ' '::text)));
|
||||
|
||||
ALTER TABLE fileinfo ADD COLUMN IF NOT EXISTS remoteid varchar(26);
|
||||
@@ -0,0 +1,6 @@
|
||||
ALTER TABLE oauthapps DROP COLUMN IF EXISTS iconurl;
|
||||
ALTER TABLE oauthapps DROP COLUMN IF EXISTS istrusted;
|
||||
|
||||
DROP INDEX IF EXISTS idx_oauthapps_creator_id;
|
||||
|
||||
DROP TABLE IF EXISTS oauthapps;
|
||||
@@ -0,0 +1,16 @@
|
||||
CREATE TABLE IF NOT EXISTS oauthapps (
|
||||
id VARCHAR(26) PRIMARY KEY,
|
||||
creatorid VARCHAR(26),
|
||||
createat bigint,
|
||||
updateat bigint,
|
||||
clientsecret VARCHAR(128),
|
||||
name VARCHAR(64),
|
||||
description VARCHAR(512),
|
||||
callbackurls VARCHAR(1024),
|
||||
homepage VARCHAR(256)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_oauthapps_creator_id ON oauthapps (creatorid);
|
||||
|
||||
ALTER TABLE oauthapps ADD COLUMN IF NOT EXISTS istrusted boolean;
|
||||
ALTER TABLE oauthapps ADD COLUMN IF NOT EXISTS iconurl VARCHAR(512);
|
||||
@@ -0,0 +1,61 @@
|
||||
CREATE INDEX IF NOT EXISTS idx_channels_name ON channels (name);
|
||||
|
||||
ALTER TABLE channels DROP COLUMN IF EXISTS shared;
|
||||
|
||||
DROP INDEX IF EXISTS idx_channels_scheme_id;
|
||||
|
||||
DO $$
|
||||
<<modify_column_type_if_type_is_different>>
|
||||
DECLARE
|
||||
col_exist_and_type_different boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO col_exist_and_type_different
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'channels'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'groupconstrained'
|
||||
AND NOT data_type = 'boolean';
|
||||
|
||||
IF col_exist_and_type_different THEN
|
||||
ALTER TABLE channels ALTER COLUMN groupconstrained TYPE boolean;
|
||||
END IF;
|
||||
END modify_column_type_if_type_is_different $$;
|
||||
|
||||
ALTER TABLE channels DROP COLUMN IF EXISTS groupconstrained;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_channels_txt ON channels (name,displayname);
|
||||
|
||||
ALTER TABLE channels DROP COLUMN IF EXISTS schemeid;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_channels_displayname ON channels (displayname);
|
||||
|
||||
DO $$
|
||||
<<modify_column_type_if_type_is_different>>
|
||||
DECLARE
|
||||
col_exist_and_type_different boolean := false;
|
||||
BEGIN
|
||||
SELECT count(*) != 0 INTO col_exist_and_type_different
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'channels'
|
||||
AND table_schema = current_schema()
|
||||
AND column_name = 'purpose'
|
||||
AND data_type = 'character varying'
|
||||
AND NOT character_maximum_length = 64;
|
||||
|
||||
IF col_exist_and_type_different THEN
|
||||
ALTER TABLE channels ALTER COLUMN purpose TYPE varchar(64);
|
||||
END IF;
|
||||
END modify_column_type_if_type_is_different $$;
|
||||
|
||||
DROP INDEX IF EXISTS idx_channels_displayname;
|
||||
DROP INDEX IF EXISTS idx_channels_txt;
|
||||
DROP INDEX IF EXISTS idx_channels_displayname_lower;
|
||||
DROP INDEX IF EXISTS idx_channels_name_lower;
|
||||
DROP INDEX IF EXISTS idx_channels_name;
|
||||
DROP INDEX IF EXISTS idx_channels_update_at;
|
||||
DROP INDEX IF EXISTS idx_channels_team_id;
|
||||
DROP INDEX IF EXISTS idx_channels_delete_at;
|
||||
DROP INDEX IF EXISTS idx_channels_create_at;
|
||||
DROP INDEX IF EXISTS idx_channel_search_txt;
|
||||
|
||||
DROP TABLE IF EXISTS channels;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user