safer migrations

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
This commit is contained in:
Julien Veyssier
2024-04-07 15:42:34 +02:00
parent 6f88c95042
commit 8756307172
36 changed files with 346 additions and 270 deletions

View File

@@ -34,14 +34,17 @@ class Version000102Date20190907142139 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_projects')) {
$table = $schema->getTable('cospend_projects');
$table->addColumn('autoexport', 'string', [
'notnull' => true,
'length' => 1,
'default' => 'n',
]);
if (!$table->hasColumn('autoexport')) {
$table->addColumn('autoexport', 'string', [
'notnull' => true,
'length' => 1,
'default' => 'n',
]);
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -52,14 +52,18 @@ class Version000103Date20190907163755 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_bills')) {
$table = $schema->getTable('cospend_bills');
$table->addColumn('categoryid', 'integer', [
'notnull' => false,
'length' => 255
]);
$table->addColumn('paymentmode', 'string', [
'notnull' => false,
'length' => 1
]);
if (!$table->hasColumn('categoryid')) {
$table->addColumn('categoryid', 'integer', [
'notnull' => false,
'length' => 255
]);
}
if (!$table->hasColumn('paymentmode')) {
$table->addColumn('paymentmode', 'string', [
'notnull' => false,
'length' => 1
]);
}
}
return $schema;

View File

@@ -35,26 +35,32 @@ class Version000106Date20191023153118 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_projects')) {
$table = $schema->getTable('cospend_projects');
$table->addColumn('lastchanged', Types::INTEGER, [
'notnull' => true,
'default' => 0,
]);
if (!$table->hasColumn('lastchanged')) {
$table->addColumn('lastchanged', Types::INTEGER, [
'notnull' => true,
'default' => 0,
]);
}
}
if ($schema->hasTable('cospend_bills')) {
$table = $schema->getTable('cospend_bills');
$table->addColumn('lastchanged', Types::INTEGER, [
'notnull' => true,
'default' => 0,
]);
if (!$table->hasColumn('lastchanged')) {
$table->addColumn('lastchanged', Types::INTEGER, [
'notnull' => true,
'default' => 0,
]);
}
}
if ($schema->hasTable('cospend_members')) {
$table = $schema->getTable('cospend_members');
$table->addColumn('lastchanged', Types::INTEGER, [
'notnull' => true,
'default' => 0,
]);
if (!$table->hasColumn('lastchanged')) {
$table->addColumn('lastchanged', Types::INTEGER, [
'notnull' => true,
'default' => 0,
]);
}
}
return $schema;

View File

