Commit Graph

240 Commits

Author SHA1 Message Date
Jarka Košanová 19db315734 Add rake tasks for migrating leacy uploads
- move uploads created by AttachmentUploader
- handle also files created for legacy_diff_notes
2019-08-16 07:52:30 +02:00
David H. Wilkins afb3c3c1fb Add missing timezone to legacy artifacts (ci_builds)
- ci_builds.artifacts_expire_at are copied to
  ci_job_artifacts.expire_at with incorrect timestamps when the
  database timezone is NOT utc

- ci_builds.artifacts_expire_at is `timestamp without time zone` and
  ci_job_artifacts.expire_at is `timestamp with time zone` on
  postgresql

- Tests fail locally for `rspec
  ./spec/lib/gitlab/import_export/import_export_spec.rb` without this
  change
2019-08-04 12:33:37 -05:00
Andreas Brandl 988dc80585
Further remove code branches by database type
We dropped MySQL support and a lot of mysql specific code has been
removed in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/29608.

This comes in from the other direction and removes any `if postgresql?`
branches.
2019-07-29 12:47:06 +02:00
Peter Leitzen 8136fac26c Prefer `flat_map` over `map` + `flatten`
Convert several occurrences of `map` + `flatten` to
`flat_map` where applicable.
2019-07-26 10:44:13 +00:00
Heinrich Lee Yu 2b3d00a778 Remove unneeded monkey-patch
Changes all calls to data_source_exists? to table_exists?
since that is the intent of these calls
2019-07-25 12:21:38 +08:00
Nick Thomas 4aa76dddec
Remove dead MySQL code
None of this code can be reached any more, so it can all be removed
2019-07-23 16:53:03 +01:00
Vladimir Shushlin 6796dcf277 Fix wrong pages access level default
- Set access level in before_validation hook
- Add post migration for updating existing project_features
2019-07-17 12:56:58 +00:00
Adam Hegyi 4959d8fd49 Migrate null values for users.private_profile
- Background migration for changing null values to false
- Set false as default value for private_profile DB column
2019-07-15 21:07:54 +00:00
Andreas Brandl 5ea899d34f Merge branch 'id-clean-up-mr-assignees-migration' into 'master'
Add cleanup migration for MR's multiple assignees

See merge request gitlab-org/gitlab-ce!30269
2019-07-12 13:16:08 +00:00
Jan Provaznik 907154957e Merge branch 'bvl-rename-routes-after-user-rename' into 'master'
Set the name of a user-namespace to the user name

See merge request gitlab-org/gitlab-ce!23272
2019-07-12 12:59:38 +00:00
Mayra Cabrera 0ab89d8e36 Add a rubocop for Rails.logger
Suggests to use a JSON structured log instead

Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/54102
2019-07-10 19:26:47 +00:00
Bob Van Landuyt 82e6ed310b Fix incorrect namespaces & route for user-routes
This fixes the `Namespace#name` and `Route#name` for all user
namespaces and their personal projects in case they don't match the
user name anymore.

More info info in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23272
2019-07-09 18:09:45 +02:00
Igor Drozdov 184807b253 Add cleanup migration for MR's mutliple assignees
The migration steals the remaining background jobs
of populating MRs with assignees, executes them
synchronously and then makes sure that all the
assignees are migrated
2019-07-09 12:13:55 +03:00
Heinrich Lee Yu 28ac2d3049 Remove old migrations and specs
This removes old migrations that violate the
FactoriesinMigrationSpecs cop
2019-07-03 03:55:56 +08:00
Nick Thomas 351392f409
Remove background migrations for old schemas
On the assumption that a background migration whose specs need a schema
older than 2018 is obsoleted by this migration squash, we can remove
both specs and code for those that fail to run in CI as a result of the
schema at that date no longer existing.

This is true for all but the MigrateStageStatus background migration,
which is also used from the MigrateBuildStage background migration.
2019-07-02 09:35:03 +01:00
Yorick Peterse 8469f59d78
Backport the EE schema and migrations to CE
This backports all EE schema changes to CE, including EE migrations,
ensuring both use the same schema.

== Updated tests

A spec related to ghost and support bot users had to be modified to make
it pass. The spec in question assumes that the "support_bot" column
exists when defining the spec. In the single codebase setup this is not
the case, as the column is backported in a later migration. Any attempt
to use a different schema version or use of "around" blocks to
conditionally disable specs won't help, as reverting the backport
migration would also drop the "support_bot" column. Removing the
"support_bot" tests entirely appears to be the only solution.

