Commit graph

17 commits

Author SHA1 Message Date
Z.J. van de Weg
e4d402427c Reject projects without namespace 2017-01-24 11:25:43 +01:00
Zeger-Jan van de Weg
5639c62b89 Quote class name in case it gets destroyed 2017-01-24 11:25:43 +01:00
Z.J. van de Weg
19b87fb4cc Requeue projects pending deletion
There have been several bugs in the project deletion service and worker.
Resulting in projects stuck in pending delete state, which limits users
to create projects with the same name, keeps stale records in the
database, and all kinds of other trouble.

This post deployment migration requeues all these projects for deletion,
in the hope that most of these could be removed by the updated code.
2017-01-24 11:25:42 +01:00
Yorick Peterse
c3a2d57415
Fill missing authorized projects rows
This ensures that the project_authorizations rows exist for all users
for which this data has not yet been populated.

Fixes #26194
2017-01-11 11:28:08 -05:00
Yorick Peterse
de321fbbb5
Remove the project_authorizations.id column
This column used to be a 32 bits integer, allowing for only a maximum of
2 147 483 647 rows. Given enough users one can hit this limit pretty
quickly, as was the case for GitLab.com.

Changing this type to bigint (= 64 bits) would give us more space, but
we'd eventually hit the same limit given enough users and projects. A
much more sustainable solution is to simply drop the "id" column.

There were only 2 lines of code depending on this column being present,
and neither truly required it to be present. Instead the code now uses
the "project_id" column combined with the "user_id" column. This means
that instead of something like this:

    DELETE FROM project_authorizations
    WHERE user_id = X
    AND id = Y;

We now run the following when removing rows:

    DELETE FROM project_authorizations
    WHERE user_id = X
    AND project_id = Y;

Since both user_id and project_id are indexed this should not slow down
the DELETE query.

This commit also removes the "dependent: destroy" clause from the
"project_authorizations" relation in the User and Project models.
Keeping this prevents Rails from being able to remove data as it relies
on an "id" column being present. Since the "project_authorizations"
table has proper foreign keys set up (with cascading removals) we don't
need to depend on any Rails logic.
2017-01-08 13:56:50 +01:00
Dmitriy Zaporozhets
3551a625a8
Whitelist next project names: assets, profile, public
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2017-01-06 11:14:17 +02:00
Dmitriy Zaporozhets
6024697c10 Merge branch 'master' into 'dz-rename-reserved-project-names'
# Conflicts:
#   db/schema.rb
2016-12-27 16:34:20 +00:00
Z.J. van de Weg
269bc74506 Disable timeout while removing services
On GitLab.com this migration could take about 3 minutes. Disabling the
statement we know we have enough time to complete this.

Fixes #25976
2016-12-27 11:10:15 +01:00
Yorick Peterse
2f93259c6b Removed return from reserved project migration
This return is redundant as the query now uses "WHERE EXISTS (...)" to
filter out projects without a namespace.
2016-12-24 19:39:51 +02:00
Yorick Peterse
dcea45015c Fix parallel renaming of reserved projects
This ensures threads don't re-use the same connection object, and use
fewer queries to perform the work.
2016-12-24 19:39:51 +02:00
Dmitriy Zaporozhets
d72b40423c Rename projects with reserved path names
We cant have project with name 'project' or 'tree' anymore.
This merge request containts a migration that will find and rename all
projects using reserved names by adding N digit to the end of the name.

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-12-24 19:39:51 +02:00
Z.J. van de Weg
1812d523a3 Remove unused services from the database
This adds a migration to remove unused services, where the properties
are empty. As the properties are empty, those do not contain any
settings or other information.

Fixes #25727
2016-12-21 15:11:03 +01:00
Timothy Andrew
eb434b15eb Make ChangePersonalAccessTokensDefaultBackToEmptyArray a "post" migration.
If we leave this as a regular migration, we could have the following flow:

1. Application knows nothing about scopes.
2. First migration runs, all existing personal access tokens have `api` scope
3. Application still knows nothing about scopes.
4. Second migration runs, all tokens created after this point have no scope
5. Application still knows nothing about scopes.
6. Tokens created at this time _should have the API scope, but instead have no scope_
7. Application code is reloaded, application knows about scopes
8. Tokens created after this point only have no scope if the user deliberately
   chooses to have no scopes.

Point #6 is the problem here. To avoid this, we move the second migration to a
"post" migration, which runs after the application code is deployed/reloaded.
2016-12-16 16:29:33 +05:30
Nick Thomas
16674d9b82 Fix a badly-performing migration 2016-11-15 17:07:58 +00:00
Alejandro Rodríguez
591f10f6bd Update 8.14-rc1 migrations to minimize downtime and deploy time
See https://gitlab.com/gitlab-org/gitlab-ce/issues/24386
2016-11-11 15:34:00 -03:00
Nick Thomas
2689428ac2 Fix project records with invalid visibility_level values
The AddVisibilityLevelToGroups migration introduced a visibility_level for
namespaces and specified that projects should always have a visibility level
less than or equal to their namespace. However, some invalid rows could have
been created.

This commit introduces a migration that updates the invalid rows, setting the
invalid project to have the same visibility_level as their namespaces. This
will make some projects internal or private when they would previously have
been public or internal, but this is better than silently making an internal
or private group public.
2016-11-10 17:58:31 +00:00
Yorick Peterse
83c8241160
Support for post deployment migrations
These are regular Rails migrations that are executed by default. A user
can opt-out of these migrations by setting an environment variable
during the deployment process.

Fixes gitlab-org/gitlab-ce#22133
2016-10-31 12:54:48 +01:00