50 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
declare(strict_types=1);
 | 
						|
// SPDX-FileCopyrightText: Szabó Dávid <daevidt@gmail.com>
 | 
						|
// SPDX-License-Identifier: AGPL-3.0-or-later
 | 
						|
 | 
						|
namespace OCA\Nezd\Migration;
 | 
						|
 | 
						|
use Closure;
 | 
						|
use OCP\DB\ISchemaWrapper;
 | 
						|
use OCP\Migration\SimpleMigrationStep;
 | 
						|
use OCP\Migration\IOutput;
 | 
						|
 | 
						|
class Version000000Date20181013124731 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('nezd')) {
 | 
						|
			$table = $schema->createTable('nezd');
 | 
						|
			$table->addColumn('id', 'integer', [
 | 
						|
				'autoincrement' => true,
 | 
						|
				'notnull' => true,
 | 
						|
			]);
 | 
						|
			$table->addColumn('title', 'string', [
 | 
						|
				'notnull' => true,
 | 
						|
				'length' => 200
 | 
						|
			]);
 | 
						|
			$table->addColumn('user_id', 'string', [
 | 
						|
				'notnull' => true,
 | 
						|
				'length' => 200,
 | 
						|
			]);
 | 
						|
			$table->addColumn('content', 'text', [
 | 
						|
				'notnull' => true,
 | 
						|
				'default' => ''
 | 
						|
			]);
 | 
						|
 | 
						|
			$table->setPrimaryKey(['id']);
 | 
						|
			$table->addIndex(['user_id'], 'nezd_user_id_index');
 | 
						|
		}
 | 
						|
		return $schema;
 | 
						|
	}
 | 
						|
}
 |