We also need to update some foreign key tests now that we have
backported the EE columns. Fortunately, these changes are very minor.

== Backporting migrations

This commit moves EE specific migrations (except those for the Geo
tracking database) and related files to CE, and also removes any traces
of the ee/db directory.

Some migrations had to be modified or removed, as they no longer work
with the schema being backported. These migrations were all quite old,
so we opted for removing them where modifying them would take too much
time and effort.

Some old migrations were modified in EE, while also existing in CE. In
these cases we took the EE code, and in one case removed them entirely.
It's not worth spending time trying to merge these changes somehow as we
plan to remove old migrations around the release of 12.0, see
https://gitlab.com/gitlab-org/gitlab-ce/issues/59177 for more details.
2019-06-17 17:09:05 +02:00
Stan Hu b7e3a1e040 Revert "Merge branch '50070-legacy-attachments' into 'master'"
This reverts commit fd19f887df, reversing
changes made to abb2d4c601.
2019-06-09 05:56:11 -07:00
Kamil Trzciński fd19f887df Merge branch '50070-legacy-attachments' into 'master'
Migrate legacy uploads

Closes #57217

See merge request gitlab-org/gitlab-ce!24679
2019-06-07 09:50:46 +00:00
Vladimir Shushlin d1d05ae4f3 Add certificate valid time to pages domain table
Save certificate validity time for pages domains on save
Fill validity time for existing pages domains in background migration
2019-06-06 19:14:09 +00:00
Nick Thomas 10dcfac1f1 Revert "Merge branch 'pages-domain_ssl-valid-period' into 'master'"
This reverts merge request !28743
2019-06-06 13:57:50 +00:00
Jarka Košanová 3335918bff Migrate legacy uploads to the project location
Uploads coming from AttachmentUploader
need to be moved to the currently supported location
(FileUploader)
2019-06-06 15:33:04 +02:00
Vladimir Shushlin 3aab750d07 Add certificate valid time to pages domain table
Save certificate validity time for pages domains on save
Fill validity time for existing pages domains in background migration
2019-06-06 13:20:15 +00:00
Oswaldo Ferreira f3efec2029 Reset merge status from mergeable MRs
Adds migrations to reset the merge_status of opened,
mergeable MRs. That's required by
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/28513
so we're able to sync the status update along merge-ref,
without leaving MRs with a stale merge-ref.
2019-05-31 15:21:20 -03:00
Peter Marko 40490cc492 Add wiki size to project statistics 2019-05-29 16:08:25 +02:00
Yoginth 2f6a20ce66 Fix typos in the whole gitlab-ce project 2019-05-20 14:11:44 +00:00
Stan Hu f93b2e02a5 Run rubocop -a on CE files 2019-05-05 03:24:28 -07:00
Stan Hu 0f5b735685 Fix stage index migration failing in PostgreSQL 10
As discussed in
https://www.postgresql.org/message-id/9922.1353433645%40sss.pgh.pa.us,
the PostgreSQL window function last_value may not consider the
right rows:

Note that first_value, last_value, and nth_value consider only the rows
within the "window frame", which by default contains the rows from the
start of the partition through the last peer of the current row. This is
likely to give unhelpful results for last_value and sometimes also
nth_value. You can redefine the frame by adding a suitable frame
specification (RANGE or ROWS) to the OVER clause. See Section 4.2.8 for
more information about frame specifications.

