Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nextcloud 22 and "The appinfo/database.xml file is not longer supported. Used in sensorlogger" error #103

Closed
stefan123t opened this issue Sep 26, 2021 · 10 comments

Comments

@stefan123t
Copy link

stefan123t commented Sep 26, 2021

Describe the bug
Upgraded to Nextcloud 22.1.4 with success.
Now sensorlogger has been disabled during upgrade
I have enabled it again but it displays error:
The appinfo/database.xml file is not longer supported. Used in sensorlogger

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Admin > Apps > Disabled Apps'
  2. Click on 'Enable'
  3. See error
    The appinfo/database.xml file is not longer supported. Used in sensorlogger

Expected behavior
Should enable the sensorlogger again.

Screenshots
grafik

Desktop (please complete the following information):

  • OS: Linux Mint 21.2
  • Browser Firefox 90.1
  • Version 22.1.4
  • sensorlogger 0.0.9

Additional context
I have seen that according to the changes in #100 the nextcloud max version is set to 23.
MySQL / Maria DB Version is:
mysql --version
mysql Ver 15.1 Distrib 10.5.10-MariaDB, for Linux (x86_64) using readline 8.1
PHP is version 7.4

@stefan123t stefan123t changed the title Nextcloud 22 and database.xml error Nextcloud 22 and "The appinfo/database.xml file is not longer supported. Used in sensorlogger" error Sep 26, 2021
@stefan123t
Copy link
Author

@alexstocker many thanks for your plugin times and again.

Given the changes between master and 0.1-nc-devel I have seen that appinfo/database.xml has already been removed from the sensorlogger code tree.
It could be that I still have the old stale file around and that this preventing upgrade from my current 0.0.9 -> 0.1.4 version now.

Should this be solved by removing it manually or do you plan on providing a smooth upgrade path by removing this file in a pre-install step somehow, then I would wait for you to test this once it is released / committed ?

Kind regards,
Stefan

@stefan123t
Copy link
Author

According to the old Nextcloud 21 documentation https://docs.nextcloud.com/server/21/developer_manual/basics/storage/migrations.html#migrate-from-database-xml I should call the following to create the respective table layouts under lib/Migration. Unfortunately I am already past the upgrade to NC22. If you want I can try to roll back to NC21 to try it again. I just did the upgrade yesterday.

php occ migrations:generate-from-schema sensorlogger 000009
The current PHP memory limit is below the recommended value of 512MB.
There are no commands defined in the "migrations" namespace.

@stefan123t
Copy link
Author

In NC22 the migrations has been disabled and is only available in Debug mode, should I try to enable Debug mode for sensorlogger ?

https://docs.nextcloud.com/server/22/developer_manual/app_publishing_maintenance/upgrade-guide.html#migration-commands

@stefan123t
Copy link
Author

The appinfo/database.xml has to be removed and the app has to supply its lib/Migration/ scripts to upgrade the database schema between versions. See owncloud/music#865 for a sample in the music plugin and especially the commit owncloud/music@6982d91

According to nextcloud/server#27113 the migration command should only be used on developer env.

@alexstocker could you supply the relevant lib/Migration/Version000104Date20210927083000.php or similar upgrade script to create / modify the schema ?

@alexstocker
Copy link
Owner

@stefan123t Thanx for reporting. I'll do my best. But to be honest, will take a while. Any contributions are warmly welcome ;-)

@stefan123t
Copy link
Author

@alexstocker thanks for taking this up as an issue which apparently occurs only when upgrading from previous versions of sensorlogger in NC 22+.

Pauli, who implemented the hange for the above owncloud/music plugin has replied with some explanation on the process to owncloud/music#865.

This is the relvant commit message:

Replace database.xml with a Migration script on Nextcloud
Nextcloud 22 drops the support for defining database schema with
database.xml. Instead, the database schema should now be defined using
a Migration script. The migration script here has been generated from
the database.xml with occ migrations:generate-from-schema.

All supported versions of Nextcloud can use the migration script but ownCloud
cannot. Hence, we still need to keep also database.xml around, and just
remove it when deploying for Nextcloud. The removing now happens with
make release which now creates two separate packages, one for Nextcloud
and another for ownCloud.

Unfortunately I do not know the changes between previous (ie 0.0.9) and current (ie. 0.1.4) DB template of sensorlogger.

But given the Migrationscript automatically generated and the other sanitized by paul it should be possible to migrate the schemas for sensorlogger too.

Kind regards,
Stwfan

@stefan123t
Copy link
Author

Dear @alexstocker,

I have taken a quick, first stab at the necessary changes to make it show some of the old data under my Nextcloud 22.1:
image

sensorlogger-0.1.4_nc22_patch.zip

Here is the list of changes I made:

  • lib/Migration/Version011400Date20211020010104.php

