折雨的天空
从gogs0.12.*转换到gitea的过程
2022-5-6 我好笨


从gitea官方看到,可以支持从gogs无缝升级到gitea,于是进行了尝试。



按照官方文档:



https://docs.gitea.io/zh-cn/upgrade-from-gogs/



进行升级,提示gitea版本过高,已不支持gogs升级,查看log文件,提示需要1.6.4或者之前的gitea,于是下载尝试。



升级过程中,提示缺少表。



于是放弃。







看到如下文章后,再次尝试。



http://t.zoukankan.com/xwgli-p-13178223.html







本次,下载的是gitea-1.11.8-windows-4.0-386.exe







需要修改从gogs拷贝过来的配置文件内容,包括MySQL的连接配置部分,主要是数据库类型,名称两者不一致,参照官方示例(https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini)进行修改即可。



DB_TYPE = mysql
HOST = 127.0.0.1:3306 ; can use socket e.g. /var/run/mysqld/mysqld.sock
NAME = gitea
USER = root
;PASSWD = ;





升级过程中,依然提示缺少表:external_login_user、repo_unit、u2f_registration。



表:protected_branch缺少字段。







可以通过新建表,或者加字段的方式,提示缺少什么字段加什么字段。字段类型,长度随意即可。也可使用如下语句。










CREATE TABLE `external_login_user` (
`external_id` varchar(255) NOT NULL,
`user_id` bigint NOT NULL,
`login_source_id` bigint NOT NULL,
`raw_data` text,
`provider` varchar(25) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`first_name` varchar(255) DEFAULT NULL,
`last_name` varchar(255) DEFAULT NULL,
`nick_name` varchar(255) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
`avatar_url` text,
`location` varchar(255) DEFAULT NULL,
`access_token` text,
`access_token_secret` text,
`refresh_token` text,
`expires_at` datetime DEFAULT NULL,
PRIMARY KEY (`external_id`,`login_source_id`),
KEY `IDX_external_login_user_user_id` (`user_id`),
KEY `IDX_external_login_user_provider` (`provider`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE `repo_unit` (
`id` int DEFAULT NULL,
`type` varchar(255) DEFAULT NULL,
`repo_id` int DEFAULT NULL,
`config` text,
`created_unix` varchar(255) DEFAULT NULL,
KEY `IDX_repo_unit_s` (`repo_id`,`type`),
KEY `IDX_repo_unit_created_unix` (`created_unix`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `protected_branch` (
`id` int DEFAULT NULL,
`repo_id` int DEFAULT NULL,
`branch_name` varchar(255) DEFAULT NULL,
`created_unix` varchar(255) DEFAULT NULL,
`updated_unix` varchar(255) DEFAULT NULL,
`enable_whitelist` varchar(255) DEFAULT NULL,
`enable_merge_whitelist` tinyint(1) NOT NULL DEFAULT '0',
`merge_whitelist_user_i_ds` text,
`merge_whitelist_team_i_ds` text,
`approvals_whitelist_user_i_ds` text,
`approvals_whitelist_team_i_ds` text,
`required_approvals` bigint NOT NULL DEFAULT '0',
`enable_status_check` tinyint(1) NOT NULL DEFAULT '0',
`status_check_contexts` text,
`whitelist_deploy_keys` tinyint(1) NOT NULL DEFAULT '0',
`can_push` tinyint(1) NOT NULL DEFAULT '0',
`enable_approvals_whitelist` tinyint(1) NOT NULL DEFAULT '0',
`block_on_rejected_reviews` tinyint(1) NOT NULL DEFAULT '0',
`whitelist_user_i_ds` text,
`whitelist_team_i_ds` text,
`dismiss_stale_approvals` tinyint(1) NOT NULL DEFAULT '0',
`require_signed_commits` tinyint(1) NOT NULL DEFAULT '0',
`protected_file_patterns` text,
`block_on_outdated_branch` tinyint(1) NOT NULL DEFAULT '0',
`block_on_official_review_requests` tinyint(1) NOT NULL DEFAULT '0',
`unprotected_file_patterns` text,
UNIQUE KEY `UQE_protected_branch_s` (`repo_id`,`branch_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `u2f_registration` (
`id` int NOT NULL,
`counter` bigint DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
`user_id` bigint DEFAULT NULL,
`raw` blob,
`created_unix` bigint DEFAULT NULL,
`updated_unix` bigint DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `IDX_u2f_registration_user_id` (`user_id`),
KEY `IDX_u2f_registration_created_unix` (`created_unix`),
KEY `IDX_u2f_registration_updated_unix` (`updated_unix`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;






有了对应表以后,转换成功。







转换成功后,再切换到最新的gitea版本就可以了。同样,也遇到了上面一篇文章中404的问题。



但是文章中,或者github中对应的信息在我这边都报语法错误,原因是Insert语句里面的双引号,应该改为~就行。正确的如下:



insert into repo_unit (`repo_id`, `type`, `config`) select repository.id as repo_id, types.*, '{}' from repository left join repo_unit on repository.id=repo_id left join ( select 1 UNION ALL select 2 UNION ALL select 3 UNION ALL select 4 UNION ALL select 5) as types on (1=1) where repo_id is null;



执行后,目前一切正常,我本地mysql是8的,估计是这个导致SQL提示错误的。









发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容