Skip to content

Commit

Permalink
Move migrating repository from frontend to backend (#6200)
Browse files Browse the repository at this point in the history
* move migrating to backend

* add loading image when migrating and fix tests

* fix format

* fix lint

* add redis task queue support and improve docs

* add redis vendor

* fix vet

* add database migrations and fix app.ini sample

* add comments for task section on app.ini.sample

* Update models/migrations/v84.go

Co-Authored-By: lunny <xiaolunwen@gmail.com>

* Update models/repo.go

Co-Authored-By: lunny <xiaolunwen@gmail.com>

* move migrating to backend

* add loading image when migrating and fix tests

* fix fmt

* add redis task queue support and improve docs

* fix fixtures

* fix fixtures

* fix duplicate function on index.js

* fix tests

* rename repository statuses

* check if repository is being create when SSH request

* fix lint

* fix template

* some improvements

* fix template

* unified migrate options

* fix lint

* fix loading page

* refactor

* When gitea restart, don't restart the running tasks because we may have servel gitea instances, that may break the migration

* fix js

* Update models/repo.go

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

* fix tests

* rename ErrTaskIsNotExist to ErrTaskDoesNotExist

* delete release after add one on tests to make it run happy

* fix tests

* fix tests

* improve codes

* fix lint

* fix lint

* fix migrations
  • Loading branch information
lunny committed Oct 13, 2019
1 parent 0a96e59 commit f2a3abc
Show file tree
Hide file tree
Showing 37 changed files with 1,180 additions and 210 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ prime/
*.snap
*.snap-build
*_source.tar.bz2
.DS_Store
9 changes: 9 additions & 0 deletions custom/conf/app.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -808,3 +808,12 @@ IS_INPUT_FILE = false
ENABLED = false
; If you want to add authorization, specify a token here
TOKEN =

[task]
; Task queue type, could be `channel` or `redis`.
QUEUE_TYPE = channel
; Task queue length, available only when `QUEUE_TYPE` is `channel`.
QUEUE_LENGTH = 1000
; Task queue connction string, available only when `QUEUE_TYPE` is `redis`.
; If there is a password of redis, use `addrs=127.0.0.1:6379 password=123 db=0`.
QUEUE_CONN_STR = "addrs=127.0.0.1:6379 db=0"
7 changes: 7 additions & 0 deletions docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,16 @@ Two special environment variables are passed to the render command:
- `GITEA_PREFIX_RAW`, which contains the current URL prefix in the `raw` path tree. To be used as prefix for image paths.

## Time (`time`)

- `FORMAT`: Time format to diplay on UI. i.e. RFC1123 or 2006-01-02 15:04:05
- `DEFAULT_UI_LOCATION`: Default location of time on the UI, so that we can display correct user's time on UI. i.e. Shanghai/Asia

## Task (`task`)

- `QUEUE_TYPE`: **channel**: Task queue type, could be `channel` or `redis`.
- `QUEUE_LENGTH`: **1000**: Task queue length, available only when `QUEUE_TYPE` is `channel`.
- `QUEUE_CONN_STR`: **addrs=127.0.0.1:6379 db=0**: Task queue connection string, available only when `QUEUE_TYPE` is `redis`. If there redis needs a password, use `addrs=127.0.0.1:6379 password=123 db=0`.

## Other (`other`)

- `SHOW_FOOTER_BRANDING`: **false**: Show Gitea branding in the footer.
Expand Down
7 changes: 7 additions & 0 deletions docs/content/doc/advanced/config-cheat-sheet.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,16 @@ IS_INPUT_FILE = false
- IS_INPUT_FILE: 输入方式是最后一个参数为文件路径还是从标准输入读取。

## Time (`time`)

- `FORMAT`: 显示在界面上的时间格式。比如: RFC1123 或者 2006-01-02 15:04:05
- `DEFAULT_UI_LOCATION`: 默认显示在界面上的时区,默认为本地时区。比如: Asia/Shanghai

## Task (`task`)

- `QUEUE_TYPE`: **channel**: 任务队列类型,可以为 `channel``redis`
- `QUEUE_LENGTH`: **1000**: 任务队列长度,当 `QUEUE_TYPE``channel` 时有效。
- `QUEUE_CONN_STR`: **addrs=127.0.0.1:6379 db=0**: 任务队列连接字符串,当 `QUEUE_TYPE``redis` 时有效。如果redis有密码,则可以 `addrs=127.0.0.1:6379 password=123 db=0`

## Other (`other`)

- `SHOW_FOOTER_BRANDING`: 为真则在页面底部显示Gitea的字样。
Expand Down
43 changes: 42 additions & 1 deletion models/fixtures/repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
num_milestones: 3
num_closed_milestones: 1
num_watches: 3
status: 0

-
id: 2
Expand All @@ -24,6 +25,7 @@
num_closed_pulls: 0
num_stars: 1
close_issues_via_commit_in_any_branch: true
status: 0

-
id: 3
Expand All @@ -36,6 +38,7 @@
num_pulls: 0
num_closed_pulls: 0
num_watches: 0
status: 0

-
id: 4
Expand All @@ -48,6 +51,7 @@
num_pulls: 0
num_closed_pulls: 0
num_stars: 1
status: 0

-
id: 5
Expand All @@ -61,6 +65,7 @@
num_closed_pulls: 0
num_watches: 0
is_mirror: true
status: 0

-
id: 6
Expand All @@ -73,6 +78,7 @@
num_pulls: 0
num_closed_pulls: 0
is_mirror: false
status: 0

-
id: 7
Expand All @@ -85,6 +91,7 @@
num_pulls: 0
num_closed_pulls: 0
is_mirror: false
status: 0

-
id: 8
Expand All @@ -97,6 +104,7 @@
num_pulls: 0
num_closed_pulls: 0
is_mirror: false
status: 0

-
id: 9
Expand All @@ -109,6 +117,7 @@
num_pulls: 0
num_closed_pulls: 0
is_mirror: false
status: 0

-
id: 10
Expand All @@ -122,6 +131,7 @@
num_closed_pulls: 0
is_mirror: false
num_forks: 1
status: 0

-
id: 11
Expand All @@ -135,6 +145,7 @@
num_pulls: 0
num_closed_pulls: 0
is_mirror: false
status: 0

-
id: 12
Expand All @@ -147,6 +158,7 @@
num_pulls: 0
num_closed_pulls: 0
is_mirror: false
status: 0

-
id: 13
Expand All @@ -159,6 +171,7 @@
num_pulls: 0
num_closed_pulls: 0
is_mirror: false
status: 0

-
id: 14
Expand All @@ -172,13 +185,15 @@
num_pulls: 0
num_closed_pulls: 0
is_mirror: false
status: 0

-
id: 15
owner_id: 2
lower_name: repo15
name: repo15
is_empty: true
status: 0

-
id: 16
Expand All @@ -191,6 +206,7 @@
num_pulls: 0
num_closed_pulls: 0
num_watches: 0
status: 0

-
id: 17
Expand All @@ -205,6 +221,7 @@
num_watches: 0
is_mirror: false
is_fork: false
status: 0

-
id: 18
Expand All @@ -218,6 +235,7 @@
num_closed_pulls: 0
is_mirror: false
is_fork: false
status: 0

-
id: 19
Expand All @@ -231,6 +249,7 @@
num_closed_pulls: 0
is_mirror: false
is_fork: false
status: 0

-
id: 20
Expand All @@ -244,6 +263,7 @@
num_closed_pulls: 0
is_mirror: false
is_fork: false
status: 0

-
id: 21
Expand All @@ -257,6 +277,7 @@
num_closed_pulls: 0
is_mirror: false
is_fork: false
status: 0

-
id: 22
Expand All @@ -270,6 +291,7 @@
num_closed_pulls: 0
is_mirror: false
is_fork: false
status: 0

-
id: 23
Expand All @@ -283,6 +305,7 @@
num_closed_pulls: 0
is_mirror: false
is_fork: false
status: 0

-
id: 24
Expand All @@ -296,6 +319,7 @@
num_closed_pulls: 0
is_mirror: false
is_fork: false
status: 0

-
id: 25
Expand All @@ -310,6 +334,7 @@
num_watches: 0
is_mirror: true
is_fork: false
status: 0

-
id: 26
Expand All @@ -324,6 +349,7 @@
num_watches: 0
is_mirror: true
is_fork: false
status: 0

-
id: 27
Expand All @@ -339,6 +365,7 @@
is_mirror: true
num_forks: 1
is_fork: false
status: 0

-
id: 28
Expand All @@ -354,6 +381,7 @@
is_mirror: true
num_forks: 1
is_fork: false
status: 0

-
id: 29
Expand All @@ -368,6 +396,7 @@
num_closed_pulls: 0
is_mirror: false
is_fork: true
status: 0

-
id: 30
Expand All @@ -382,6 +411,7 @@
num_closed_pulls: 0
is_mirror: false
is_fork: true
status: 0

-
id: 31
Expand All @@ -392,6 +422,7 @@
num_forks: 0
num_issues: 0
is_mirror: false
status: 0

-
id: 32 # org public repo
Expand All @@ -403,13 +434,15 @@
num_forks: 0
num_issues: 0
is_mirror: false
status: 0

-
id: 33
owner_id: 2
lower_name: utf8
name: utf8
is_private: false
status: 0

-
id: 34
Expand All @@ -421,6 +454,7 @@
num_forks: 0
num_issues: 0
is_mirror: false
status: 0

-
id: 35
Expand All @@ -432,6 +466,7 @@
num_forks: 0
num_issues: 0
is_mirror: false
status: 0

-
id: 36
Expand All @@ -443,6 +478,7 @@
num_forks: 0
num_issues: 0
is_mirror: false
status: 0

-
id: 37
Expand All @@ -454,6 +490,7 @@
num_forks: 0
num_issues: 0
is_mirror: false
status: 0

-
id: 38
Expand All @@ -465,6 +502,7 @@
num_forks: 0
num_issues: 0
is_mirror: false
status: 0

-
id: 39
Expand All @@ -476,6 +514,7 @@
num_forks: 0
num_issues: 0
is_mirror: false
status: 0

-
id: 40
Expand All @@ -487,6 +526,7 @@
num_forks: 0
num_issues: 0
is_mirror: false
status: 0

-
id: 41
Expand Down Expand Up @@ -519,4 +559,5 @@
num_stars: 0
num_forks: 0
num_issues: 0
is_mirror: false
is_mirror: false
status: 0
2 changes: 2 additions & 0 deletions models/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ var migrations = []Migration{
NewMigration("add repo_admin_change_team_access to user", addRepoAdminChangeTeamAccessColumnForUser),
// v98 -> v99
NewMigration("add original author name and id on migrated release", addOriginalAuthorOnMigratedReleases),
// v99 -> v100
NewMigration("add task table and status column for repository table", addTaskTable),
}

// Migrate database to current version
Expand Down
Loading

0 comments on commit f2a3abc

Please sign in to comment.