This query could be fixed by adding `RANGE BETWEEN UNBOUNDED PRECEDING
AND UNBOUNDED FOLLOWING`, but that's quite verbose. It's simpler just to
use the first_value function.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/59985
2019-04-03 22:47:51 -07:00
Felipe Artur f2b7da4bf5 Remove additional logging 2019-04-01 15:05:52 -03:00
Felipe Artur b2fb3a9c62 Address review comments 2019-03-28 11:31:14 -03:00
Felipe Artur 16a3fea399 Merge master 2019-03-27 15:19:12 -03:00
Oswaldo Ferreira 929ee4d18d Add multiple assignees migration and table population
This will be further required for supporting multi-assignees MRs
2019-03-25 19:50:40 -03:00
Nick Thomas 9f05e97aad
Run rubocop -a 2019-03-13 13:42:43 +00:00
Andrew Newdigate 3288e1a874 Adds the Rubocop ReturnNil cop
This style change enforces `return if ...` instead of
`return nil if ...` to save maintainers a few minor review points
2019-03-06 17:51:56 +02:00
Kamil Trzciński c5f1f7f3db Use encrypted runner tokens
This makes code to support encrypted runner tokens.
This code also finished previously started encryption
process.
2019-03-06 12:18:53 +00:00
Felipe Artur 294c5c41be Remove auto vacuum logic, decrease batch size and interval 2019-03-01 16:24:47 -03:00
Felipe Artur 7bd066a1fa Address review comments 2019-02-19 14:00:53 -03:00
Felipe Artur 52155d8cf8 Add more specs and code improvements 2019-02-19 11:33:30 -03:00
Felipe Artur cc7a44c8e1 Make migrations reschedulable 2019-02-18 17:43:16 -03:00
Felipe Artur d88b44caad Fix typo 2019-02-18 12:00:14 -03:00
Felipe Artur a9886c7dd4 Fix rubocop 2019-02-18 11:51:44 -03:00
Felipe Artur b1346db3a0 Add Reschedulable module 2019-02-15 17:11:41 -02:00
Felipe Artur 37741c59a4 Split background migration for issues and merge requests 2019-02-14 11:48:20 -02:00
Felipe Artur 362d56e65a Schedule background migrations and specs 2019-02-12 14:40:37 -02:00
Felipe Artur e9b84f50e9 Migrate issuable states to integer patch 1
Patch 1 that migrates issues/merge requests states from integer to string.
On this commit we are only adding the state_id column and syncing it with a backgroud migration.

On Patch 2 the code to use the new integer column will be deployed and the old column will be
removed.
2019-02-11 15:48:40 -02:00
Rémy Coutable 3a2abc1d50
Enable the Layout/ExtraSpacing cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2019-01-24 13:05:45 +01:00
Toon Claes 83767dd0b3 Cleanup dead code and comments 2019-01-11 15:36:57 +01:00
Toon Claes 082cc12225 Fix failing spec with orphaned namespace 2019-01-11 15:36:57 +01:00
Toon Claes d3e028b85f Load all projects, namespaces, routes in 1 query
Avoid doing sequential database queries to load the namespaces and the
routes of projects and namespaces.

This results in the following query:

