focalboard/server/services/store/sqlstore/migrations
2022-12-19 16:46:53 -07:00
..
000001_init.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000001_init.up.sql
000002_system_settings_table.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000002_system_settings_table.up.sql
000003_blocks_rootid.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000003_blocks_rootid.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000004_auth_table.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000004_auth_table.up.sql
000005_blocks_modifiedby.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000005_blocks_modifiedby.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000006_sharing_table.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000006_sharing_table.up.sql
000007_workspaces_table.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000007_workspaces_table.up.sql
000008_teams.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000008_teams.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000009_blocks_history.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000009_blocks_history.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000010_blocks_created_by.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000010_blocks_created_by.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000011_match_collation.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000011_match_collation.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000012_match_column_collation.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000012_match_column_collation.up.sql
000013_millisecond_timestamps.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000013_millisecond_timestamps.up.sql
000014_add_not_null_constraint.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000014_add_not_null_constraint.up.sql
000015_blocks_history_no_nulls.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000015_blocks_history_no_nulls.up.sql
000016_subscriptions_table.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000016_subscriptions_table.up.sql
000017_add_file_info.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000017_add_file_info.up.sql
000018_add_teams_and_boards.down.sql
000018_add_teams_and_boards.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000019_populate_categories.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000019_populate_categories.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000020_populate_category_blocks.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000020_populate_category_blocks.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000021_create_boards_members_history.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000021_create_boards_members_history.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000022_create_default_board_role.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000022_create_default_board_role.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000023_persist_category_collapsed_state.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000023_persist_category_collapsed_state.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000024_mark_existsing_categories_collapsed.down.sql rename migration 24 back to original name (#4367) 2022-12-19 16:46:53 -07:00
000024_mark_existsing_categories_collapsed.up.sql rename migration 24 back to original name (#4367) 2022-12-19 16:46:53 -07:00
000025_indexes_update.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000025_indexes_update.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000026_create_preferences_table.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000026_create_preferences_table.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000027_migrate_user_props_to_preferences.down.sql
000027_migrate_user_props_to_preferences.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000028_remove_template_channel_link.down.sql
000028_remove_template_channel_link.up.sql
000029_add_category_type_field.down.sql Set down migrations as noops and add CI job (#4186) 2022-11-10 17:04:40 +01:00
000029_add_category_type_field.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
000030_add_category_sort_order.down.sql Revert "Revert dnd (#4294)" (#4324) 2022-12-14 14:21:53 +05:30
000030_add_category_sort_order.up.sql Dnd remove default column value (#4337) 2022-12-19 14:37:51 -07:00
000031_add_category_boards_sort_order.down.sql Revert "Revert dnd (#4294)" (#4324) 2022-12-14 14:21:53 +05:30
000031_add_category_boards_sort_order.up.sql Dnd remove default column value (#4337) 2022-12-19 14:37:51 -07:00
000032_move_boards_category_to_end.down.sql Revert "Revert dnd (#4294)" (#4324) 2022-12-14 14:21:53 +05:30
000032_move_boards_category_to_end.up.sql Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00
README.md Idempotent schema and data migrations (#4253) 2022-12-16 11:15:38 -05:00

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}}