@@ -7,7 +7,7 @@ be accessed without authentication if the repository is publicly accessible.
This command provides essentially the same functionality as the `git ls-tree` command. For more information, see the section _Tree Objects_ in the [Git internals documentation](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects/#_tree_objects).
```
```plaintext
GET /projects/:id/repository/tree
```
...
...
@@ -79,7 +79,7 @@ Allows you to receive information about blob in repository like size and
content. Note that blob content is Base64 encoded. This endpoint can be accessed
without authentication if the repository is publicly accessible.
```
```plaintext
GET /projects/:id/repository/blobs/:sha
```
...
...
@@ -93,7 +93,7 @@ Parameters:
Get the raw file contents for a blob by blob SHA. This endpoint can be accessed
without authentication if the repository is publicly accessible.
```
```plaintext
GET /projects/:id/repository/blobs/:sha/raw
```
...
...
@@ -107,7 +107,7 @@ Parameters:
Get an archive of the repository. This endpoint can be accessed without
authentication if the repository is publicly accessible.
This endpoint can be accessed without authentication if the repository is
publicly accessible. Note that diffs could have an empty diff string if [diff limits](../development/diffs.md#diff-limits) are reached.
```
```plaintext
GET /projects/:id/repository/compare
```
...
...
@@ -141,7 +141,7 @@ Parameters:
-`to` (required) - the commit SHA or branch name
-`straight` (optional) - comparison method, `true` for direct comparison between `from` and `to` (`from`..`to`), `false` to compare using merge base (`from`...`to`)'. Default is `false`.
```
```plaintext
GET /projects/:id/repository/compare?from=master&to=feature
```
...
...
@@ -186,7 +186,7 @@ Response:
Get repository contributors list. This endpoint can be accessed without
authentication if the repository is publicly accessible.
```
```plaintext
GET /projects/:id/repository/contributors
```
...
...
@@ -198,16 +198,16 @@ Parameters:
Response:
```
```json
[{
"name": "Dmitriy Zaporozhets",
"email": "dmitriy.zaporozhets@gmail.com",
"name":"Example User",
"email":"example@example.com",
"commits":117,
"additions":2097,
"deletions":517
},{
"name": "Jacob Vosmaer",
"email": "contact@jacobvosmaer.nl",
"name":"Sample User",
"email":"sample@example.com",
"commits":33,
"additions":338,
"deletions":244
...
...
@@ -218,7 +218,7 @@ Response:
Get the common ancestor for 2 or more refs (commit SHAs, branch names or tags).
@@ -20,7 +20,7 @@ Allows you to receive information about file in repository like name, size,
content. Note that file content is Base64 encoded. This endpoint can be accessed
without authentication if the repository is publicly accessible.
```
```plaintext
GET /projects/:id/repository/files/:file_path
```
...
...
@@ -55,7 +55,7 @@ NOTE: **Note:**
In addition to the `GET` method, you can also use `HEAD` to get just file metadata.
```
```plaintext
HEAD /projects/:id/repository/files/:file_path
```
...
...
@@ -84,7 +84,7 @@ X-Gitlab-Size: 1476
Allows you to receive blame information. Each blame range contains lines and corresponding commit info.
```
```plaintext
GET /projects/:id/repository/files/:file_path/blame
```
...
...
@@ -151,7 +151,7 @@ X-Gitlab-Size: 1476
## Get raw file from repository
```
```plaintext
GET /projects/:id/repository/files/:file_path/raw
```
...
...
@@ -171,7 +171,7 @@ Like [Get file from repository](repository_files.md#get-file-from-repository) yo
This allows you to create a single file. For creating multiple files with a single request see the [commits API](commits.html#create-a-commit-with-multiple-files-and-actions).
```
```plaintext
POST /projects/:id/repository/files/:file_path
```
...
...
@@ -206,7 +206,7 @@ Parameters:
This allows you to update a single file. For updating multiple files with a single request see the [commits API](commits.html#create-a-commit-with-multiple-files-and-actions).
```
```plaintext
PUT /projects/:id/repository/files/:file_path
```
...
...
@@ -252,7 +252,7 @@ Currently GitLab Shell has a boolean return code, preventing GitLab from specify
This allows you to delete a single file. For deleting multiple files with a single request, see the [commits API](commits.html#create-a-commit-with-multiple-files-and-actions).
| `access_level` | string | no | The access_level of the runner; `not_protected` or `ref_protected` |
| `maximum_timeout` | integer | no | Maximum timeout set when this Runner will handle the job |
```
```shell
curl --request PUT --header"PRIVATE-TOKEN: <your_access_token>""https://gitlab.example.com/api/v4/runners/6"--form"description=test-1-20150125-test"--form"tag_list=ruby,mysql,tag1,tag2"
| `access_level` | string | no | The access_level of the runner; `not_protected` or `ref_protected` |
| `maximum_timeout` | integer | no | Maximum timeout set when this Runner will handle the job |
```
```shell
curl --request POST "https://gitlab.example.com/api/v4/runners"--form"token=<registration_token>"--form"description=test-1-20150125-test"--form"tag_list=ruby,mysql,tag1,tag2"
# Adding foreign key constraint to an existing column
Foreign keys help ensure consistency between related database tables. The current database review process **always** encourages you to add [foreign keys](../foreign_keys.md) when creating tables that reference records from other tables.
Starting with Rails version 4, Rails includes migration helpers to add foreign key constraints to database tables. Before Rails 4, the only way for ensuring some level of consistency was the [`dependent`](https://guides.rubyonrails.org/association_basics.html#options-for-belongs-to-dependent) option within the association definition. Ensuring data consistency on the application level could fail in some unfortunate cases, so we might end up with inconsistent data in the table. This is mostly affecting older tables, where we simply didn't have the framework support to ensure consistency on the database level. These data inconsistencies can easily cause unexpected application behavior or bugs.
Adding a foreign key to an existing database column requires database structure changes and potential data changes. In case the table is in use, we should always assume that there is inconsistent data.
To add a foreign key constraint to an existing column:
1. GitLab version `N.M`: Add a `NOT VALID` foreign key constraint to the column to ensure GitLab doesn't create inconsistent records.
1. GitLab version `N.M`: Add a data migration, to fix or clean up existing records.
1. GitLab version `N.M+1`: Validate the whole table by making the foreign key `VALID`.
## Example
Consider the following table structures:
`users` table:
-`id` (integer, primary key)
-`name` (string)
`emails` table:
-`id` (integer, primary key)
-`user_id` (integer)
-`email` (string)
Express the relationship in `ActiveRecord`:
```ruby
classUser<ActiveRecord::Base
has_many:emails
end
classEmail<ActiveRecord::Base
belongs_to:user
end
```
Problem: when the user is removed, the email records related to the removed user will stay in the `emails` table:
```ruby
user=User.find(1)
user.destroy
emails=Email.where(user_id: 1)# returns emails for the deleted user
```
### Prevent invalid records
Add a `NOT VALID` foreign key constraint to the table, which enforces consistency on the record changes.
In the example above, you'd be still able to update records in the `emails` table. However, when you'd try to update the `user_id` with non-existent value, the constraint causes a database error.
Migration file for adding `NOT VALID` foreign key:
Avoid using the `add_foreign_key` constraint more than once per migration file, unless the source and target tables are identical.
#### Data migration to fix existing records
The approach here depends on the data volume and the cleanup strategy. If we can easily find "invalid" records by doing a simple database query and the record count is not that high, then the data migration can be executed within a Rails migration.
In case the data volume is higher (>1000 records), it's better to create a background migration. If unsure, please contact the database team for advice.
Example for cleaning up records in the `emails` table within a database migration: