Urko. d3a068fe2b | ||
---|---|---|
cmd | ||
internal/domain | ||
kit/config | ||
.gitignore | ||
README.md | ||
app.example.yml | ||
go.mod | ||
go.sum |
README.md
gogstea
migration from gogs to gitea with less pain
High level operation:
The main idea is to do a copy. The script will take the users from csv data from gogs, previously obtained, and will create gitea users interacting with gitea API
source := gogs.mysql --> select * from user; --> csv
dst:= gitea.postgres --> API /admin gitea --> go script read from csv and http post to gitea api
copy(dst, source)
users migration
Export results of this query to .csv to migrate the users
SELECT * FROM user
WHERE email !='';
Execution:
CONFIG_FILE=./app.yml go run ./cmd/users/main.go
orgs migration
Export results of this query to .csv to migrate the users
SELECT
u.name,
ou.org_id,
uo.name AS owner_name,
uo.email AS owner_email
FROM org_user ou
INNER JOIN user u ON ou.org_id = u.id
INNER JOIN user uo ON uo.id = ou.is_owner
Execution:
CONFIG_FILE=./app.yml go run ./cmd/org/main.go
repositories migration
You have to options: You can use the API to import them or like I did: manually import using the unadopted
button from the UI.
Execution:
CONFIG_FILE=./app.yml go run ./cmd/org/main.go
collaborators migration
Export results of this query to .csv to migrate the repositories
SELECT
r.name AS repo_name,
uo.name AS repo_owner,
u.name AS collaborator_user,
co.mode,
CASE
WHEN co.mode = 1 THEN 'read'
WHEN co.mode = 2 THEN 'write'
WHEN co.mode = 3 THEN 'admin'
WHEN co.mode = 4 THEN 'owner'
ELSE 'failed'
END AS permission
FROM collaboration co
INNER JOIN repository r ON r.id = co.repo_id
INNER JOIN user uo ON uo.id = r.owner_id
INNER JOIN user u ON u.id = co.user_id;
Execution:
CONFIG_FILE=./app.yml go run ./cmd/collaborator/main.go