Update Snippets table to support Cells 1.0
### Problem [Table `snippets`](https://gitlab.com/gitlab-org/gitlab/blob/741fa2897bc752ffcfa5e1bf5e687d03cd6f0eca/db/structure.sql#L16118-16139) includes records for both `PersonalSnippets` (by `author_id`) and `ProjectSnippets` (by `project_id`). Unfortunately, this structure doesn't support Cells. * `ProjectSnippets` should have `cell-local` scope * `PersonalSnippets` should have `clusterwide` scope ### Old proposal <details><summary>Click to expand</summary> ### Proposal * Create a new table `personal_snippets` (or `project_snippets` depending on what is easier to migrate) ([see comment describing a similar approach for Uploads split](https://gitlab.com/gitlab-org/gitlab/-/issues/443573#note_1876123083)) * Migrate data to the new table and keep it in sync * Update Rails models to use both tables * Remove the old data from the original table * Define [`gitlab_schema` and `sharding_keys`](https://gitlab.com/gitlab-org/gitlab/blob/741fa2897bc752ffcfa5e1bf5e687d03cd6f0eca/db/docs/snippets.yml#L12) for both tables. ### Notes There are 3 more tables that depend on `snippets` (we probably need to split them too) * [snippet_repositories](https://gitlab.com/gitlab-org/gitlab/-/blob/master/db/docs/snippet_repositories.yml) * [snippet_statistics](https://gitlab.com/gitlab-org/gitlab/-/blob/master/db/docs/snippet_statistics.yml) * [snippet_user_mentions](https://gitlab.com/gitlab-org/gitlab/-/blob/master/db/docs/snippet_user_mentions.yml) </details> ### Proposal [Based on the suggestion](https://gitlab.com/gitlab-org/gitlab/-/issues/458098#note_1893583994) and [the blueprint](https://docs.gitlab.com/ee/architecture/blueprints/cells/impacted_features/snippets.html). We can migrate `PersonalSnippets` into `OrganizationSnippets` scope while keeping the backward compatibility for now. 1. Add a new field `organization_id` to `snippets` table with default organization id (id: 1) 2. For new personal snippets populate this field with user's organization id (or default organization) 3. Remove automatic assignment of default value from `organization_id` field 4. Define [a sharding key for snippets table](https://gitlab.com/gitlab-org/gitlab/-/issues/458098#note_1894907789) with `project_id`, `organization_id` combination.
epic