I have tried to incorporate all the suggested changes from appinfo/Migrations/Version*.php and these in their original form.
I do not know whether they should be placed into appinfo/Migrations as these two automagically generated ones (?) or under lib/Migration/Version*.php as suggested by @paulijar in owncloud/music@6982d91
I also did not yet remove the appinfo/database.xml just moved it somewhere else for Nextcloud 22.1 not to complain.

  • lib/App.php -> added constructor with all six arguments from apps/files/lib/App.php to prevent the obvious constructor mismatch

Exception: Too few arguments to function OC\NavigationManager::__construct(), 0 passed in .../apps/sensorlogger/lib/App.php on line 33 and exactly 6 expected

         public static function getNavigationManager() {
                // TODO: move this into a service in the Application class
                if (self::$navigationManager === null) {
                        self::$navigationManager = new \OC\NavigationManager(
                                \OC::$server->getAppManager(),
                                \OC::$server->getURLGenerator(),
                                \OC::$server->getL10NFactory(),
                                \OC::$server->getUserSession(),
                                \OC::$server->getGroupManager(),
                                \OC::$server->getConfig()
                        );
                        self::$navigationManager->clear(false);
                }
                return self::$navigationManager;
        }
  • lib/Devices.php -> I had to remove the ->select('*') in line 27 to prevent Doctrine execute error in line 40.
Doctrine\DBAL\Query\QueryException: Query is selecting * and specific values in the same query. This is not supported in Oracle.
    .../apps/sensorlogger/lib/Devices.php - line 40:
    OC\DB\QueryBuilder\QueryBuilder->execute()
	public static function getDevices($userId, IDBConnection $db) {
		$query = $db->getQueryBuilder();
		$query
			->selectAlias('sd.user_id','user_id')
			->selectAlias('sd.id','id')
			->selectAlias('sdt.device_type_name','device_type_name')
			->selectAlias('sdg0.device_group_name','device_group_name')
			->selectAlias('sdg1.device_group_name','device_group_parent_name')
			->from('sensorlogger_devices','sd')
			->leftJoin('sd', 'sensorlogger_device_types', 'sdt', 'sdt.id = sd.type_id')
			->leftJoin('sd', 'sensorlogger_device_groups', 'sdg0', 'sdg0.id = sd.group_id')
			->leftJoin('sd', 'sensorlogger_device_groups', 'sdg1', 'sdg1.id = sd.group_parent_id')
			->where('sd.user_id = "'.$userId.'"')
			->orderBy('sd.id', 'DESC');
		$query->setMaxResults(100);
		$result = $query->execute();

The query returns something like if I am not mistaken, maybe the * can simply be omitted or instead it may be specified explicitly which fields are required:

SELECT
    *,
    sd.user_id AS user_id,
    sd.id AS id,
    sdt.device_type_name AS device_type_name,
    sdg0.device_group_name AS device_group_name,
    sdg1.device_group_name AS device_group_parent_name
FROM
    nc_6613_sensorlogger_devices sd
LEFT JOIN nc_6613_sensorlogger_device_types sdt ON
    sdt.id = sd.type_id
LEFT JOIN nc_6613_sensorlogger_device_groups sdg0 ON
    sdg0.id = sd.group_id
LEFT JOIN nc_6613_sensorlogger_device_groups sdg1 ON
    sdg1.id = sd.group_parent_id
WHERE
    sd.user_id = 'userid'
ORDER BY
    sd.id
DESC

I do not know why they were not in my sensorlogger-master.zip I downloaded to the server from GitHub.

@stefan123t
Copy link
Author

stefan123t commented Oct 20, 2021

@alexstocker I am just checking your 0.1-nc-devel branch to find that some (if not most) of the above issues I faced already have been addressed by you:

  • lib/App.php -> constructor with all six arguments is there.
  • lib/Migration/Version000009Date20190206183414.php and Version000010Date20190206183552.php do already exist.
  • appinfo/info.xml ->changes in for Nextcloud 21 Nextcloud 21 #100 made in 2c072b3 are valid until Nextcloud 23
  • lib/Devices.php -> I may have to remove the ->select('*') in line 27 to prevent Doctrine execute error in line 40.

Still have to figure out how to get the branch on my server for testing purposes.

@alexstocker
Copy link
Owner

@stefan123t Thanx for your effort. I'll check your changes as soon as possible.

If you have shell (ssh) access to your server and git available you can git clone and git checkout your sensorlogger branch within apps directory.

@stefan123t
Copy link
Author

@alexstocker thanks for adding the suggested changes to your 0.1.4 branch. I do not know if I am able to test / provoke this again e.g. by rolling back to 0.1.x and doing another upgrade. Hence I suggest to close this issue as resolved. I just checked and now even the graph seems to display fine. Thanks for this christmas present!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants