1<?php
2
3declare(strict_types=1);
4
5namespace OCA\Cospend\Migration;
6
7use Closure;
8use OCP\DB\ISchemaWrapper;
9use OCP\Migration\SimpleMigrationStep;
10use OCP\Migration\IOutput;
11
12/**
13 * Auto-generated migration step: Please modify to your needs!
14 */
15class Version000106Date20191023153118 extends SimpleMigrationStep {
16
17	/**
18	 * @param IOutput $output
19	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
20	 * @param array $options
21	 */
22	public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
23	}
24
25	/**
26	 * @param IOutput $output
27	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
28	 * @param array $options
29	 * @return null|ISchemaWrapper
30	 */
31	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
32		/** @var ISchemaWrapper $schema */
33		$schema = $schemaClosure();
34
35		$ts = (new \DateTime())->getTimestamp();
36
37		if ($schema->hasTable('cospend_projects')) {
38			$table = $schema->getTable('cospend_projects');
39			$table->addColumn('lastchanged', 'integer', [
40				'notnull' => true,
41				'length' => 1,
42				'default' => $ts,
43			]);
44		}
45
46		if ($schema->hasTable('cospend_bills')) {
47			$table = $schema->getTable('cospend_bills');
48			$table->addColumn('lastchanged', 'integer', [
49				'notnull' => true,
50				'length' => 1,
51				'default' => $ts,
52			]);
53		}
54
55		if ($schema->hasTable('cospend_members')) {
56			$table = $schema->getTable('cospend_members');
57			$table->addColumn('lastchanged', 'integer', [
58				'notnull' => true,
59				'length' => 1,
60				'default' => $ts,
61			]);
62		}
63
64		return $schema;
65	}
66
67	/**
68	 * @param IOutput $output
69	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
70	 * @param array $options
71	 */
72	public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
73	}
74}
75