Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional fields to the deck_cards table #2526

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/Db/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ class Card extends RelationalEntity {
protected $notified = false;
protected $deletedAt = 0;
protected $commentsUnread = 0;
protected $timeToComplete;
protected $timeToCompleteMinutes;
protected $milestone;
protected $product;
protected $component;
protected $pctComplete;

private $databaseType = 'sqlite';

Expand All @@ -64,6 +70,8 @@ public function __construct() {
$this->addType('archived', 'boolean');
$this->addType('notified', 'boolean');
$this->addType('deletedAt', 'integer');
$this->addType('timeToCompleteMinutes', 'integer');
$this->addType('pctComplete', 'integer');
$this->addRelation('labels');
$this->addRelation('assignedUsers');
$this->addRelation('attachments');
Expand Down
64 changes: 64 additions & 0 deletions lib/Migration/Version1000Date20201112173419.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

declare(strict_types=1);

namespace OCA\Deck\Migration;

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

/**
* Auto-generated migration step: Please modify to your needs!
*/
class Version1000Date20201112173419 extends SimpleMigrationStep {

/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
}

/**
* @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) {
$schema = $schemaClosure();
$table = $schema->getTable('deck_cards');

$table->addColumn('time_to_complete', 'text', [
'notnull' => false,
]);
$table->addColumn('time_to_complete_minutes', 'integer', [
'notnull' => false,
]);
$table->addColumn('milestone', 'text', [
'notnull' => false,
]);
$table->addColumn('product', 'text', [
'notnull' => false,
]);
$table->addColumn('component', 'text', [
'notnull' => false,
]);
$table->addColumn('pct_complete', 'integer', [
'notnull' => false,
]);

return $schema;
}

/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*/
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
}
}
18 changes: 18 additions & 0 deletions tests/unit/Db/CardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ public function testJsonSerialize() {
'commentsUnread' => 0,
'lastEditor' => null,
'ETag' => $card->getETag(),
'pctComplete' => null,
'timeToComplete' => null,
'timeToCompleteMinutes' => null,
'product' => null,
'component' => null,
'milestone' => null,
], $card->jsonSerialize());
}
public function testJsonSerializeLabels() {
Expand All @@ -111,6 +117,12 @@ public function testJsonSerializeLabels() {
'commentsUnread' => 0,
'lastEditor' => null,
'ETag' => $card->getETag(),
'pctComplete' => null,
'timeToComplete' => null,
'timeToCompleteMinutes' => null,
'product' => null,
'component' => null,
'milestone' => null,
], $card->jsonSerialize());
}

Expand Down Expand Up @@ -147,6 +159,12 @@ public function testJsonSerializeAsignedUsers() {
'commentsUnread' => 0,
'lastEditor' => null,
'ETag' => $card->getETag(),
'pctComplete' => null,
'timeToComplete' => null,
'timeToCompleteMinutes' => null,
'product' => null,
'component' => null,
'milestone' => null,
], $card->jsonSerialize());
}
}