~cypheon/nextcloud-chores-app

2362d457e5bdfba946902d1191ffd31057a9cd1d — Johann Rudloff 1 year, 6 months ago 46c04e8
Add a `deleted` column to chores DB
2 files changed, 75 insertions(+), 1 deletions(-)

M appinfo/info.xml
A lib/Migration/Version0Date20230403160946.php
M appinfo/info.xml => appinfo/info.xml +1 -1
@@ 11,7 11,7 @@ points for each member are tracked.

Chores can be set to automatically repeat based on a schedule.
]]></description>
    <version>0.0.3</version>
    <version>0.0.4</version>
    <licence>agpl</licence>
    <author mail="johann+ncdev@sinyax.net" >Johann Rudloff</author>
    <namespace>Chores</namespace>

A lib/Migration/Version0Date20230403160946.php => lib/Migration/Version0Date20230403160946.php +74 -0
@@ 0,0 1,74 @@
<?php

declare(strict_types=1);

/**
 * @copyright Copyright (c) 2023 Johann Rudloff <johann@sinyax.net>
 *
 * @author Johann Rudloff <johann@sinyax.net>
 *
 * @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\Chores\Migration;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

/**
 * Migration step
 */
class Version0Date20230403160946 extends SimpleMigrationStep {

  /**
   * @param IOutput $output
   * @param Closure(): ISchemaWrapper $schemaClosure
   * @param array $options
   */
  public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
  }

  /**
   * @param IOutput $output
   * @param Closure(): ISchemaWrapper $schemaClosure
   * @param array $options
   * @return null|ISchemaWrapper
   */
  public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
    /** @var ISchemaWrapper $schema */
    $schema = $schemaClosure();

    $chores = $schema->getTable('chores_chores');
    $chores->addColumn('deleted', 'boolean', [
      'default' => false,
      'notnull' => false,
    ]);
    $chores->addIndex(['team_id', 'deleted'], 'chores_chores_team_del_idx');

    return $schema;
  }

  /**
   * @param IOutput $output
   * @param Closure(): ISchemaWrapper $schemaClosure
   * @param array $options
   */
  public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
  }
}