question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

4.2: Database migration seems to fail for non-empty database - Column "X21.ALLOW_WIKI_EDITING" not found

See original GitHub issue

I’ve upgraded from 4.1 to 4.2 and now I’m getting this error:

org.h2.jdbc.JdbcSQLException: Column "X21.ALLOW_WIKI_EDITING" not found; SQL statement:
CREATE FORCE VIEW PUBLIC._1 AS
SELECT
    X21.UPDATED_DATE AS X22,
    X21.ALLOW_WIKI_EDITING AS X23,
    X21.EXTERNAL_ISSUES_URL AS X24,
    X21.PARENT_REPOSITORY_NAME AS X25,
    X21.EXTERNAL_WIKI_URL AS X26,
    X21.DEFAULT_BRANCH AS X27,
    X21.DESCRIPTION AS X28,
    X21.ORIGIN_REPOSITORY_NAME AS X29,
    X21.ORIGIN_USER_NAME AS X30,
    X21.PARENT_USER_NAME AS X31,
    X21.PRIVATE AS X32,
    X21.REPOSITORY_NAME AS X33,
    X21.USER_NAME AS X34,
    X21.ENABLE_WIKI AS X35,
    X21.ENABLE_ISSUES AS X36,
    X21.REGISTERED_DATE AS X37,
    X21.LAST_ACTIVITY_DATE AS X38
FROM PUBLIC.REPOSITORY X21 [42122-192]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
    at org.h2.message.DbException.get(DbException.java:179)
    at org.h2.message.DbException.get(DbException.java:155)
    at org.h2.expression.ExpressionColumn.optimize(ExpressionColumn.java:147)
    at org.h2.expression.Alias.optimize(Alias.java:51)
    at org.h2.command.dml.Select.prepare(Select.java:852)
...

I’ve double-checked using empty databases, i.e.:

rm -rf ~/.gitbucket
git checkout 4.1
./sbt.sh package
./sbt.sh executable
java -jar target/executable/gitbucket.war
./sbt.sh clean; rm -rf target; git clean -f
git checkout 4.2
./sbt.sh package
./sbt.sh executable
 java -jar target/executable/gitbucket.war

For these, it works without an issue. So the migration seems to fail only when the database actually contains data.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:17 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
uli-hellercommented, Jul 2, 2016

Here is the complete work-around. With this, I’m able to login:

  1. Try to open a browser using the usual gitbucket url
  2. See the error above
  3. Connect to the h2 console - append /console/login.jsp to the url
  4. Login to the h2 database
  5. Execute the commands mentioned at the end of this comment
  6. Try to open a browser using the usual gitbucket url again
  7. No error this time.

Here the commands for the h2 console:

alter table repository add column allow_wiki_editing boolean;
update repository set allow_wiki_editing=true;
alter table repository alter column allow_wiki_editing boolean not null;

alter table repository add column external_issues_url varchar(200);
alter table repository add column external_wiki_url varchar(200);

alter table repository add column enable_wiki boolean;
update repository set enable_wiki=true;
alter table repository alter column enable_wiki boolean not null;

alter table repository add column enable_issues boolean;
update repository set enable_issues=true;
alter table repository alter column enable_issues boolean not null;
1reaction
codelingcommented, Aug 16, 2016

Just tried upgrading from 4.0.0 to 4.3 and also got this error. Seems the fix in 4.2.1 does not work in this scenario. I followed the instructions from the gitbucket README (that is, I just replaced the gitbucket.war). Is there an additional step required during upgrade for this scenario, or is there some bug in the procedure?

The workaround from this comment worked for me; but I had to add

UPDATE VERSIONS SET VERSION='4.2.1' WHERE MODULE_ID='gitbucket-core';

to the executed statements (to avoid getting an error as described here: https://github.com/gitbucket/gitbucket/issues/1255).

Is there anything I need to look out for now? Everything seems to work fine; in VERSIONS table I see that gitbucket-core has been upgraded to 4.3.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Second Prisma migrate run (with no interim schema changes ...
Bug description After introspecting a MySQL database and running an initial migration, and then making no changes of any kind to the schema ......
Read more >
Database migration fails after installing the recently released ...
The database migration fails and our instance is now essentially broken, so we are humbly asking for some know-how about how to unbrick...
Read more >
Caused by: org.flywaydb.core.api.FlywayException: Validate ...
I simply migrate database from H2 DB to MYSQL. Then I simply updated the V2__create_shipwreck.sql. Please guide how I can solve it. I...
Read more >
Help with db:migrate - seems to be missing tables/columns
Hi,. I'm trying to put redmine 3.0.3 on a new linux server (Red Hat Enterprise Linux Server release 6.6, with Linux 2.6.32-279.11.1.el6.x86_64).
Read more >
Migration troubleshooting in development - Prisma
This guide describes how to resolve issues with Prisma Migrate in a development environment, which often involves resetting your database.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found