DB migrations unable to complete (stuck at db version 233) due to missing index #11080

Closed
opened 2025-11-02 09:27:02 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @Thulium-Drake on GitHub (Jun 22, 2023).

Description

After upgrading from Gitea 1.18.5 to 1.19.3 it's DB migrations can't continue because of a missing index and it produces some other warnings about the database structure

However, as it's stuck between the DB versions 1.18.5 (231) and 1.19.0 (244) use, it's now inoperable.

git@git:~/data$ gitea doctor --config /etc/gitea/gitea.ini --custom-path /var/lib/gitea/custom/
[1] Check paths and basic configuration
 - [I] Configuration File Path:    "/etc/gitea/gitea.ini"
 - [I] Repository Root Path:       "/var/lib/gitea/repos"
 - [I] Data Root Path:             "/var/lib/gitea/data"
 - [I] Custom File Root Path:      "/var/lib/gitea/custom/"
 - [I] Work directory:             "/usr/local/bin"
 - [I] Log Root Path:              "/var/lib/gitea/log"
OK
[2] Check Database Version
 - [I] Expected database version: 244
 - [C] Error: migrate: Current database version 233 is not equal to the expected version 244. Please run "gitea [--config /path/to/app.ini] migrate" to update the database version during ensure up to date
ERROR
[3] Check if user with wrong type exist
OK
[4] Check if OpenSSH authorized_keys file is up-to-date
OK
[5] Synchronize repo HEADs
 - [C] Error when fixing repo HEADs: no such column: num_action_runs
 - [I] All 0 repos have their HEADs in the correct state
ERROR
git@git:~/data$ gitea migrate --config /etc/gitea/gitea.ini --custom-path /var/lib/gitea/custom/
2023/06/22 15:24:05 cmd/migrate.go:33:runMigrate() [I] AppPath: /usr/local/bin/gitea
2023/06/22 15:24:05 cmd/migrate.go:34:runMigrate() [I] AppWorkPath: /usr/local/bin
2023/06/22 15:24:05 cmd/migrate.go:35:runMigrate() [I] Custom path: /var/lib/gitea/custom/
2023/06/22 15:24:05 cmd/migrate.go:36:runMigrate() [I] Log path: /var/lib/gitea/log
2023/06/22 15:24:05 cmd/migrate.go:37:runMigrate() [I] Configuration file: /etc/gitea/gitea.ini
2023/06/22 15:24:05 .../cli@v1.22.10/app.go:277:Run() [I] PING DATABASE sqlite3
2023/06/22 15:24:05 ...@v1.22.10/command.go:173:Run() [W] Table version Column version db default is NULL, struct default is 
2023/06/22 15:24:05 ...ations/migrations.go:565:Migrate() [I] Migration[233]: Add header_authorization_encrypted column to webhook table
2023/06/22 15:24:05 cmd/migrate.go:39:runMigrate() [W] Table webhook column type db type is varchar(16), struct type is TEXT
2023/06/22 15:24:05 cmd/migrate.go:39:runMigrate() [W] Table webhook Column meta db default is NULL, struct default is 
2023/06/22 15:24:05 cmd/migrate.go:40:runMigrate() [F] Failed to initialize ORM engine: migrate: migration[233]: Add header_authorization_encrypted column to webhook table failed: no such index: IDX_webhook_idx_webhook_IDX_webhook_is_active

Gitea Version

1.19.3

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.30.2

Operating System

Debian 11

How are you running Gitea?

Installed via https://github.com/roles-ansible/ansible_role_gitea after migrating away from a docker container, worked fine for 3 months and broke yesterday.

The database was converted from MySQL to SQLite.

Database

SQLite

