Move to migration

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2020-07-10 16:02:01 +02:00
parent 1759d2176e
commit d5cdfc262d
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
6 changed files with 82 additions and 65 deletions

View File

@ -20,7 +20,6 @@ addons:
env:
global:
- CORE_TYPE=nextcloud
- CORE_BRANCH=master
- APP_NAME=notifications
matrix:
@ -43,8 +42,6 @@ matrix:
env: DB=sqlite CORE_BRANCH=stable18
- php: 7.2
env: DB=sqlite CORE_BRANCH=stable17
- php: 7.3
env: DB=sqlite CORE_BRANCH=master CORE_TYPE=owncloud
fast_finish: true
before_install:

View File

@ -1,56 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<database>
<name>*dbname*</name>
<create>true</create>
<overwrite>false</overwrite>
<charset>utf8</charset>
<table>
<name>*dbprefix*registration</name>
<declaration>
<field>
<name>id</name>
<type>integer</type>
<notnull>true</notnull>
<autoincrement>true</autoincrement>
<unsigned>true</unsigned>
<primary>true</primary>
</field>
<field>
<name>email</name>
<type>text</type>
<notnull>true</notnull>
</field>
<field>
<name>username</name>
<type>text</type>
</field>
<field>
<name>password</name>
<type>text</type>
</field>
<field>
<name>displayname</name>
<type>text</type>
</field>
<field>
<name>email_confirmed</name>
<type>boolean</type>
<default>false</default>
</field>
<field>
<name>token</name>
<type>text</type>
<notnull>true</notnull>
</field>
<field>
<name>client_secret</name>
<type>text</type>
</field>
<field>
<name>requested</name>
<type>timestamp</type>
<notnull>true</notnull>
</field>
</declaration>
</table>
</database>

View File

@ -27,7 +27,7 @@ This app allows users to register a new account.
Send Ethereum to `0x941613eBB948C2C547cb957B55fEB2609fa6Fe66`
Send BTC to `33pStaSaf4sDUA8XBAHTq7ZDQpCVFQArxQ`
]]></description>
<version>0.4.7</version>
<version>0.5.0</version>
<licence>agpl</licence>
<author mail="pellaeon@cnmc.tw" homepage="https://nyllep.wordpress.com/about-2">Pellaeon Lin</author>
<category>security</category>
@ -40,7 +40,6 @@ Send BTC to `33pStaSaf4sDUA8XBAHTq7ZDQpCVFQArxQ`
<database>sqlite</database>
<database>pgsql</database>
<database min-version="5.5">mysql</database>
<owncloud min-version="9.0" max-version="11"/>
<nextcloud min-version="17" max-version="20" />
</dependencies>
<settings>

View File

@ -0,0 +1,80 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Registration\Migration;
use Closure;
use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
class Version0005Date20200710135953 extends SimpleMigrationStep {
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if (!$schema->hasTable('registration')) {
$table = $schema->createTable('registration');
$table->addColumn('id', Type::INTEGER, [
'autoincrement' => true,
'notnull' => true,
'unsigned' => true,
]);
$table->addColumn('email', Type::STRING, [
'notnull' => true,
]);
$table->addColumn('username', Type::STRING, [
'notnull' => false,
]);
$table->addColumn('password', Type::STRING, [
'notnull' => false,
]);
$table->addColumn('displayname', Type::STRING, [
'notnull' => false,
]);
$table->addColumn('email_confirmed', Type::BOOLEAN, [
'notnull' => false,
'default' => false,
]);
$table->addColumn('token', Type::STRING, [
'notnull' => true,
]);
$table->addColumn('client_secret', Type::STRING, [
'notnull' => false,
]);
$table->addColumn('requested', Type::DATETIME, [
'notnull' => true,
]);
$table->setPrimaryKey(['id']);
}
return $schema;
}
}

View File

@ -10,8 +10,7 @@ export BUILD_CORE_DIR="${BUILD_ROOT_DIR}/core"
export BUILD_APPS_DIR="${BUILD_CORE_DIR}/apps"
export BUILD_APP_MODULE_DIR="${BUILD_APPS_DIR}/registration"
if [[ ${CORE_TYPE} == 'owncloud' ]]; then git clone https://github.com/owncloud/core.git --recursive --depth 1 -b ${CORE_BRANCH} ${BUILD_CORE_DIR}; fi
if [[ ${CORE_TYPE} == 'nextcloud' ]]; then git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b ${CORE_BRANCH} ${BUILD_CORE_DIR}; fi
git clone https://github.com/nextcloud/server.git --recursive --depth 1 -b ${CORE_BRANCH} ${BUILD_CORE_DIR}
mv ${BUILD_ROOT_DIR}/registration ${BUILD_APPS_DIR}

View File

@ -6,8 +6,6 @@ set -e
cd ${BUILD_CORE_DIR}
if [[ ${CORE_TYPE} == 'owncloud' ]]; then composer install -o --prefer-dist --no-suggest --no-interaction; fi
# Set up core
php -f occ maintenance:install --database-name oc_autotest --database-user oc_autotest --admin-user admin --admin-pass admin --database ${DB} --database-pass=''