diff options
author | dartcafe <github@dartcafe.de> | 2019-12-21 23:01:06 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2019-12-21 23:01:06 +0300 |
commit | 923fe1897f3f6962d95a94577b2d03ae5bc512ad (patch) | |
tree | 5c9031d3dfdf4969d98c2377767045e2294a9c35 /lib/Migration | |
parent | 9d015be1fa920e002a2f9cbacdfdafacbe807357 (diff) |
Prepare mail notification and update tests
Diffstat (limited to 'lib/Migration')
-rw-r--r-- | lib/Migration/Version0010Date20191221183157.php | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/lib/Migration/Version0010Date20191221183157.php b/lib/Migration/Version0010Date20191221183157.php new file mode 100644 index 00000000..98b26af5 --- /dev/null +++ b/lib/Migration/Version0010Date20191221183157.php @@ -0,0 +1,104 @@ +<?php +/** + * @copyright Copyright (c) 2017 René Gieling <github@dartcafe.de> + * + * @author René Gieling <github@dartcafe.de> + * + * @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\Polls\Migration; + +// use Doctrine\DBAL\Exception\TableNotFoundException; +// use Doctrine\DBAL\Platforms\PostgreSqlPlatform; +use Doctrine\DBAL\Types\Type; +use OCP\DB\ISchemaWrapper; +use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\IConfig; +use OCP\IDBConnection; +use OCP\Migration\SimpleMigrationStep; +use OCP\Migration\IOutput; +use OCP\Security\ISecureRandom; + +/** + * Installation class for the polls app. + * Initial db creation + */ +class Version0010Date20191221183157 extends SimpleMigrationStep { + + /** @var IDBConnection */ + protected $connection; + + /** @var IConfig */ + protected $config; + + /** + * @param IDBConnection $connection + * @param IConfig $config + */ + public function __construct(IDBConnection $connection, IConfig $config) { + $this->connection = $connection; + $this->config = $config; + } + + /** + * @param IOutput $output + * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` + * @param array $options + * @return null|ISchemaWrapper + * @since 13.0.0 + */ + public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + if (!$schema->hasTable('polls_send_mail')) { + $table = $schema->createTable('polls_send_mail'); + $table->addColumn('id', Type::INTEGER, [ + 'autoincrement' => true, + 'notnull' => true, + ]); + $table->addColumn('poll_id', Type::INTEGER, [ + 'notnull' => true + ]); + $table->addColumn('user_id', Type::STRING, [ + 'notnull' => false, + 'length' => 1024 + ]); + $table->addColumn('user_email', Type::STRING, [ + 'notnull' => false, + 'length' => 1024 + ]); + $table->addColumn('display_name', Type::STRING, [ + 'notnull' => false, + 'length' => 64 + ]); + $table->addColumn('message_id', Type::STRING, [ + 'notnull' => false, + 'length' => 64 + ]); + $table->addColumn('message', Type::STRING, [ + 'notnull' => false, + 'length' => 1024 + ]); + $table->setPrimaryKey(['id']); + } + + return $schema; + } + +} |