gitlab-org--gitlab-foss/spec/lib/gitlab/import_export/all_models.yml

338 lines
5.0 KiB
YAML
Raw Normal View History

---
issues:
- subscriptions
- award_emoji
- author
- assignees
- updated_by
- milestone
- notes
2018-08-01 08:58:49 +00:00
- resource_label_events
- label_links
- labels
2017-05-05 05:39:26 +00:00
- last_edited_by
- todos
- user_agent_detail
- moved_to
- events
2016-09-21 11:01:46 +00:00
- merge_requests_closing_issues
- metrics
- timelogs
- issue_assignees
2018-03-01 14:42:50 +00:00
- closed_by
events:
- author
- project
- target
Migrate events into a new format This commit migrates events data in such a way that push events are stored much more efficiently. This is done by creating a shadow table called "events_for_migration", and a table called "push_event_payloads" which is used for storing push data of push events. The background migration in this commit will copy events from the "events" table into the "events_for_migration" table, push events in will also have a row created in "push_event_payloads". This approach allows us to reclaim space in the next release by simply swapping the "events" and "events_for_migration" tables, then dropping the old events (now "events_for_migration") table. The new table structure is also optimised for storage space, and does not include the unused "title" column nor the "data" column (since this data is moved to "push_event_payloads"). == Newly Created Events Newly created events are inserted into both "events" and "events_for_migration", both using the exact same primary key value. The table "push_event_payloads" in turn has a foreign key to the _shadow_ table. This removes the need for recreating and validating the foreign key after swapping the tables. Since the shadow table also has a foreign key to "projects.id" we also don't have to worry about orphaned rows. This approach however does require some additional storage as we're duplicating a portion of the events data for at least 1 release. The exact amount is hard to estimate, but for GitLab.com this is expected to be between 10 and 20 GB at most. The background migration in this commit deliberately does _not_ update the "events" table as doing so would put a lot of pressure on PostgreSQL's auto vacuuming system. == Supporting Both Old And New Events Application code has also been adjusted to support push events using both the old and new data formats. This is done by creating a PushEvent class which extends the regular Event class. Using Rails' Single Table Inheritance system we can ensure the right class is used for the right data, which in this case is based on the value of `events.action`. To support displaying old and new data at the same time the PushEvent class re-defines a few methods of the Event class, falling back to their original implementations for push events in the old format. Once all existing events have been migrated the various push event related methods can be removed from the Event model, and the calls to `super` can be removed from the methods in the PushEvent model. The UI and event atom feed have also been slightly changed to better handle this new setup, fortunately only a few changes were necessary to make this work. == API Changes The API only displays push data of events in the new format. Supporting both formats in the API is a bit more difficult compared to the UI. Since the old push data was not really well documented (apart from one example that used an incorrect "action" nmae) I decided that supporting both was not worth the effort, especially since events will be migrated in a few days _and_ new events are created in the correct format.
2017-07-10 15:43:57 +00:00
- push_event_payload
notes:
- award_emoji
- project
- noteable
- author
- updated_by
2017-05-05 05:39:26 +00:00
- last_edited_by
- resolved_by
- todos
- events
- system_note_metadata
- note_diff_file
label_links:
- target
- label
label:
- subscriptions
- project
- lists
- label_links
- issues
- merge_requests
- priorities
milestone:
2017-07-07 15:08:49 +00:00
- group
- project
- issues
- labels
- merge_requests
- participants
- events
snippets:
- author
- project
- notes
- award_emoji
- user_agent_detail
releases:
- project
project_members:
- created_by
- user
- source
- project
merge_requests:
- subscriptions
- award_emoji
- author
- assignee
- updated_by
- milestone
- notes
2018-08-01 08:58:49 +00:00
- resource_label_events
- label_links
- labels
2017-05-05 05:39:26 +00:00
- last_edited_by
- todos
- target_project
- source_project
- merge_user
- merge_request_diffs
- merge_request_diff
- events
2016-09-21 11:01:46 +00:00
- merge_requests_closing_issues
- cached_closes_issues
2016-09-21 11:01:46 +00:00
- metrics
- timelogs
2017-03-22 19:36:14 +00:00
- head_pipeline
Use latest_merge_request_diff association Compared to the merge_request_diff association: 1. It's simpler to query. The query uses a foreign key to the merge_request_diffs table, so no ordering is necessary. 2. It's faster for preloading. The merge_request_diff association has to load every diff for the MRs in the set, then discard all but the most recent for each. This association means that Rails can just query for N diffs from N MRs. 3. It's more complicated to update. This is a bidirectional foreign key, so we need to update two tables when adding a diff record. This also means we need to handle this as a special case when importing a GitLab project. There is some juggling with this association in the merge request model: * `MergeRequest#latest_merge_request_diff` is _always_ the latest diff. * `MergeRequest#merge_request_diff` reuses `MergeRequest#latest_merge_request_diff` unless: * Arguments are passed. These are typically to force-reload the association. * It doesn't exist. That means we might be trying to implicitly create a diff. This only seems to happen in specs. * The association is already loaded. This is important for the reasons explained in the comment, which I'll reiterate here: if we a) load a non-latest diff, then b) get its `merge_request`, then c) get that MR's `merge_request_diff`, we should get the diff we loaded in c), even though that's not the latest diff. Basically, `MergeRequest#merge_request_diff` is the latest diff in most cases, but not quite all.
2017-11-15 17:22:18 +00:00
- latest_merge_request_diff
merge_request_diff:
- merge_request
- merge_request_diff_commits
- merge_request_diff_files
merge_request_diff_commits:
- merge_request_diff
merge_request_diff_files:
- merge_request_diff
pipelines:
- project
- user
- stages
- statuses
- builds
- trigger_requests
2017-07-26 09:31:09 +00:00
- variables
2017-03-19 15:47:37 +00:00
- auto_canceled_by
- auto_canceled_pipelines
- auto_canceled_jobs
2017-04-06 19:37:28 +00:00
- pending_builds
- retryable_builds
- cancelable_statuses
- manual_actions
2018-10-02 09:10:58 +00:00
- scheduled_actions
2017-04-06 19:37:28 +00:00
- artifacts
- pipeline_schedule
- merge_requests
Squashed commit of the following: commit 04b06a2293fa12660a9c213a9db27fe90b83248b Merge: d580841d4ed a445aa0a926 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Dec 3 10:51:55 2018 +0900 Merge branch 'master-ce' into fix-mr-widget-unrelated-deployment-status commit d580841d4ed944f01e6417fa77842826843b6a04 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Nov 30 18:11:04 2018 +0900 Add environment to all_models.yml commit 689fbe2699a3adf10804312e680fa336e4560eaf Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Nov 30 17:00:35 2018 +0900 Proper way to get uniq relationship commit c0733c6ecd535a6a1b6243080a2226836890f479 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Nov 30 16:20:40 2018 +0900 Revert build change commit 19dc55a8fe6e0fa575858d51144516b7fb0120de Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Nov 30 16:19:18 2018 +0900 Add uniq option commit 0a6995f311c09b453fd0aecff2f6052de38efc27 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Nov 30 16:14:30 2018 +0900 Drop persisted_environment commit 3f68fc783b0ee0d66e03de6d979616c4c4892118 Author: Shinya Maeda <shinya@gitlab.com> Date: Wed Nov 28 13:59:04 2018 +0900 Return empty array if pipeline is nil commit 73801c5c3d06339e38dce7461a71285bcdbb8f45 Author: Shinya Maeda <shinya@gitlab.com> Date: Tue Nov 27 16:34:47 2018 +0900 Add changelog commit d461699abf2835cc51949a5138e829628209dd6d Author: Shinya Maeda <shinya@gitlab.com> Date: Tue Nov 27 16:32:20 2018 +0900 Squashed commit of the following: commit 77ab5259605e217a39b04d2cea6204277e42d2b5 Merge: 7ac1ed50612 2ee8c40fc16 Author: Shinya Maeda <shinya@gitlab.com> Date: Tue Nov 27 16:31:07 2018 +0900 Merge branch 'master-ce' into fix-mr-widget-unrelated-deployment-status commit 7ac1ed50612620df6408220b0a7cfcb626a04c48 Merge: 49ba5c5aeff b55aeca25e7 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Nov 26 20:01:43 2018 +0900 Merge branch 'master-ce' into fix-mr-widget-unrelated-deployment-status commit 49ba5c5aeff3efee7b7498d443372021c3f4f8b5 Merge: aa3fd0ff9e8 fbbe5ccd1be Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Nov 26 15:27:36 2018 +0900 Merge branch 'master-ce' into fix-mr-widget-unrelated-deployment-status commit aa3fd0ff9e8a418a233ebaa60b38c081cab50099 Author: Shinya Maeda <shinya@gitlab.com> Date: Tue Nov 20 18:28:53 2018 +0900 Fix static analysis commit 7afe5f37003869a73dbb297229f8533f78b82684 Merge: e65b9580ff4 8a581d531ba Author: Shinya Maeda <shinya@gitlab.com> Date: Tue Nov 20 18:27:33 2018 +0900 Merge branch 'master-ce' into fix-mr-widget-unrelated-deployment-status commit e65b9580ff422359113e1a4e37c212f7b13aba4d Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Nov 19 17:59:48 2018 +0900 Ignore deployments from project import/export commit 9eb4ddab8415c1ef61a3c646bdc4602bcf4ebe24 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Nov 19 16:26:00 2018 +0900 Add memoization commit 57f0bea3aaaa07b75d18e52068c532277350cda0 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Nov 19 16:21:39 2018 +0900 Fix unrelated deployment status in MR widget
2018-12-03 06:46:45 +00:00
- deployments
- environments
2017-07-26 09:31:09 +00:00
pipeline_variables:
- pipeline
stages:
- project
- pipeline
- statuses
- builds
statuses:
- project
- pipeline
- stage
- user
- auto_canceled_by
variables:
- project
triggers:
- project
- trigger_requests
2017-03-05 20:23:57 +00:00
- owner
pipeline_schedules:
- project
- owner
- pipelines
- last_pipeline
2017-07-03 13:13:10 +00:00
- variables
pipeline_schedule:
- pipelines
pipeline_schedule_variables:
- pipeline_schedule
deploy_tokens:
- project_deploy_tokens
- projects
deploy_keys:
- user
- deploy_keys_projects
- projects
services:
- project
- service_hook
hooks:
- project
- web_hook_logs
protected_branches:
- project
- merge_access_levels
- push_access_levels
protected_tags:
- project
- create_access_levels
2016-09-21 11:01:46 +00:00
merge_access_levels:
- protected_branch
push_access_levels:
- protected_branch
create_access_levels:
- user
- protected_tag
- group
container_repositories:
- project
2016-12-16 03:24:05 +00:00
- name
project:
- taggings
- base_tags
- tag_taggings
- tags
2016-11-18 10:38:54 +00:00
- chat_services
- cluster
2017-11-06 17:06:02 +00:00
- clusters
2017-11-03 11:26:38 +00:00
- cluster_project
- cluster_ingresses
- creator
- group
- namespace
- boards
- last_event
- services
- campfire_service
2018-10-30 11:23:20 +00:00
- discord_service
- drone_ci_service
- emails_on_push_service
- pipelines_email_service
- mattermost_slash_commands_service
2016-12-18 22:32:53 +00:00
- slack_slash_commands_service
- irker_service
2017-09-21 20:05:44 +00:00
- packagist_service
- pivotaltracker_service
- prometheus_service
- hipchat_service
- flowdock_service
- assembla_service
- asana_service
- slack_service
- microsoft_teams_service
- mattermost_service
- hangouts_chat_service
- buildkite_service
- bamboo_service
- teamcity_service
- pushover_service
- jira_service
- redmine_service
- custom_issue_tracker_service
- bugzilla_service
- gitlab_issue_tracker_service
- external_wiki_service
- kubernetes_service
- mock_ci_service
- mock_deployment_service
- mock_monitoring_service
- forked_to_members
- forked_from_project
- forks
- merge_requests
- fork_merge_requests
- issues
- labels
- events
- milestones
- notes
- snippets
- hooks
- protected_branches
- protected_tags
- project_members
- project_repository
- users
- requesters
- deploy_keys_projects
- deploy_keys
- users_star_projects
- starrers
- releases
- lfs_objects_projects
- lfs_objects
- project_group_links
- invited_groups
- todos
- notification_settings
- import_data
- commit_statuses
- pipelines
- stages
- builds
- runner_projects
- runners
- variables
- triggers
- pipeline_schedules
- environments
- deployments
- project_feature
- auto_devops
- pages_domains
- authorized_users
- project_authorizations
- remote_mirrors
- route
- redirect_routes
- statistics
- container_repositories
- uploads
- import_state
- members_and_requesters
2017-09-25 16:54:08 +00:00
- build_trace_section_names
- build_trace_chunks
- root_of_fork_network
- fork_network_member
- fork_network
2017-09-18 13:03:24 +00:00
- custom_attributes
2018-09-04 09:55:45 +00:00
- prometheus_metrics
2018-02-07 13:00:53 +00:00
- lfs_file_locks
2018-03-05 17:51:40 +00:00
- project_badges
- source_of_merge_requests
- internal_ids
- project_deploy_tokens
- deploy_tokens
- settings
- ci_cd_settings
- import_export_upload
- repository_languages
2018-10-19 03:44:41 +00:00
- pool_repository
award_emoji:
- awardable
- user
priorities:
2016-11-18 10:38:54 +00:00
- label
2018-09-04 09:55:45 +00:00
prometheus_metrics:
- project
timelogs:
- issue
- merge_request
- user
Migrate events into a new format This commit migrates events data in such a way that push events are stored much more efficiently. This is done by creating a shadow table called "events_for_migration", and a table called "push_event_payloads" which is used for storing push data of push events. The background migration in this commit will copy events from the "events" table into the "events_for_migration" table, push events in will also have a row created in "push_event_payloads". This approach allows us to reclaim space in the next release by simply swapping the "events" and "events_for_migration" tables, then dropping the old events (now "events_for_migration") table. The new table structure is also optimised for storage space, and does not include the unused "title" column nor the "data" column (since this data is moved to "push_event_payloads"). == Newly Created Events Newly created events are inserted into both "events" and "events_for_migration", both using the exact same primary key value. The table "push_event_payloads" in turn has a foreign key to the _shadow_ table. This removes the need for recreating and validating the foreign key after swapping the tables. Since the shadow table also has a foreign key to "projects.id" we also don't have to worry about orphaned rows. This approach however does require some additional storage as we're duplicating a portion of the events data for at least 1 release. The exact amount is hard to estimate, but for GitLab.com this is expected to be between 10 and 20 GB at most. The background migration in this commit deliberately does _not_ update the "events" table as doing so would put a lot of pressure on PostgreSQL's auto vacuuming system. == Supporting Both Old And New Events Application code has also been adjusted to support push events using both the old and new data formats. This is done by creating a PushEvent class which extends the regular Event class. Using Rails' Single Table Inheritance system we can ensure the right class is used for the right data, which in this case is based on the value of `events.action`. To support displaying old and new data at the same time the PushEvent class re-defines a few methods of the Event class, falling back to their original implementations for push events in the old format. Once all existing events have been migrated the various push event related methods can be removed from the Event model, and the calls to `super` can be removed from the methods in the PushEvent model. The UI and event atom feed have also been slightly changed to better handle this new setup, fortunately only a few changes were necessary to make this work. == API Changes The API only displays push data of events in the new format. Supporting both formats in the API is a bit more difficult compared to the UI. Since the old push data was not really well documented (apart from one example that used an incorrect "action" nmae) I decided that supporting both was not worth the effort, especially since events will be migrated in a few days _and_ new events are created in the correct format.
2017-07-10 15:43:57 +00:00
push_event_payload:
- event
2017-10-31 15:13:09 +00:00
issue_assignees:
- issue
2017-11-06 17:06:02 +00:00
- assignee
2018-02-07 13:00:53 +00:00
lfs_file_locks:
- user
2018-03-05 17:51:40 +00:00
project_badges:
- project
metrics:
- merge_request
- latest_closed_by
- merged_by
- pipeline
resource_label_events:
- user
- issue
- merge_request
- epic
- label