diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-17 15:10:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-17 15:10:08 +0300 |
commit | 8060e5c60901ab0f6b890414dccbdf5d1b95c3ad (patch) | |
tree | fc217fe53f68a45ea225c0d1b966642852d96321 /doc/administration/troubleshooting | |
parent | b9b58dba70466949d761132d2d96f0f24c0b469c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/administration/troubleshooting')
-rw-r--r-- | doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md b/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md index d730d62a0ce..f1775768aac 100644 --- a/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md +++ b/doc/administration/troubleshooting/gitlab_rails_cheat_sheet.md @@ -75,114 +75,6 @@ Benchmark.bm do |x| end ``` -## Projects - -### Clear a project's cache - -```ruby -ProjectCacheWorker.perform_async(project.id) -``` - -### Expire the .exists? cache - -```ruby -project.repository.expire_exists_cache -``` - -### Make all projects private - -```ruby -Project.update_all(visibility_level: 0) -``` - -### Find projects that are pending deletion - -```ruby -# -# This section lists all the projects which are pending deletion -# -projects = Project.where(pending_delete: true) -projects.each do |p| - puts "Project ID: #{p.id}" - puts "Project name: #{p.name}" - puts "Repository path: #{p.repository.full_path}" -end - -# -# Assign a user (the root user does) -# -user = User.find_by_username('root') - -# -# For each project listed repeat these two commands -# - -# Find the project, update the xxx-changeme values from above -project = Project.find_by_full_path('group-changeme/project-changeme') - -# Immediately delete the project -::Projects::DestroyService.new(project, user, {}).execute -``` - -### Destroy a project - -```ruby -project = Project.find_by_full_path('<project_path>') -user = User.find_by_username('<username>') -ProjectDestroyWorker.perform_async(project.id, user.id, {}) -# or ProjectDestroyWorker.new.perform(project.id, user.id, {}) -# or Projects::DestroyService.new(project, user).execute -``` - -If this fails, display why it doesn't work with: - -```ruby -project = Project.find_by_full_path('<project_path>') -project.delete_error -``` - -### Remove fork relationship manually - -```ruby -p = Project.find_by_full_path('<project_path>') -u = User.find_by_username('<username>') -::Projects::UnlinkForkService.new(p, u).execute -``` - -### Make a project read-only (can only be done in the console) - -```ruby -# Make a project read-only -project.repository_read_only = true; project.save - -# OR -project.update!(repository_read_only: true) -``` - -### Transfer project from one namespace to another - -```ruby -p = Project.find_by_full_path('<project_path>') - - # To set the owner of the project - current_user= p.creator - -# Namespace where you want this to be moved. -namespace = Namespace.find_by_full_path("<new_namespace>") - -::Projects::TransferService.new(p, current_user).execute(namespace) -``` - -### Find projects using an SQL query - -Find and store an array of projects based on an SQL query: - -```ruby -# Finds projects that end with '%ject' -projects = Project.find_by_sql("SELECT * FROM projects WHERE name LIKE '%ject'") -=> [#<Project id:12 root/my-first-project>>, #<Project id:13 root/my-second-project>>] -``` - ## Imports and exports ### Import a project |