mirror of
https://github.com/mattermost/focalboard.git
synced 2025-01-11 18:13:52 +02:00
03f4717e96
* WIP * Added migrations * Updating store method * WIP * WIP * Updated DND * WIP * WIP * WIP * WIP * WIP * wip * WIP * Adding new DB tool * Used migration functions in new migrations * Unique constraint migration * Unique constraint migration * Added SQLITE migrations * Added SQLITE support in few more migrations * Added SQLITE support in few more migrations * WIP * Used old-fashioned way to add unique constraint * Using oldsqlite method * Using oldsqlite method * Fixed all store and app layer tests * fixed integration tests * test and lint fix * Updated migration for MySQL and Postgres on personal server * Types fix * sqlite fix * fix typo * misc cleanup * added new tests * added new tests * de-duping input for postgres * integration tests, rmeoved uneeded migration * Added some migration tests * Added some migration tests * Fixed a test * completed migration tests * completed migration tests * Removed leftover debug statements Co-authored-by: Mattermost Build <build@mattermost.com> |
||
---|---|---|
.. | ||
000001_init.down.sql | ||
000001_init.up.sql | ||
000002_system_settings_table.down.sql | ||
000002_system_settings_table.up.sql | ||
000003_blocks_rootid.down.sql | ||
000003_blocks_rootid.up.sql | ||
000004_auth_table.down.sql | ||
000004_auth_table.up.sql | ||
000005_blocks_modifiedby.down.sql | ||
000005_blocks_modifiedby.up.sql | ||
000006_sharing_table.down.sql | ||
000006_sharing_table.up.sql | ||
000007_workspaces_table.down.sql | ||
000007_workspaces_table.up.sql | ||
000008_teams.down.sql | ||
000008_teams.up.sql | ||
000009_blocks_history.down.sql | ||
000009_blocks_history.up.sql | ||
000010_blocks_created_by.down.sql | ||
000010_blocks_created_by.up.sql | ||
000011_match_collation.down.sql | ||
000011_match_collation.up.sql | ||
000012_match_column_collation.down.sql | ||
000012_match_column_collation.up.sql | ||
000013_millisecond_timestamps.down.sql | ||
000013_millisecond_timestamps.up.sql | ||
000014_add_not_null_constraint.down.sql | ||
000014_add_not_null_constraint.up.sql | ||
000015_blocks_history_no_nulls.down.sql | ||
000015_blocks_history_no_nulls.up.sql | ||
000016_subscriptions_table.down.sql | ||
000016_subscriptions_table.up.sql | ||
000017_add_file_info.down.sql | ||
000017_add_file_info.up.sql | ||
000018_add_teams_and_boards.down.sql | ||
000018_add_teams_and_boards.up.sql | ||
000019_populate_categories.down.sql | ||
000019_populate_categories.up.sql | ||
000020_populate_category_blocks.down.sql | ||
000020_populate_category_blocks.up.sql | ||
000021_create_boards_members_history.down.sql | ||
000021_create_boards_members_history.up.sql | ||
000022_create_default_board_role.down.sql | ||
000022_create_default_board_role.up.sql | ||
000023_persist_category_collapsed_state.down.sql | ||
000023_persist_category_collapsed_state.up.sql | ||
000024_mark_existsing_categories_collapsed.down.sql | ||
000024_mark_existsing_categories_collapsed.up.sql | ||
000025_indexes_update.down.sql | ||
000025_indexes_update.up.sql | ||
000026_create_preferences_table.down.sql | ||
000026_create_preferences_table.up.sql | ||
000027_migrate_user_props_to_preferences.down.sql | ||
000027_migrate_user_props_to_preferences.up.sql | ||
000028_remove_template_channel_link.down.sql | ||
000028_remove_template_channel_link.up.sql | ||
000029_add_category_type_field.down.sql | ||
000029_add_category_type_field.up.sql | ||
000030_add_category_sort_order.down.sql | ||
000030_add_category_sort_order.up.sql | ||
000031_add_category_boards_sort_order.down.sql | ||
000031_add_category_boards_sort_order.up.sql | ||
000032_move_boards_category_to_end.down.sql | ||
000032_move_boards_category_to_end.up.sql | ||
000033_remove_deleted_category_boards.down.sql | ||
000033_remove_deleted_category_boards.up.sql | ||
000034_category_boards_remove_unused_delete_at_column.down.sql | ||
000034_category_boards_remove_unused_delete_at_column.up.sql | ||
000035_add_hidden_board_column.down.sql | ||
000035_add_hidden_board_column.up.sql | ||
000036_category_board_add_unique_constraint.down.sql | ||
000036_category_board_add_unique_constraint.up.sql | ||
000037_hidden_boards_from_preferences.down.sql | ||
000037_hidden_boards_from_preferences.up.sql | ||
000038_delete_hiddenBoardIDs_from_preferences.down.sql | ||
000038_delete_hiddenBoardIDs_from_preferences.up.sql | ||
README.md |
Migration Scripts
These scripts are executed against the current database on server start-up. Any scripts previously executed are skipped, however these scripts are designed to be idempotent for Postgres and MySQL. To correct common problems with schema and data migrations the focalboard_schema_migrations
table can be cleared of all records and the server restarted.
The following built-in variables are available:
Name | Syntax | Description |
---|---|---|
schemaName | {{ .schemaName }} | Returns the database/schema name (e.g. mattermost_ , mattermost_test , public , ...) |
prefix | {{ .prefix }} | Returns the table name prefix (e.g. focalbaord_ ) |
postgres | {{if .postgres }} ... {{end}} | Returns true if the current database is Postgres. |
sqlite | {{if .sqlite }} ... {{end}} | Returns true if the current database is Sqlite3. |
mysql | {{if .mysql }} ... {{end}} | Returns true if the current database is MySQL. |
plugin | {{if .plugin }} ... {{end}} | Returns true if the server is currently running as a plugin (or product). In others words this is true if the server is not running as stand-alone or personal server. |
singleUser | {{if .singleUser }} ... {{end}} | Returns true if the server is currently running in single user mode. |
To help with creating scripts that are idempotent some template functions have been added to the migration engine.
Name | Syntax | Description |
---|---|---|
addColumnIfNeeded | {{ addColumnIfNeeded schemaName tableName columnName datatype constraint }} | Adds column to table only if column doesn't already exist. |
dropColumnIfNeeded | {{ dropColumnIfNeeded schemaName tableName columnName }} | Drops column from table if the column exists. |
createIndexIfNeeded | {{ createIndexIfNeeded schemaName tableName columns }} | Creates an index if it does not already exist. The index name follows the existing convention of using idx_ plus the table name and all columns separated by underscores. |
renameTableIfNeeded | {{ renameTableIfNeeded schemaName oldTableName newTableName }} | Renames the table if the new table name does not exist. |
renameColumnIfNeeded | {{ renameColumnIfNeeded schemaName tableName oldVolumnName newColumnName datatype }} | Renames a column if the new column name does not exist. |
doesTableExist | {{if doesTableExist schemaName tableName }} ... {{end}} | Returns true if the table exists. Typically used in a if statement to conditionally include a section of script. Currently the existence of the table is determined before any scripts are executed (limitation of Morph). |
doesColumnExist | {{if doesTableExist schemaName tableName columnName }} ... {{end}} | Returns true if the column exists. Typically used in a if statement to conditionally include a section of script. Currently the existence of the column is determined before any scripts are executed (limitation of Morph). |
Note, table names should not include table prefix or schema name.
Examples
{{ addColumnIfNeeded .schemaName "categories" "type" "varchar(64)" ""}}
{{ addColumnIfNeeded .schemaName "boards_history" "minimum_role" "varchar(36)" "NOT NULL DEFAULT ''"}}
{{ dropColumnIfNeeded .schemaName "blocks_history" "workspace_id" }}
{{ createIndexIfNeeded .schemaName "boards" "team_id, is_template" }}
{{ renameTableIfNeeded .schemaName "blocks" "blocks_history" }}
{{ renameColumnIfNeeded .schemaName "blocks_history" "workspace_id" "channel_id" "varchar(36)" }}
{{if doesTableExist .schemaName "blocks_history" }}
SELECT 'table exists';
{{end}}
{{if not (doesTableExist .schemaName "blocks_history") }}
SELECT 1;
{{end}}
{{if doesColumnExist .schemaName "boards_history" "minimum_role"}}
UPDATE ...
{{end}}