lib/Migration/Version100Date20211106170854.php
57a6327f
 <?php
 /**
  * @copyright 2021 Double Bastion LLC <www.doublebastion.com>
  *
  * @author Double Bastion LLC
  *
  * @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
  * License as published by the Free Software Foundation; either
  * version 3 of the License, or 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/>.
  *
  */
 
 declare(strict_types=1);
 
 namespace OCA\PaxFax\Migration;
 
 use Closure;
 use OCP\DB\Types;
 use OCP\DB\ISchemaWrapper;
 use OCP\Migration\IOutput;
 use OCP\Migration\SimpleMigrationStep;
 
 
 class Version100Date20211106170854 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): ?ISchemaWrapper {
 		/** @var ISchemaWrapper $schema */
 		$schema = $schemaClosure();
 
 		if (!$schema->hasTable('pax_fax')) {
 			$table = $schema->createTable('pax_fax');
 			$table->addColumn('id', Types::BIGINT, [
 				'autoincrement' => true,
 				'notnull' => true,
                                 'length' => 11,
                                 'unsigned' => true,
 			]);
 			$table->addColumn('user_id', Types::STRING, [
 				'notnull' => true,
 				'length' => 64,
 				'default' => '',
 			]);
 			$table->addColumn('api_key', Types::STRING, [
 				'notnull' => true,
 				'length' => 1024,
 				'default' => '',
 			]);
 			$table->addColumn('api_secret', Types::STRING, [
 				'notnull' => true,
 				'length' => 1024,
 				'default' => '',
 			]);
 			$table->addColumn('webhook_token', Types::STRING, [
 				'notnull' => true,
 				'length' => 1024,
 				'default' => '',
 			]);
 			$table->addColumn('receive_url', Types::STRING, [
 				'notnull' => true,
 				'length' => 1024,
 				'default' => '',
 			]);
 			$table->addColumn('get_notification', Types::SMALLINT, [
 				'notnull' => false,
 				'length' => 1,
 			]);
 			$table->addColumn('notification_email', Types::STRING, [
 				'notnull' => false,
 				'length' => 1024,
 				'default' => '',
 			]);
                         $table->setPrimaryKey(['id']);
                         $table->addUniqueIndex(['id']);
 		}
 
 		return $schema;
 	}
 }