mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
more migrations
This commit is contained in:
parent
d9d78d1539
commit
a22593925a
@ -0,0 +1,2 @@
|
|||||||
|
INSERT INTO `migrations` (`id`, `db_version`) VALUES
|
||||||
|
(1, 2);
|
||||||
@ -41,7 +41,9 @@ class MigrationsController extends AppController
|
|||||||
$startTime = microtime(true);
|
$startTime = microtime(true);
|
||||||
$stateUserTransactionsTable = TableRegistry::getTableLocator()->get('StateUserTransactions');
|
$stateUserTransactionsTable = TableRegistry::getTableLocator()->get('StateUserTransactions');
|
||||||
$transactionsTable = TableRegistry::getTableLocator()->get('Transactions');
|
$transactionsTable = TableRegistry::getTableLocator()->get('Transactions');
|
||||||
|
$transactionTypesTable = TableRegistry::getTableLocator()->get('TransactionTypes');
|
||||||
$stateBalancesTable = TableRegistry::getTableLocator()->get('StateBalances');
|
$stateBalancesTable = TableRegistry::getTableLocator()->get('StateBalances');
|
||||||
|
$blockchainTypesTable = TableRegistry::getTableLocator()->get('BlockchainTypes');
|
||||||
|
|
||||||
$new_db_version = 1;
|
$new_db_version = 1;
|
||||||
|
|
||||||
@ -51,7 +53,9 @@ class MigrationsController extends AppController
|
|||||||
$stateUserTransactionsTable->truncate();
|
$stateUserTransactionsTable->truncate();
|
||||||
$commands = [
|
$commands = [
|
||||||
[$transactionsTable, 'fillStateUserTransactions'],
|
[$transactionsTable, 'fillStateUserTransactions'],
|
||||||
[$stateBalancesTable, 'updateAllBalances']
|
[$stateBalancesTable, 'updateAllBalances'],
|
||||||
|
[$blockchainTypesTable, 'fillWithDefault'],
|
||||||
|
[$transactionTypesTable, 'fillWithDefault']
|
||||||
];
|
];
|
||||||
$new_db_version = 2;
|
$new_db_version = 2;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ use Cake\Validation\Validator;
|
|||||||
* @method \App\Model\Entity\BlockchainType[] patchEntities($entities, array $data, array $options = [])
|
* @method \App\Model\Entity\BlockchainType[] patchEntities($entities, array $data, array $options = [])
|
||||||
* @method \App\Model\Entity\BlockchainType findOrCreate($search, callable $callback = null, $options = [])
|
* @method \App\Model\Entity\BlockchainType findOrCreate($search, callable $callback = null, $options = [])
|
||||||
*/
|
*/
|
||||||
class BlockchainTypesTable extends Table
|
class BlockchainTypesTable extends AppTable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Initialize method
|
* Initialize method
|
||||||
@ -65,4 +65,37 @@ class BlockchainTypesTable extends Table
|
|||||||
|
|
||||||
return $validator;
|
return $validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fillWithDefault()
|
||||||
|
{
|
||||||
|
$entry_contents = [
|
||||||
|
[
|
||||||
|
'id' => 1,
|
||||||
|
'name' => 'mysql',
|
||||||
|
'text' => 'use mysql db as blockchain, work only with single community-server',
|
||||||
|
'symbol' => NULL
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 2,
|
||||||
|
'name' => 'hedera',
|
||||||
|
'text' => 'use hedera for transactions',
|
||||||
|
'symbol' => 'HBAR'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$entities = $this->newEntities($entry_contents);
|
||||||
|
$this->truncate();
|
||||||
|
$save_results = $this->saveMany($entities);
|
||||||
|
$errors = [];
|
||||||
|
foreach($save_results as $i => $result)
|
||||||
|
{
|
||||||
|
if(!$result) {
|
||||||
|
$errors[] = $entities[$i]->getErrors();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(count($errors) > 0) {
|
||||||
|
return ['success' => false, 'msg' => 'error by saving blockchain types', 'errors' => $errors];
|
||||||
|
}
|
||||||
|
return ['success' => true];
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ use Cake\Validation\Validator;
|
|||||||
* @method \App\Model\Entity\TransactionType[] patchEntities($entities, array $data, array $options = [])
|
* @method \App\Model\Entity\TransactionType[] patchEntities($entities, array $data, array $options = [])
|
||||||
* @method \App\Model\Entity\TransactionType findOrCreate($search, callable $callback = null, $options = [])
|
* @method \App\Model\Entity\TransactionType findOrCreate($search, callable $callback = null, $options = [])
|
||||||
*/
|
*/
|
||||||
class TransactionTypesTable extends Table
|
class TransactionTypesTable extends AppTable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Initialize method
|
* Initialize method
|
||||||
@ -66,4 +66,62 @@ class TransactionTypesTable extends Table
|
|||||||
|
|
||||||
return $validator;
|
return $validator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function fillWithDefault()
|
||||||
|
{
|
||||||
|
|
||||||
|
$entry_contents = [
|
||||||
|
[
|
||||||
|
'id' => 1,
|
||||||
|
'name' => 'creation',
|
||||||
|
'text' => 'create new gradidos for member and also for group (in development)',
|
||||||
|
], [
|
||||||
|
'id' => 2,
|
||||||
|
'name' => 'transfer',
|
||||||
|
'text' => 'send gradidos from one member to another, also cross group transfer',
|
||||||
|
], [
|
||||||
|
'id' => 3,
|
||||||
|
'name' => 'group create',
|
||||||
|
'text' => 'create a new group, trigger creation of new hedera topic and new blockchain on node server'
|
||||||
|
], [
|
||||||
|
'id' => 4,
|
||||||
|
'name' => 'group add member',
|
||||||
|
'text' => 'add user to a group or move if he was already in a group'
|
||||||
|
], [
|
||||||
|
'id' => 5,
|
||||||
|
'name' => 'group remove member',
|
||||||
|
'text' => 'remove user from group, maybe he was moved elsewhere'
|
||||||
|
],[
|
||||||
|
'id' => 6,
|
||||||
|
'name' => 'hedera topic create',
|
||||||
|
'text' => 'create new topic on hedera'
|
||||||
|
],[
|
||||||
|
'id' => 7,
|
||||||
|
'name' => 'hedera topic send message',
|
||||||
|
'text' => 'send consensus message over hedera topic'
|
||||||
|
],[
|
||||||
|
'id' => 8,
|
||||||
|
'name' => 'hedera account create',
|
||||||
|
'text' => 'create new account on hedera for holding some founds with unencrypted keys'
|
||||||
|
],[
|
||||||
|
'id' => 9,
|
||||||
|
'name' => 'decay start',
|
||||||
|
'text' => 'signalize the starting point for decay calculation, allowed only once per chain'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$entities = $this->newEntities($entry_contents);
|
||||||
|
$this->truncate();
|
||||||
|
$save_results = $this->saveMany($entities);
|
||||||
|
$errors = [];
|
||||||
|
foreach($save_results as $i => $result)
|
||||||
|
{
|
||||||
|
if(!$result) {
|
||||||
|
$errors[] = $entities[$i]->getErrors();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(count($errors) > 0) {
|
||||||
|
return ['success' => false, 'msg' => 'error by saving transaction types', 'errors' => $errors];
|
||||||
|
}
|
||||||
|
return ['success' => true];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user