```sql
SELECT "projects"."id" AS t0_r0,
       "projects"."name" AS t0_r1,
       "projects"."path" AS t0_r2,
       "projects"."description" AS t0_r3,
       "projects"."created_at" AS t0_r4,
       "projects"."updated_at" AS t0_r5,
       "projects"."creator_id" AS t0_r6,
       "projects"."namespace_id" AS t0_r7,
       "projects"."last_activity_at" AS t0_r8,
       "projects"."import_url" AS t0_r9,
       "projects"."visibility_level" AS t0_r10,
       "projects"."archived" AS t0_r11,
       "projects"."avatar" AS t0_r12,
       "projects"."import_status" AS t0_r13,
       "projects"."star_count" AS t0_r14,
       "projects"."import_type" AS t0_r15,
       "projects"."import_source" AS t0_r16,
       "projects"."import_error" AS t0_r17,
       "projects"."ci_id" AS t0_r18,
       "projects"."shared_runners_enabled" AS t0_r19,
       "projects"."runners_token" AS t0_r20,
       "projects"."build_coverage_regex" AS t0_r21,
       "projects"."build_allow_git_fetch" AS t0_r22,
       "projects"."build_timeout" AS t0_r23,
       "projects"."pending_delete" AS t0_r24,
       "projects"."public_builds" AS t0_r25,
       "projects"."last_repository_check_failed" AS t0_r26,
       "projects"."last_repository_check_at" AS t0_r27,
       "projects"."container_registry_enabled" AS t0_r28,
       "projects"."only_allow_merge_if_pipeline_succeeds" AS t0_r29,
       "projects"."has_external_issue_tracker" AS t0_r30,
       "projects"."repository_storage" AS t0_r31,
       "projects"."request_access_enabled" AS t0_r32,
       "projects"."has_external_wiki" AS t0_r33,
       "projects"."ci_config_path" AS t0_r34,
       "projects"."lfs_enabled" AS t0_r35,
       "projects"."description_html" AS t0_r36,
       "projects"."only_allow_merge_if_all_discussions_are_resolved" AS t0_r37,
       "projects"."printing_merge_request_link_enabled" AS t0_r38,
       "projects"."auto_cancel_pending_pipelines" AS t0_r39,
       "projects"."import_jid" AS t0_r40,
       "projects"."cached_markdown_version" AS t0_r41,
       "projects"."delete_error" AS t0_r42,
       "projects"."last_repository_updated_at" AS t0_r43,
       "projects"."storage_version" AS t0_r44,
       "projects"."resolve_outdated_diff_discussions" AS t0_r45,
       "projects"."repository_read_only" AS t0_r46,
       "projects"."merge_requests_ff_only_enabled" AS t0_r47,
       "projects"."merge_requests_rebase_enabled" AS t0_r48,
       "projects"."jobs_cache_index" AS t0_r49,
       "projects"."pages_https_only" AS t0_r50,
       "projects"."remote_mirror_available_overridden" AS t0_r51,
       "projects"."pool_repository_id" AS t0_r52,
       "projects"."runners_token_encrypted" AS t0_r53,
       "projects"."bfg_object_map" AS t0_r54,
       "namespaces"."id" AS t1_r0,
       "namespaces"."name" AS t1_r1,
       "namespaces"."path" AS t1_r2,
       "namespaces"."owner_id" AS t1_r3,
       "namespaces"."created_at" AS t1_r4,
       "namespaces"."updated_at" AS t1_r5,
       "namespaces"."type" AS t1_r6,
       "namespaces"."description" AS t1_r7,
       "namespaces"."avatar" AS t1_r8,
       "namespaces"."share_with_group_lock" AS t1_r9,
       "namespaces"."visibility_level" AS t1_r10,
       "namespaces"."request_access_enabled" AS t1_r11,
       "namespaces"."description_html" AS t1_r12,
       "namespaces"."lfs_enabled" AS t1_r13,
       "namespaces"."parent_id" AS t1_r14,
       "namespaces"."require_two_factor_authentication" AS t1_r15,
       "namespaces"."two_factor_grace_period" AS t1_r16,
       "namespaces"."cached_markdown_version" AS t1_r17,
       "namespaces"."runners_token" AS t1_r18,
       "namespaces"."runners_token_encrypted" AS t1_r19,
       "routes"."id" AS t2_r0,
       "routes"."source_id" AS t2_r1,
       "routes"."source_type" AS t2_r2,
       "routes"."path" AS t2_r3,
       "routes"."created_at" AS t2_r4,
       "routes"."updated_at" AS t2_r5,
       "routes"."name" AS t2_r6,
       "routes_projects"."id" AS t3_r0,
       "routes_projects"."source_id" AS t3_r1,
       "routes_projects"."source_type" AS t3_r2,
       "routes_projects"."path" AS t3_r3,
       "routes_projects"."created_at" AS t3_r4,
       "routes_projects"."updated_at" AS t3_r5,
       "routes_projects"."name" AS t3_r6
FROM "projects"
LEFT OUTER JOIN "namespaces" ON "namespaces"."id" = "projects"."namespace_id"
LEFT OUTER JOIN "routes" ON "routes"."source_id" = "namespaces"."id"
AND "routes"."source_type" = $1
LEFT OUTER JOIN "routes" "routes_projects" ON "routes_projects"."source_id" = "projects"."id"
AND "routes_projects"."source_type" = $2
LEFT OUTER JOIN "project_repositories" ON "projects"."id" = "project_repositories"."project_id"
WHERE ("projects"."storage_version" IS NULL
       OR "projects"."storage_version" = 0)
  AND "project_repositories"."project_id" IS NULL
  AND ("projects"."id" BETWEEN $3 AND $4);
  -- [["source_type", "Namespace"],
  --  ["source_type", "Project"],
  --  ["id", 1],
  --  ["id", 4]]
```
2019-01-11 15:36:57 +01:00
Stan Hu 618875c58c Fix duplicate disk path in Backfill ProjectRepos
On GitLab.com, we saw numerous duplicate disk entry inserts because
the migration was not taking the routes table into account. We now
implement this in the migration to be consistent.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/56061
2019-01-11 15:36:51 +01:00
Douglas Barbosa Alexandre 754f66113e
Backfill project_repositories for legacy storage projects
Adds a background migration that will ensure all projects that
are on legacy storage have a row in `project_repositories`.
2018-12-18 21:13:38 -02:00