-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from owncloud/stable10-migrations
Stable10 migrations
- Loading branch information
Showing
8 changed files
with
127 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace OCA\Files_Antivirus\Migrations; | ||
use Doctrine\DBAL\Schema\Schema; | ||
use OCP\Migration\ISchemaMigration; | ||
|
||
/** Creates initial schema */ | ||
class Version20170808220321 implements ISchemaMigration { | ||
public function changeSchema(Schema $schema, array $options) { | ||
$prefix = $options['tablePrefix']; | ||
if (!$schema->hasTable("{$prefix}files_antivirus")) { | ||
$table = $schema->createTable("{$prefix}files_antivirus"); | ||
$table->addColumn('fileid', 'bigint', [ | ||
'unsigned' => true, | ||
'notnull' => true, | ||
'length' => 11, | ||
]); | ||
|
||
$table->addColumn('check_time', 'integer', [ | ||
'notnull' => true, | ||
'unsigned' => true, | ||
'default' => 0, | ||
]); | ||
$table->setPrimaryKey(['fileid']); | ||
} | ||
|
||
if (!$schema->hasTable("{$prefix}files_avir_status")) { | ||
$table = $schema->createTable("{$prefix}files_avir_status"); | ||
$table->addColumn('id', 'integer', [ | ||
'autoincrement' => true, | ||
'unsigned' => true, | ||
'notnull' => true, | ||
'length' => 11, | ||
]); | ||
|
||
$table->addColumn('group_id', 'integer', [ | ||
'notnull' => true, | ||
'unsigned' => true, | ||
'default' => 0, | ||
]); | ||
|
||
$table->addColumn('status_type', 'integer', [ | ||
'notnull' => true, | ||
'unsigned' => true, | ||
'default' => 0, | ||
]); | ||
|
||
$table->addColumn('result', 'integer', [ | ||
'notnull' => true, | ||
'unsigned' => false, | ||
'default' => 0, | ||
]); | ||
|
||
$table->addColumn('match', 'string', [ | ||
'length' => 64, | ||
'notnull' => false, | ||
'default' => null, | ||
]); | ||
|
||
$table->addColumn('description', 'string', [ | ||
'length' => 64, | ||
'notnull' => false, | ||
'default' => null, | ||
]); | ||
|
||
$table->addColumn('status', 'integer', [ | ||
'length' => 4, | ||
'notnull' => true, | ||
'default' => 0, | ||
'unsigned' => false, | ||
]); | ||
$table->setPrimaryKey(['id']); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace OCA\Files_Antivirus\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\DBAL\Types\Type; | ||
use OCP\Migration\ISchemaMigration; | ||
|
||
/** Updates some fields to bigint if required */ | ||
class Version20170808221437 implements ISchemaMigration { | ||
public function changeSchema(Schema $schema, array $options) { | ||
$prefix = $options['tablePrefix']; | ||
|
||
if ($schema->hasTable("${prefix}files_antivirus")) { | ||
$table = $schema->getTable("{$prefix}files_antivirus"); | ||
|
||
$fileIdColumn = $table->getColumn('fileid'); | ||
if ($fileIdColumn && $fileIdColumn->getType()->getName() !== Type::BIGINT) { | ||
$fileIdColumn->setType(Type::getType(Type::BIGINT)); | ||
$fileIdColumn->setOptions(['length' => 20]); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace OCA\Files_Antivirus\Migrations; | ||
use OCA\Files_Antivirus\Db\RuleMapper; | ||
use OCP\Migration\IOutput; | ||
use OCP\Migration\ISimpleMigration; | ||
|
||
/** Populate statuses */ | ||
class Version20170808222334 implements ISimpleMigration { | ||
private $ruleMapper; | ||
|
||
public function __construct(RuleMapper $ruleMapper){ | ||
$this->ruleMapper = $ruleMapper; | ||
} | ||
|
||
public function run(IOutput $out) { | ||
$rules = $this->ruleMapper->findAll(); | ||
if (!count($rules)) { | ||
$this->ruleMapper->populate(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
<?php | ||
|
||
$app = new \OCA\Files_Antivirus\AppInfo\Application(); | ||
$ruleMapper = $app->getContainer()->query('RuleMapper'); | ||
$rules = $ruleMapper->findAll(); | ||
if(!count($rules)) { | ||
$ruleMapper->populate(); | ||
} | ||
|
||
\OC::$server->getConfig()->setAppValue('files_antivirus', 'av_path', '/usr/bin/clamscan'); | ||
\OC::$server->getJobList()->add('OCA\Files_Antivirus\Cron\Task'); |