Originally created by @Thulium-Drake on GitHub (Jun 22, 2023). ### Description After upgrading from Gitea 1.18.5 to 1.19.3 it's DB migrations can't continue because of a missing index and it produces some other warnings about the database structure However, as it's stuck between the DB versions 1.18.5 (231) and 1.19.0 (244) use, it's now inoperable. ``` git@git:~/data$ gitea doctor --config /etc/gitea/gitea.ini --custom-path /var/lib/gitea/custom/ [1] Check paths and basic configuration - [I] Configuration File Path: "/etc/gitea/gitea.ini" - [I] Repository Root Path: "/var/lib/gitea/repos" - [I] Data Root Path: "/var/lib/gitea/data" - [I] Custom File Root Path: "/var/lib/gitea/custom/" - [I] Work directory: "/usr/local/bin" - [I] Log Root Path: "/var/lib/gitea/log" OK [2] Check Database Version - [I] Expected database version: 244 - [C] Error: migrate: Current database version 233 is not equal to the expected version 244. Please run "gitea [--config /path/to/app.ini] migrate" to update the database version during ensure up to date ERROR [3] Check if user with wrong type exist OK [4] Check if OpenSSH authorized_keys file is up-to-date OK [5] Synchronize repo HEADs - [C] Error when fixing repo HEADs: no such column: num_action_runs - [I] All 0 repos have their HEADs in the correct state ERROR git@git:~/data$ gitea migrate --config /etc/gitea/gitea.ini --custom-path /var/lib/gitea/custom/ 2023/06/22 15:24:05 cmd/migrate.go:33:runMigrate() [I] AppPath: /usr/local/bin/gitea 2023/06/22 15:24:05 cmd/migrate.go:34:runMigrate() [I] AppWorkPath: /usr/local/bin 2023/06/22 15:24:05 cmd/migrate.go:35:runMigrate() [I] Custom path: /var/lib/gitea/custom/ 2023/06/22 15:24:05 cmd/migrate.go:36:runMigrate() [I] Log path: /var/lib/gitea/log 2023/06/22 15:24:05 cmd/migrate.go:37:runMigrate() [I] Configuration file: /etc/gitea/gitea.ini 2023/06/22 15:24:05 .../cli@v1.22.10/app.go:277:Run() [I] PING DATABASE sqlite3 2023/06/22 15:24:05 ...@v1.22.10/command.go:173:Run() [W] Table version Column version db default is NULL, struct default is 2023/06/22 15:24:05 ...ations/migrations.go:565:Migrate() [I] Migration[233]: Add header_authorization_encrypted column to webhook table 2023/06/22 15:24:05 cmd/migrate.go:39:runMigrate() [W] Table webhook column type db type is varchar(16), struct type is TEXT 2023/06/22 15:24:05 cmd/migrate.go:39:runMigrate() [W] Table webhook Column meta db default is NULL, struct default is 2023/06/22 15:24:05 cmd/migrate.go:40:runMigrate() [F] Failed to initialize ORM engine: migrate: migration[233]: Add header_authorization_encrypted column to webhook table failed: no such index: IDX_webhook_idx_webhook_IDX_webhook_is_active ``` ### Gitea Version 1.19.3 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version 2.30.2 ### Operating System Debian 11 ### How are you running Gitea? Installed via https://github.com/roles-ansible/ansible_role_gitea after migrating away from a docker container, worked fine for 3 months and broke yesterday. The database was converted from MySQL to SQLite. ### Database SQLite
GiteaMirror added the type/bug label 2025-11-02 09:27:02 -06:00
Author
Owner

@Thulium-Drake commented on GitHub (Jun 22, 2023):

As a note, if this is fixable by dropping the webhook table and have gitea migration recreate it, that's fine by me, but I don't know how to continue :-)

Also, yes, I did have backups and the system is running again with 1.18.5, but I'd like to figure out why the DB migrations aren't able to upgrade to 1.19.x

@Thulium-Drake commented on GitHub (Jun 22, 2023): As a note, if this is fixable by dropping the webhook table and have ```gitea migration``` recreate it, that's fine by me, but I don't know how to continue :-) Also, yes, I did have backups and the system is running again with 1.18.5, but I'd like to figure out why the DB migrations aren't able to upgrade to 1.19.x
Author
Owner

@lunny commented on GitHub (Jun 25, 2023):

How many records on your webhook table?

@lunny commented on GitHub (Jun 25, 2023): How many records on your webhook table?
Author
Owner

@Thulium-Drake commented on GitHub (Jun 26, 2023):

I did some tests by dropping the affected tables, however, the last index it is missing seems to be on the repository table, but I can't drop that table (can I?):