@@ -34,14 +34,17 @@ class Version000201Date20191223203543 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_members')) {
$table = $schema->getTable('cospend_shares');
$table->addColumn('permissions', 'string', [
'notnull' => true,
'length' => 4,
'default' => 'edc'
]);
if (!$table->hasColumn('permissions')) {
$table->addColumn('permissions', 'string', [
'notnull' => true,
'length' => 4,
'default' => 'edc'
]);
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -34,14 +34,17 @@ class Version000202Date20191225201436 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_bills')) {
$table = $schema->getTable('cospend_bills');
$table->addColumn('repeatallactive', 'integer', [
'notnull' => true,
'length' => 1,
'default' => 0
]);
if (!$table->hasColumn('repeatallactive')) {
$table->addColumn('repeatallactive', 'integer', [
'notnull' => true,
'length' => 1,
'default' => 0
]);
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -34,14 +34,17 @@ class Version000203Date20191227005654 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_projects')) {
$table = $schema->getTable('cospend_projects');
$table->addColumn('guestpermissions', 'string', [
'notnull' => true,
'length' => 4,
'default' => 'edc'
]);
if (!$table->hasColumn('guestpermissions')) {
$table->addColumn('guestpermissions', 'string', [
'notnull' => true,
'length' => 4,
'default' => 'edc'
]);
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -34,14 +34,17 @@ class Version000204Date20191228201832 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_bills')) {
$table = $schema->getTable('cospend_bills');
$table->addColumn('repeatuntil', 'string', [
'notnull' => false,
'length' => 20,
'default' => null
]);
if (!$table->hasColumn('repeatuntil')) {
$table->addColumn('repeatuntil', 'string', [
'notnull' => false,
'length' => 20,
'default' => null
]);
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -34,14 +34,17 @@ class Version000205Date20200102013739 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_members')) {
$table = $schema->getTable('cospend_members');
$table->addColumn('color', 'string', [
'notnull' => false,
'length' => 10,
'default' => null
]);
if (!$table->hasColumn('color')) {
$table->addColumn('color', 'string', [
'notnull' => false,
'length' => 10,
'default' => null
]);
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -56,11 +56,13 @@ class Version000301Date20200108160931 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_projects')) {
$table = $schema->getTable('cospend_projects');
$table->addColumn('currencyname', 'string', [
'notnull' => false,
'length' => 64,
'default' => null
]);
if (!$table->hasColumn('currencyname')) {
$table->addColumn('currencyname', 'string', [
'notnull' => false,
'length' => 64,
'default' => null
]);
}
}
return $schema;

View File

@@ -34,16 +34,20 @@ class Version000302Date20200110144741 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_categories')) {
$table = $schema->getTable('cospend_categories');
$table->addColumn('icon', 'string', [
'notnull' => false,
'length' => 3,
'default' => null
]);
$table->addColumn('color', 'string', [
'notnull' => false,
'length' => 10,
'default' => null
]);
if (!$table->hasColumn('icon')) {
$table->addColumn('icon', 'string', [
'notnull' => false,
'length' => 3,
'default' => null
]);
}
if (!$table->hasColumn('color')) {
$table->addColumn('color', 'string', [
'notnull' => false,
'length' => 10,
'default' => null
]);
}
}
return $schema;

View File

@@ -46,14 +46,17 @@ class Version000303Date20200201171814 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_shares')) {
$table = $schema->getTable('cospend_shares');
$table->addColumn('type', 'string', [
'notnull' => true,
'length' => 1,
'default' => 'u'
]);
if (!$table->hasColumn('type')) {
$table->addColumn('type', 'string', [
'notnull' => true,
'length' => 1,
'default' => 'u'
]);
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -34,10 +34,13 @@ class Version000303Date20200201172933 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_shares')) {
$table = $schema->getTable('cospend_shares');
$table->dropColumn('isgroupshare');
if ($table->hasColumn('isgroupshare')) {
$table->dropColumn('isgroupshare');
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -46,14 +46,17 @@ class Version000304Date20200313092247 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_bills')) {
$table = $schema->getTable('cospend_bills');
$table->addColumn('timestamp', 'bigint', [
'notnull' => true,
'length' => 10,
'default' => 0
]);
if (!$table->hasColumn('timestamp')) {
$table->addColumn('timestamp', 'bigint', [
'notnull' => true,
'length' => 10,
'default' => 0
]);
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -34,10 +34,13 @@ class Version000304Date20200313095955 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_bills')) {
$table = $schema->getTable('cospend_bills');
$table->dropColumn('date');
if ($table->hasColumn('date')) {
$table->dropColumn('date');
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -43,18 +43,29 @@ class Version000403Date20200231152118 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cospend_projects');
$table->addColumn('guestaccesslevel', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 2
]);
$table = $schema->getTable('cospend_shares');
$table->addColumn('accesslevel', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 2
]);
if ($schema->hasTable('cospend_projects')) {
$table = $schema->getTable('cospend_projects');
if (!$table->hasColumn('guestaccesslevel')) {
$table->addColumn('guestaccesslevel', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 2
]);
}
}
if ($schema->hasTable('cospend_shares')) {
$table = $schema->getTable('cospend_shares');
if (!$table->hasColumn('accesslevel')) {
$table->addColumn('accesslevel', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 2
]);
}
}
return $schema;
}

View File

@@ -32,10 +32,19 @@ class Version000403Date20200323173321 extends SimpleMigrationStep {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cospend_shares');
$table->dropColumn('permissions');
$table = $schema->getTable('cospend_projects');
$table->dropColumn('guestpermissions');
if ($schema->hasTable('cospend_shares')) {
$table = $schema->getTable('cospend_shares');
if ($table->hasColumn('permissions')) {
$table->dropColumn('permissions');
}
}
if ($schema->hasTable('cospend_projects')) {
$table = $schema->getTable('cospend_projects');
if ($table->hasColumn('guestpermissions')) {
$table->dropColumn('guestpermissions');
}
}
return $schema;
}

View File

@@ -34,9 +34,10 @@ class Version000404Date20200324145208 extends SimpleMigrationStep {
if ($schema->hasTable('cospend_ext_projects')) {
$schema->dropTable('cospend_ext_projects');
return $schema;
}
return $schema;
return null;
}
/**

View File

@@ -32,14 +32,19 @@ class Version000406Date20200417185442 extends SimpleMigrationStep {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cospend_members');
$table->addColumn('userid', 'string', [
'notnull' => false,
'length' => 64,
'default' => null
]);
if ($schema->hasTable('cospend_members')) {
$table = $schema->getTable('cospend_members');
if (!$table->hasColumn('userid')) {
$table->addColumn('userid', 'string', [
'notnull' => false,
'length' => 64,
'default' => null
]);
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -46,13 +46,19 @@ class Version000406Date20200426154317 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cospend_categories');
$table->addColumn('encoded_icon', 'string', [
'notnull' => false,
'length' => 64,
'default' => null
]);
return $schema;
if ($schema->hasTable('cospend_categories')) {
$table = $schema->getTable('cospend_categories');
if (!$table->hasColumn('encoded_icon')) {
$table->addColumn('encoded_icon', 'string', [
'notnull' => false,
'length' => 64,
'default' => null
]);
return $schema;
}
}
return null;
}
/**

View File

@@ -32,10 +32,15 @@ class Version000406Date20200426163311 extends SimpleMigrationStep {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cospend_categories');
$table->dropColumn('icon');
if ($schema->hasTable('cospend_categories')) {
$table = $schema->getTable('cospend_categories');
if ($table->hasColumn('icon')) {
$table->dropColumn('icon');
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -6,7 +6,6 @@ namespace OCA\Cospend\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
@@ -15,16 +14,6 @@ use OCP\Migration\SimpleMigrationStep;
*/
class Version000408Date20200430162436 extends SimpleMigrationStep {
/** @var IDBConnection */
private $connection;
/**
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
@@ -42,13 +31,20 @@ class Version000408Date20200430162436 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cospend_bills');
$table->addColumn('comment', 'string', [
'notnull' => false,
'length' => 300,
'default' => null
]);
return $schema;
if ($schema->hasTable('cospend_bills')) {
$table = $schema->getTable('cospend_bills');
if (!$table->hasColumn('comment')) {
$table->addColumn('comment', 'string', [
'notnull' => false,
'length' => 300,
'default' => null
]);
return $schema;
}
}
return null;
}
/**

View File

@@ -6,7 +6,6 @@ namespace OCA\Cospend\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
@@ -15,16 +14,6 @@ use OCP\Migration\SimpleMigrationStep;
*/
class Version010105Date20201030132329 extends SimpleMigrationStep {
/** @var IDBConnection */
private $connection;
/**
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
@@ -42,13 +31,20 @@ class Version010105Date20201030132329 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cospend_shares');
$table->addColumn('manually_added', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 1,
]);
return $schema;
if ($schema->hasTable('cospend_shares')) {
$table = $schema->getTable('cospend_shares');
if (!$table->hasColumn('manually_added')) {
$table->addColumn('manually_added', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 1,
]);
return $schema;
}
}
return null;
}
/**

View File

@@ -6,7 +6,6 @@ namespace OCA\Cospend\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
@@ -15,16 +14,6 @@ use OCP\Migration\SimpleMigrationStep;
*/
class Version010203Date20201208131054 extends SimpleMigrationStep {
/** @var IDBConnection */
private $connection;
/**
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
@@ -42,9 +31,14 @@ class Version010203Date20201208131054 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cospend_projects');
$table->setPrimaryKey(['id']);
return $schema;
if ($schema->hasTable('cospend_projects')) {
$table = $schema->getTable('cospend_projects');
$table->setPrimaryKey(['id']);
return $schema;
}
return null;
}
/**

View File

@@ -6,7 +6,6 @@ namespace OCA\Cospend\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
@@ -15,16 +14,6 @@ use OCP\Migration\SimpleMigrationStep;
*/
class Version010206Date20201223134353 extends SimpleMigrationStep {
/** @var IDBConnection */
private $connection;
/**
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
@@ -42,30 +31,36 @@ class Version010206Date20201223134353 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cospend_projects');
if (!$table->hasColumn('deletiondisabled')) {
$table->addColumn('deletiondisabled', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 0,
]);
}
if (!$table->hasColumn('categorysort')) {
$table->addColumn('categorysort', 'string', [
'notnull' => true,
'length' => 1,
'default' => 'a',
]);
if ($schema->hasTable('cospend_projects')) {
$table = $schema->getTable('cospend_projects');
if (!$table->hasColumn('deletiondisabled')) {
$table->addColumn('deletiondisabled', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 0,
]);
}
if (!$table->hasColumn('categorysort')) {
$table->addColumn('categorysort', 'string', [
'notnull' => true,
'length' => 1,
'default' => 'a',
]);
}
}
$table = $schema->getTable('cospend_categories');
if (!$table->hasColumn('order')) {
$table->addColumn('order', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 0,
]);
if ($schema->hasTable('cospend_categories')) {
$table = $schema->getTable('cospend_categories');
if (!$table->hasColumn('order')) {
$table->addColumn('order', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 0,
]);
}
}
return $schema;
}

View File

@@ -6,7 +6,6 @@ namespace OCA\Cospend\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
@@ -15,16 +14,6 @@ use OCP\Migration\SimpleMigrationStep;
*/
class Version010301Date20210412152948 extends SimpleMigrationStep {
/** @var IDBConnection */
private $connection;
/**
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
@@ -42,15 +31,20 @@ class Version010301Date20210412152948 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cospend_bills');
if (!$table->hasColumn('repeatfreq')) {
$table->addColumn('repeatfreq', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 1,
]);
if ($schema->hasTable('cospend_bills')) {
$table = $schema->getTable('cospend_bills');
if (!$table->hasColumn('repeatfreq')) {
$table->addColumn('repeatfreq', 'integer', [
'notnull' => true,
'length' => 4,
'default' => 1,
]);
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -8,7 +8,6 @@ use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
@@ -19,14 +18,12 @@ class Version010309Date20210628143307 extends SimpleMigrationStep {
/** @var IDBConnection */
private $connection;
private $trans;
/**
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection, IL10N $l10n) {
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
$this->trans = $l10n;
}
/**

View File

@@ -35,14 +35,19 @@ class Version010309Date20210714194120 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cospend_shares');
if (!$table->hasColumn('label')) {
$table->addColumn('label', Types::STRING, [
'notnull' => false,
'length' => 100,
]);
if ($schema->hasTable('cospend_shares')) {
$table = $schema->getTable('cospend_shares');
if (!$table->hasColumn('label')) {
$table->addColumn('label', Types::STRING, [
'notnull' => false,
'length' => 100,
]);
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -9,7 +9,6 @@ use OCP\DB\ISchemaWrapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\Types;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
@@ -20,14 +19,12 @@ class Version010314Date20210815170535 extends SimpleMigrationStep {
/** @var IDBConnection */
private $connection;
private $trans;
/**
* @param IDBConnection $connection
*/
public function __construct(IDBConnection $connection, IL10N $l10n) {
public function __construct(IDBConnection $connection) {
$this->connection = $connection;
$this->trans = $l10n;
}
/**
@@ -81,22 +78,26 @@ class Version010314Date20210815170535 extends SimpleMigrationStep {
$table->setPrimaryKey(['id']);
}
$table = $schema->getTable('cospend_bills');
if (!$table->hasColumn('paymentmodeid')) {
$table->addColumn('paymentmodeid', Types::INTEGER, [
'notnull' => true,
'length' => 4,
'default' => 0,
]);
if ($schema->hasTable('cospend_bills')) {
$table = $schema->getTable('cospend_bills');
if (!$table->hasColumn('paymentmodeid')) {
$table->addColumn('paymentmodeid', Types::INTEGER, [
'notnull' => true,
'length' => 4,
'default' => 0,
]);
}
}
$table = $schema->getTable('cospend_projects');
if (!$table->hasColumn('paymentmodesort')) {
$table->addColumn('paymentmodesort', Types::STRING, [
'notnull' => true,
'length' => 1,
'default' => 'a',
]);
if ($schema->hasTable('cospend_projects')) {
$table = $schema->getTable('cospend_projects');
if (!$table->hasColumn('paymentmodesort')) {
$table->addColumn('paymentmodesort', Types::STRING, [
'notnull' => true,
'length' => 1,
'default' => 'a',
]);
}
}
return $schema;

View File

@@ -47,15 +47,20 @@ class Version010314Date20210828143421 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cospend_paymentmodes');
if (!$table->hasColumn('old_id')) {
$table->addColumn('old_id', Types::STRING, [
'notnull' => false,
'length' => 1,
'default' => null,
]);
if ($schema->hasTable('cospend_paymentmodes')) {
$table = $schema->getTable('cospend_paymentmodes');
if (!$table->hasColumn('old_id')) {
$table->addColumn('old_id', Types::STRING, [
'notnull' => false,
'length' => 1,
'default' => null,
]);
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -32,14 +32,19 @@ class Version010315Date20210830235504 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$table = $schema->getTable('cospend_shares');
if (!$table->hasColumn('password')) {
$table->addColumn('password', Types::STRING, [
'notnull' => false,
'length' => 64,
]);
if ($schema->hasTable('cospend_shares')) {
$table = $schema->getTable('cospend_shares');
if (!$table->hasColumn('password')) {
$table->addColumn('password', Types::STRING, [
'notnull' => false,
'length' => 64,
]);
return $schema;
}
}
return $schema;
return null;
}
/**

View File

@@ -85,6 +85,7 @@ class Version010403Date20211112141106 extends SimpleMigrationStep {
]);
$table->setPrimaryKey(['id']);
}
if (!$schema->hasTable('cospend_paymentmodes')) {
if ($schema->hasTable('cospend_project_paymentmodes')) {
$this->shouldCopyPaymentmodesData = true;

View File

@@ -31,12 +31,14 @@ class Version010403Date20211112144733 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if ($schema->hasTable('cospend_project_categories')) {
$schema->dropTable('cospend_project_categories');
}
if ($schema->hasTable('cospend_project_paymentmodes')) {
$schema->dropTable('cospend_project_paymentmodes');
}
return $schema;
}

View File

@@ -24,6 +24,7 @@ class Version010511Date20231012151740 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if ($schema->hasTable('cospend_bills')) {
$table = $schema->getTable('cospend_bills');
if (!$table->hasColumn('deleted')) {
@@ -35,6 +36,7 @@ class Version010511Date20231012151740 extends SimpleMigrationStep {
return $schema;
}
}
return null;
}
}

View File

@@ -24,6 +24,7 @@ class Version010512Date20231201151136 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
if ($schema->hasTable('cospend_projects')) {
$table = $schema->getTable('cospend_projects');
if (!$table->hasColumn('archived_ts')) {
@@ -35,6 +36,7 @@ class Version010512Date20231201151136 extends SimpleMigrationStep {
return $schema;
}
}
return null;
}
}

View File

@@ -25,6 +25,7 @@ class Version010514Date20231203164157 extends SimpleMigrationStep {
*/
public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $options) {
$qb = $this->connection->getQueryBuilder();
$qb->update('cospend_projects')
->set('lastchanged', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT))
->where(

View File

@@ -97,10 +97,7 @@ class Version010600Date20240103034026 extends SimpleMigrationStep {
*/
}
if ($schemaChanged) {
return $schema;
}
return null;
return $schemaChanged ? $schema : null;
}
/**