Server: occ command ignores '--database-name' and '--database-table-prefix' when creating a SQLite3 database

Created on 31 Jan 2017  路  3Comments  路  Source: nextcloud/server

Expected behavior

If an administrator wants to create a SQLite3 database using the occ command, all used command line switches should be interpreted correctly.

Current behavior

If an administrator wants to create a SQLite3 database using the occ command, the command line switches --database-name and --database-table-prefix are ignored.

Steps to reproduce

  1. extract and install the Nextcloud files.
  2. switch to the user under which the web-server runs and change to the Nextcloud directory where the occ command resides.
> cd nextcloud/
  1. check the Nextcloud installation status.
> ./occ --no-ansi status
Nextcloud is not installed - only a limited number of commands are available
  - installed: false
  - version: 11.0.1.2
  - versionstring: 11.0.1
  - edition: 
  1. execute the following command to initialize the SQLite3 database:
> ./occ --no-ansi maintenance:install --database 'sqlite' --database-name 'nextcloud'  \
        --database-table-prefix 'nc_' --admin-user 'admin' --admin-pass 'pass'  \
        --data-dir '/var/nextcloud/data'
Nextcloud is not installed - only a limited number of commands are available
creating sqlite db
Nextcloud was successfully installed
  1. When you now check if the database has been created and what its name is you will find out that it has been created but its name is owncloud.db instead of 'nextcloud' :-(
> ls -al /var/nextcloud/data/*.db
-rw-r--r-- 1 wwwrun nogroup 589824 Jan 31 19:14 /var/nextcloud/data/owncloud.db
  1. When you now check if the database tables have been created and what their names are you will find out that all database tables have been created but they're are prefixed with oc_ instead of nc_ :-(
> sqlite3 /var/nextcloud/data/owncloud.db .tables
oc_accounts                  oc_flow_checks
oc_activity                  oc_flow_operations
oc_activity_mq               oc_group_admin
oc_addressbookchanges        oc_group_user
oc_addressbooks              oc_groups
oc_admin_sections            oc_jobs
oc_admin_settings            oc_mimetypes
oc_appconfig                 oc_mounts
oc_authtoken                 oc_notifications
oc_bruteforce_attempts       oc_preferences
oc_calendarchanges           oc_privatedata
oc_calendarobjects           oc_properties
oc_calendars                 oc_schedulingobjects
oc_calendarsubscriptions     oc_share
oc_cards                     oc_share_external
oc_cards_properties          oc_storages
oc_comments                  oc_systemtag
oc_comments_read_markers     oc_systemtag_group
oc_credentials               oc_systemtag_object_mapping
oc_dav_shares                oc_trusted_servers
oc_federated_reshares        oc_twofactor_backup_codes
oc_file_locks                oc_users
oc_filecache                 oc_vcategory
oc_files_trash               oc_vcategory_to_object
  1. If you create an initial configuration file which only contains the two parameter dbname and dbtableprefix the database and its tables are created as requested. This is an indication that the parameters itself are working but they're not parsed as expexted.
<?php
$CONFIG = array (
  'dbname' => 'nextcloud',
  'dbtableprefix' => 'nc_'
);

Environment

Server Configuration

OS: Linux 3.2.84
Web server: Apache2 2.4.25
Database: MariaDB 5.5.54
PHP version: 5.6.29
Nextcloud version: 11.0.1

Client Configuration

Browser: Mozilla Firefox 51.0.1
Operating system: Windows 7

bug install and update

Most helpful comment

https://github.com/nextcloud/server/blob/0211e17e3fe7dd36ba9360de4cc70aaddfafa4c2/lib/private/Setup/Sqlite.php#L32-L33

When you remove the lines above from sqlite and call

maintenance:install
--database=sqlite
--database-name=nextcloud
--database-table-prefix=nc_
--admin-user=admin
--admin-pass=admin

does it work?

All 3 comments

It seems that issue has still not been fixed in Nextcloud v13.0.6.

https://github.com/nextcloud/server/blob/0211e17e3fe7dd36ba9360de4cc70aaddfafa4c2/lib/private/Setup/Sqlite.php#L32-L33

When you remove the lines above from sqlite and call

maintenance:install
--database=sqlite
--database-name=nextcloud
--database-table-prefix=nc_
--admin-user=admin
--admin-pass=admin

does it work?

@danielkesselberg Thank you for the hint. If I remove the mentioned two lines of code, the installation works as expected. A database file nextcloud.db is created and the table prefixes are correctly set to nc_.

Was this page helpful?
0 / 5 - 0 ratings