git@git:~$ gitea migrate --config /etc/gitea/gitea.ini --custom-path /var/lib/gitea/custom/
2023/06/26 11:26:26 cmd/migrate.go:33:runMigrate() [I] AppPath: /usr/local/bin/gitea
2023/06/26 11:26:26 cmd/migrate.go:34:runMigrate() [I] AppWorkPath: /usr/local/bin
2023/06/26 11:26:26 cmd/migrate.go:35:runMigrate() [I] Custom path: /var/lib/gitea/custom/
2023/06/26 11:26:26 cmd/migrate.go:36:runMigrate() [I] Log path: /var/lib/gitea/log
2023/06/26 11:26:26 cmd/migrate.go:37:runMigrate() [I] Configuration file: /etc/gitea/gitea.ini
2023/06/26 11:26:26 .../cli@v1.22.10/app.go:277:Run() [I] PING DATABASE sqlite3
2023/06/26 11:26:26 ...@v1.22.10/command.go:173:Run() [W] Table version Column version db default is NULL, struct default is 
2023/06/26 11:26:26 ...ations/migrations.go:565:Migrate() [I] Migration[233]: Add header_authorization_encrypted column to webhook table
2023/06/26 11:26:26 cmd/migrate.go:39:runMigrate() [W] Table webhook column type db type is varchar(16), struct type is TEXT
2023/06/26 11:26:26 cmd/migrate.go:39:runMigrate() [W] Table webhook Column meta db default is NULL, struct default is 
2023/06/26 11:26:26 cmd/migrate.go:40:runMigrate() [F] Failed to initialize ORM engine: migrate: migration[233]: Add header_authorization_encrypted column to webhook table failed: no such index: IDX_webhook_idx_webhook_IDX_webhook_repo_id
git@git:~$ gitea migrate --config /etc/gitea/gitea.ini --custom-path /var/lib/gitea/custom/
2023/06/26 11:26:43 cmd/migrate.go:33:runMigrate() [I] AppPath: /usr/local/bin/gitea
2023/06/26 11:26:43 cmd/migrate.go:34:runMigrate() [I] AppWorkPath: /usr/local/bin
2023/06/26 11:26:43 cmd/migrate.go:35:runMigrate() [I] Custom path: /var/lib/gitea/custom/
2023/06/26 11:26:43 cmd/migrate.go:36:runMigrate() [I] Log path: /var/lib/gitea/log
2023/06/26 11:26:43 cmd/migrate.go:37:runMigrate() [I] Configuration file: /etc/gitea/gitea.ini
2023/06/26 11:26:43 .../cli@v1.22.10/app.go:277:Run() [I] PING DATABASE sqlite3
2023/06/26 11:26:43 ...@v1.22.10/command.go:173:Run() [W] Table version Column version db default is NULL, struct default is 
2023/06/26 11:26:43 ...ations/migrations.go:565:Migrate() [I] Migration[235]: Add index for access_token
2023/06/26 11:26:43 cmd/migrate.go:39:runMigrate() [W] Table access_token column token_last_eight db type is varchar(255), struct type is TEXT
2023/06/26 11:26:43 cmd/migrate.go:40:runMigrate() [F] Failed to initialize ORM engine: migrate: migration[235]: Add index for access_token failed: no such index: IDX_access_token_idx_access_token_IDX_access_token_created_unix
git@git:~$ gitea migrate --config /etc/gitea/gitea.ini --custom-path /var/lib/gitea/custom/
2023/06/26 11:28:04 cmd/migrate.go:33:runMigrate() [I] AppPath: /usr/local/bin/gitea
2023/06/26 11:28:04 cmd/migrate.go:34:runMigrate() [I] AppWorkPath: /usr/local/bin
2023/06/26 11:28:04 cmd/migrate.go:35:runMigrate() [I] Custom path: /var/lib/gitea/custom/
2023/06/26 11:28:04 cmd/migrate.go:36:runMigrate() [I] Log path: /var/lib/gitea/log
2023/06/26 11:28:04 cmd/migrate.go:37:runMigrate() [I] Configuration file: /etc/gitea/gitea.ini
2023/06/26 11:28:04 .../cli@v1.22.10/app.go:277:Run() [I] PING DATABASE sqlite3
2023/06/26 11:28:05 ...@v1.22.10/command.go:173:Run() [W] Table version Column version db default is NULL, struct default is 
2023/06/26 11:28:05 ...ations/migrations.go:565:Migrate() [I] Migration[240]: Add actions tables
2023/06/26 11:28:05 cmd/migrate.go:40:runMigrate() [F] Failed to initialize ORM engine: migrate: migration[240]: Add actions tables failed: no such index: IDX_repository_idx_repository_IDX_repository_is_mirror

