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

333 lines
4.9 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
- artifacts
- pipeline_schedule
- merge_requests
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
- 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_project_link
- forked_from_project
- forked_project_links
- forks
- merge_requests
- fork_merge_requests
- issues
- labels
- events
- milestones
- notes
- snippets
- hooks
- protected_branches
- protected_tags
- project_members
- 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
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