Unable to open test.md file in seafile web UI

Hi,

I’m running seafile server CE 7.0.5 and I cannot view markdown files in the web UI. The problem seems to relate to /api2/repos//file/detail/ path which fails (returns 500) in seahub. I had the same problem on 7.0.3 so I upgraded after reading someone had a similar problem here online with that version. Since upgrading did not solve it for me, maybe someone knows how to help?

seahub.log:

2020-02-08 15:49:31,550 [ERROR] django.request:135 handle_uncaught_exception Internal Server Error: /api2/repos/4836d8df-3b6c-427a-928f-feddd9ca98a2/file/detail/
Traceback (most recent call last):
  File "/opt/haiwen/seafile-server-7.0.5/seahub/thirdpart/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/opt/haiwen/seafile-server-7.0.5/seahub/thirdpart/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/opt/haiwen/seafile-server-7.0.5/seahub/thirdpart/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/opt/haiwen/seafile-server-7.0.5/seahub/thirdpart/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/haiwen/seafile-server-7.0.5/seahub/thirdpart/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/opt/haiwen/seafile-server-7.0.5/seahub/thirdpart/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/haiwen/seafile-server-7.0.5/seahub/seahub/api2/base.py", line 23, in dispatch
    response = super(APIView, self).dispatch(*a, **kw)
  File "/opt/haiwen/seafile-server-7.0.5/seahub/thirdpart/rest_framework/views.py", line 466, in dispatch
    response = self.handle_exception(exc)
  File "/opt/haiwen/seafile-server-7.0.5/seahub/seahub/api2/base.py", line 20, in handle_exception
    return super(APIView, self).handle_exception(exc)
  File "/opt/haiwen/seafile-server-7.0.5/seahub/thirdpart/rest_framework/views.py", line 463, in dispatch
    response = handler(request, *args, **kwargs)
  File "/opt/haiwen/seafile-server-7.0.5/seahub/seahub/api2/views.py", line 3194, in get
    comment_total = file_comments.count()
  File "/opt/haiwen/seafile-server-7.0.5/seahub/thirdpart/django/db/models/query.py", line 364, in count
    return self.query.get_count(using=self.db)
  File "/opt/haiwen/seafile-server-7.0.5/seahub/thirdpart/django/db/models/sql/query.py", line 499, in get_count
    number = obj.get_aggregation(using, ['__count'])['__count']
  File "/opt/haiwen/seafile-server-7.0.5/seahub/thirdpart/django/db/models/sql/query.py", line 480, in get_aggregation
    result = compiler.execute_sql(SINGLE)
  File "/opt/haiwen/seafile-server-7.0.5/seahub/thirdpart/django/db/models/sql/compiler.py", line 899, in execute_sql
    raise original_exception
OperationalError: (1054, "Unknown column 'base_filecomment.uuid_id' in 'where clause'")

I searched for base_filecomment and found out that my database schema is incorrect. This is the schema I have:

+-------------------------+--------------+------+-----+---------+----------------+
| Field                   | Type         | Null | Key | Default | Extra          |
+-------------------------+--------------+------+-----+---------+----------------+
| id                      | int(11)      | NO   | PRI | NULL    | auto_increment |
| repo_id                 | varchar(36)  | NO   | MUL | NULL    |                |
| parent_path             | longtext     | NO   |     | NULL    |                |
| repo_id_parent_path_md5 | varchar(100) | NO   | MUL | NULL    |                |
| item_name               | longtext     | NO   |     | NULL    |                |
| author                  | varchar(255) | NO   | MUL | NULL    |                |
| comment                 | longtext     | NO   |     | NULL    |                |
| created_at              | datetime     | NO   |     | NULL    |                |
| updated_at              | datetime     | NO   |     | NULL    |                |
| detail                  | longtext     | YES  |     | NULL    |                |
| resolved                | tinyint(1)   | NO   | MUL | 0       |                |
+-------------------------+--------------+------+-----+---------+----------------+

But according to the source code. It is created like this:

CREATE TABLE `base_filecomment` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `author` varchar(255) NOT NULL,
  `comment` longtext NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `uuid_id` char(32) NOT NULL,
  `detail` longtext NOT NULL,
  `resolved` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `base_filecomment_uuid_id_4f9a2ca2_fk_tags_fileuuidmap_uuid` (`uuid_id`),
  KEY `base_filecomment_author_8a4d7e91` (`author`),
  KEY `base_filecomment_resolved_e0717eca` (`resolved`),
  CONSTRAINT `base_filecomment_uuid_id_4f9a2ca2_fk_tags_fileuuidmap_uuid` FOREIGN KEY (`uuid_id`) REFERENCES `tags_fileuuidmap` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

I see here that file comments should have been migrated for me. But maybe something went wrong during migration.

You can check the document: https://download.seafile.com/published/seafile-manual/upgrade/ce-7.0.md

Ah thanks! Can’t believe I missed that!