These are the counts of the tables that contained data before I dropped them:

sqlite> select count(*) from webhook;
35
sqlite> select count(*) from access_token;
2

So it seems there's more missing :(

EDIT: Are the indexes case sensitive by any chance? This seems odd:

sqlite> .schema repository
CREATE TABLE `repository` (
  `id` integer NOT NULL PRIMARY KEY AUTOINCREMENT
,  `owner_id` integer DEFAULT NULL
,  `lower_name` varchar(255) NOT NULL
,  `name` varchar(255) NOT NULL
,  `description` text DEFAULT NULL
,  `website` varchar(2048) DEFAULT NULL
,  `default_branch` varchar(255) DEFAULT NULL
,  `num_watches` integer DEFAULT NULL
,  `num_stars` integer DEFAULT NULL
,  `num_forks` integer DEFAULT NULL
,  `num_issues` integer DEFAULT NULL
,  `num_closed_issues` integer DEFAULT NULL
,  `num_pulls` integer DEFAULT NULL
,  `num_closed_pulls` integer DEFAULT NULL
,  `num_milestones` integer NOT NULL DEFAULT 0
,  `num_closed_milestones` integer NOT NULL DEFAULT 0
,  `is_private` integer DEFAULT NULL
,  `is_empty` integer DEFAULT NULL
,  `is_archived` integer DEFAULT NULL
,  `is_mirror` integer DEFAULT NULL
,  `is_fork` integer NOT NULL DEFAULT 0
,  `fork_id` integer DEFAULT NULL
,  `size` integer NOT NULL DEFAULT 0
,  `is_fsck_enabled` integer NOT NULL DEFAULT 1
,  `close_issues_via_commit_in_any_branch` integer NOT NULL DEFAULT 0
,  `topics` text DEFAULT NULL
,  `created_unix` integer DEFAULT NULL
,  `updated_unix` integer DEFAULT NULL
,  `avatar` varchar(64) DEFAULT NULL
,  `original_url` varchar(2048) DEFAULT NULL
,  `status` integer NOT NULL DEFAULT 0
,  `original_service_type` integer DEFAULT 0
,  `is_template` integer NOT NULL DEFAULT 0
,  `template_id` integer DEFAULT NULL
,  `owner_name` varchar(255) DEFAULT NULL
,  `num_projects` integer NOT NULL DEFAULT 0
,  `num_closed_projects` integer NOT NULL DEFAULT 0
,  `trust_model` integer DEFAULT NULL
, `num_action_runs` INTEGER DEFAULT 0 NOT NULL, `num_closed_action_runs` INTEGER DEFAULT 0 NOT NULL,  UNIQUE (`owner_id`,`lower_name`)
);
CREATE INDEX "idx_repository_IDX_repository_lower_name" ON "repository" (`lower_name`);
CREATE INDEX "idx_repository_IDX_repository_owner_id" ON "repository" (`owner_id`);
CREATE INDEX "idx_repository_IDX_repository_is_private" ON "repository" (`is_private`);
CREATE INDEX "idx_repository_IDX_repository_is_archived" ON "repository" (`is_archived`);
CREATE INDEX "idx_repository_IDX_repository_created_unix" ON "repository" (`created_unix`);
CREATE INDEX "idx_repository_IDX_repository_original_service_type" ON "repository" (`original_service_type`);
CREATE INDEX "idx_repository_IDX_repository_template_id" ON "repository" (`template_id`);
CREATE INDEX "idx_repository_IDX_repository_is_empty" ON "repository" (`is_empty`);
CREATE INDEX "idx_repository_IDX_repository_is_mirror" ON "repository" (`is_mirror`);
CREATE INDEX "idx_repository_IDX_repository_is_fork" ON "repository" (`is_fork`);
CREATE INDEX "idx_repository_IDX_repository_fork_id" ON "repository" (`fork_id`);
CREATE INDEX "idx_repository_IDX_repository_name" ON "repository" (`name`);
CREATE INDEX "idx_repository_IDX_repository_is_template" ON "repository" (`is_template`);
CREATE INDEX "idx_repository_IDX_repository_updated_unix" ON "repository" (`updated_unix`);
sqlite> CREATE INDEX "idx_repository_IDX_repository_is_mirror" ON "repository" (`is_mirror`);
Error: index idx_repository_IDX_repository_is_mirror already exists
@Thulium-Drake commented on GitHub (Jun 26, 2023): I did some tests by dropping the affected tables, however, the last index it is missing seems to be on the repository table, but I can't drop that table (can I?): ``` git@git:~$ gitea migrate --config /etc/gitea/gitea.ini --custom-path /var/lib/gitea/custom/ 2023/06/26 11:26:26 cmd/migrate.go:33:runMigrate() [I] AppPath: /usr/local/bin/gitea 2023/06/26 11:26:26 cmd/migrate.go:34:runMigrate() [I] AppWorkPath: /usr/local/bin 2023/06/26 11:26:26 cmd/migrate.go:35:runMigrate() [I] Custom path: /var/lib/gitea/custom/ 2023/06/26 11:26:26 cmd/migrate.go:36:runMigrate() [I] Log path: /var/lib/gitea/log 2023/06/26 11:26:26 cmd/migrate.go:37:runMigrate() [I] Configuration file: /etc/gitea/gitea.ini 2023/06/26 11:26:26 .../cli@v1.22.10/app.go:277:Run() [I] PING DATABASE sqlite3 2023/06/26 11:26:26 ...@v1.22.10/command.go:173:Run() [W] Table version Column version db default is NULL, struct default is 2023/06/26 11:26:26 ...ations/migrations.go:565:Migrate() [I] Migration[233]: Add header_authorization_encrypted column to webhook table 2023/06/26 11:26:26 cmd/migrate.go:39:runMigrate() [W] Table webhook column type db type is varchar(16), struct type is TEXT 2023/06/26 11:26:26 cmd/migrate.go:39:runMigrate() [W] Table webhook Column meta db default is NULL, struct default is 2023/06/26 11:26:26 cmd/migrate.go:40:runMigrate() [F] Failed to initialize ORM engine: migrate: migration[233]: Add header_authorization_encrypted column to webhook table failed: no such index: IDX_webhook_idx_webhook_IDX_webhook_repo_id git@git:~$ gitea migrate --config /etc/gitea/gitea.ini --custom-path /var/lib/gitea/custom/ 2023/06/26 11:26:43 cmd/migrate.go:33:runMigrate() [I] AppPath: /usr/local/bin/gitea 2023/06/26 11:26:43 cmd/migrate.go:34:runMigrate() [I] AppWorkPath: /usr/local/bin 2023/06/26 11:26:43 cmd/migrate.go:35:runMigrate() [I] Custom path: /var/lib/gitea/custom/ 2023/06/26 11:26:43 cmd/migrate.go:36:runMigrate() [I] Log path: /var/lib/gitea/log 2023/06/26 11:26:43 cmd/migrate.go:37:runMigrate() [I] Configuration file: /etc/gitea/gitea.ini 2023/06/26 11:26:43 .../cli@v1.22.10/app.go:277:Run() [I] PING DATABASE sqlite3 2023/06/26 11:26:43 ...@v1.22.10/command.go:173:Run() [W] Table version Column version db default is NULL, struct default is 2023/06/26 11:26:43 ...ations/migrations.go:565:Migrate() [I] Migration[235]: Add index for access_token 2023/06/26 11:26:43 cmd/migrate.go:39:runMigrate() [W] Table access_token column token_last_eight db type is varchar(255), struct type is TEXT 2023/06/26 11:26:43 cmd/migrate.go:40:runMigrate() [F] Failed to initialize ORM engine: migrate: migration[235]: Add index for access_token failed: no such index: IDX_access_token_idx_access_token_IDX_access_token_created_unix git@git:~$ gitea migrate --config /etc/gitea/gitea.ini --custom-path /var/lib/gitea/custom/ 2023/06/26 11:28:04 cmd/migrate.go:33:runMigrate() [I] AppPath: /usr/local/bin/gitea 2023/06/26 11:28:04 cmd/migrate.go:34:runMigrate() [I] AppWorkPath: /usr/local/bin 2023/06/26 11:28:04 cmd/migrate.go:35:runMigrate() [I] Custom path: /var/lib/gitea/custom/ 2023/06/26 11:28:04 cmd/migrate.go:36:runMigrate() [I] Log path: /var/lib/gitea/log 2023/06/26 11:28:04 cmd/migrate.go:37:runMigrate() [I] Configuration file: /etc/gitea/gitea.ini 2023/06/26 11:28:04 .../cli@v1.22.10/app.go:277:Run() [I] PING DATABASE sqlite3 2023/06/26 11:28:05 ...@v1.22.10/command.go:173:Run() [W] Table version Column version db default is NULL, struct default is 2023/06/26 11:28:05 ...ations/migrations.go:565:Migrate() [I] Migration[240]: Add actions tables 2023/06/26 11:28:05 cmd/migrate.go:40:runMigrate() [F] Failed to initialize ORM engine: migrate: migration[240]: Add actions tables failed: no such index: IDX_repository_idx_repository_IDX_repository_is_mirror ``` These are the counts of the tables that contained data before I dropped them: ``` sqlite> select count(*) from webhook; 35 sqlite> select count(*) from access_token; 2 ``` So it seems there's more missing :( EDIT: Are the indexes case sensitive by any chance? This seems odd: ``` sqlite> .schema repository CREATE TABLE `repository` ( `id` integer NOT NULL PRIMARY KEY AUTOINCREMENT , `owner_id` integer DEFAULT NULL , `lower_name` varchar(255) NOT NULL , `name` varchar(255) NOT NULL , `description` text DEFAULT NULL , `website` varchar(2048) DEFAULT NULL , `default_branch` varchar(255) DEFAULT NULL , `num_watches` integer DEFAULT NULL , `num_stars` integer DEFAULT NULL , `num_forks` integer DEFAULT NULL , `num_issues` integer DEFAULT NULL , `num_closed_issues` integer DEFAULT NULL , `num_pulls` integer DEFAULT NULL , `num_closed_pulls` integer DEFAULT NULL , `num_milestones` integer NOT NULL DEFAULT 0 , `num_closed_milestones` integer NOT NULL DEFAULT 0 , `is_private` integer DEFAULT NULL , `is_empty` integer DEFAULT NULL , `is_archived` integer DEFAULT NULL , `is_mirror` integer DEFAULT NULL , `is_fork` integer NOT NULL DEFAULT 0 , `fork_id` integer DEFAULT NULL , `size` integer NOT NULL DEFAULT 0 , `is_fsck_enabled` integer NOT NULL DEFAULT 1 , `close_issues_via_commit_in_any_branch` integer NOT NULL DEFAULT 0 , `topics` text DEFAULT NULL , `created_unix` integer DEFAULT NULL , `updated_unix` integer DEFAULT NULL , `avatar` varchar(64) DEFAULT NULL , `original_url` varchar(2048) DEFAULT NULL , `status` integer NOT NULL DEFAULT 0 , `original_service_type` integer DEFAULT 0 , `is_template` integer NOT NULL DEFAULT 0 , `template_id` integer DEFAULT NULL , `owner_name` varchar(255) DEFAULT NULL , `num_projects` integer NOT NULL DEFAULT 0 , `num_closed_projects` integer NOT NULL DEFAULT 0 , `trust_model` integer DEFAULT NULL , `num_action_runs` INTEGER DEFAULT 0 NOT NULL, `num_closed_action_runs` INTEGER DEFAULT 0 NOT NULL, UNIQUE (`owner_id`,`lower_name`) ); CREATE INDEX "idx_repository_IDX_repository_lower_name" ON "repository" (`lower_name`); CREATE INDEX "idx_repository_IDX_repository_owner_id" ON "repository" (`owner_id`); CREATE INDEX "idx_repository_IDX_repository_is_private" ON "repository" (`is_private`); CREATE INDEX "idx_repository_IDX_repository_is_archived" ON "repository" (`is_archived`); CREATE INDEX "idx_repository_IDX_repository_created_unix" ON "repository" (`created_unix`); CREATE INDEX "idx_repository_IDX_repository_original_service_type" ON "repository" (`original_service_type`); CREATE INDEX "idx_repository_IDX_repository_template_id" ON "repository" (`template_id`); CREATE INDEX "idx_repository_IDX_repository_is_empty" ON "repository" (`is_empty`); CREATE INDEX "idx_repository_IDX_repository_is_mirror" ON "repository" (`is_mirror`); CREATE INDEX "idx_repository_IDX_repository_is_fork" ON "repository" (`is_fork`); CREATE INDEX "idx_repository_IDX_repository_fork_id" ON "repository" (`fork_id`); CREATE INDEX "idx_repository_IDX_repository_name" ON "repository" (`name`); CREATE INDEX "idx_repository_IDX_repository_is_template" ON "repository" (`is_template`); CREATE INDEX "idx_repository_IDX_repository_updated_unix" ON "repository" (`updated_unix`); sqlite> CREATE INDEX "idx_repository_IDX_repository_is_mirror" ON "repository" (`is_mirror`); Error: index idx_repository_IDX_repository_is_mirror already exists ```
Author
Owner

@lunny commented on GitHub (Jun 26, 2023):

If you have less records, please drop all the indexes. Looks like all your indexes names are wrong. They should be IDX_repository_xxxx, not idx_repository_IDX_repository_xxxx. The idx_repository_ prefixes are wrong.

@lunny commented on GitHub (Jun 26, 2023): If you have less records, please drop all the indexes. Looks like all your indexes names are wrong. They should be `IDX_repository_xxxx`, not `idx_repository_IDX_repository_xxxx`. The `idx_repository_` prefixes are wrong.
Author
Owner

@Thulium-Drake commented on GitHub (Jun 26, 2023):

That did the trick! However, there's still a lot of warnings according to migrate, do I need to address them by manually updating the tables? Or is there a script that can correct these issues?

I put them in a gist https://gist.github.com/Thulium-Drake/6204d091e88705000bd03717254a6be2

@Thulium-Drake commented on GitHub (Jun 26, 2023): That did the trick! However, there's still a lot of warnings according to migrate, do I need to address them by manually updating the tables? Or is there a script that can correct these issues? I put them in a gist https://gist.github.com/Thulium-Drake/6204d091e88705000bd03717254a6be2
Author
Owner

@lunny commented on GitHub (Jun 26, 2023):

The warnings could be ignored.

@lunny commented on GitHub (Jun 26, 2023): The warnings could be ignored.
Author
Owner

@Thulium-Drake commented on GitHub (Jun 26, 2023):

Cool, thanks for checking.

So bottom line for those whom it may concern:

Check if you have broken index names, if so, remove them, and let gitea migrate fix it. I removed all my indexes with the following script:

#!/bin/bash

DB=/var/lib/gitea/data/gitea.db

INDEXES="$(echo "SELECT name FROM sqlite_master WHERE type == 'index' AND name like 'idx_%'" | sqlite3 $DB)"
for i in $INDEXES; do
  echo "DROP INDEX '$i';"  | sqlite3 $DB
done
@Thulium-Drake commented on GitHub (Jun 26, 2023): Cool, thanks for checking. So bottom line for those whom it may concern: Check if you have broken index names, if so, remove them, and let ```gitea migrate``` fix it. I removed all my indexes with the following script: ``` #!/bin/bash DB=/var/lib/gitea/data/gitea.db INDEXES="$(echo "SELECT name FROM sqlite_master WHERE type == 'index' AND name like 'idx_%'" | sqlite3 $DB)" for i in $INDEXES; do echo "DROP INDEX '$i';" | sqlite3 $DB done ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11080