1
0
Fork 0
mirror of synced 2024-06-03 11:24:48 +12:00

fix: migration

This commit is contained in:
Torsten Dittmann 2022-05-16 11:14:23 +02:00
parent 72fdda6b8a
commit 5b6900ac84
3 changed files with 83 additions and 52 deletions

View file

@ -45,7 +45,7 @@
"utopia-php/cache": "0.6.*",
"utopia-php/cli": "0.12.*",
"utopia-php/config": "0.2.*",
"utopia-php/database": "0.16.*",
"utopia-php/database": "0.17.*",
"utopia-php/locale": "0.4.*",
"utopia-php/registry": "0.5.*",
"utopia-php/preloader": "0.2.*",

28
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "23a43ddfd26689ff154463410f7da3a4",
"content-hash": "ffb0a355553045db9c4f517eec033a90",
"packages": [
{
"name": "adhocore/jwt",
@ -2133,16 +2133,16 @@
},
{
"name": "utopia-php/database",
"version": "0.16.1",
"version": "0.17.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "ab30b2a2ae27b83bd1756928e4ffa47fd8c9e602"
"reference": "a4d001452b78b85335ffbd34176cd45d2b13c1ca"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/ab30b2a2ae27b83bd1756928e4ffa47fd8c9e602",
"reference": "ab30b2a2ae27b83bd1756928e4ffa47fd8c9e602",
"url": "https://api.github.com/repos/utopia-php/database/zipball/a4d001452b78b85335ffbd34176cd45d2b13c1ca",
"reference": "a4d001452b78b85335ffbd34176cd45d2b13c1ca",
"shasum": ""
},
"require": {
@ -2190,9 +2190,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/0.16.1"
"source": "https://github.com/utopia-php/database/tree/0.17.1"
},
"time": "2022-05-12T17:05:57+00:00"
"time": "2022-05-16T09:11:44+00:00"
},
{
"name": "utopia-php/domains",
@ -6320,16 +6320,16 @@
},
{
"name": "twig/twig",
"version": "v3.3.10",
"version": "v3.4.0",
"source": {
"type": "git",
"url": "https://github.com/twigphp/Twig.git",
"reference": "8442df056c51b706793adf80a9fd363406dd3674"
"reference": "ed19f4bf9d19c4ef920b5d8243910bd32e85b9ba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/8442df056c51b706793adf80a9fd363406dd3674",
"reference": "8442df056c51b706793adf80a9fd363406dd3674",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/ed19f4bf9d19c4ef920b5d8243910bd32e85b9ba",
"reference": "ed19f4bf9d19c4ef920b5d8243910bd32e85b9ba",
"shasum": ""
},
"require": {
@ -6344,7 +6344,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
"dev-master": "3.4-dev"
}
},
"autoload": {
@ -6380,7 +6380,7 @@
],
"support": {
"issues": "https://github.com/twigphp/Twig/issues",
"source": "https://github.com/twigphp/Twig/tree/v3.3.10"
"source": "https://github.com/twigphp/Twig/tree/v3.4.0"
},
"funding": [
{
@ -6392,7 +6392,7 @@
"type": "tidelift"
}
],
"time": "2022-04-06T06:47:41+00:00"
"time": "2022-05-15T06:25:28+00:00"
},
{
"name": "vimeo/psalm",

View file

@ -84,20 +84,10 @@ class V13 extends Migration
Console::log("- {$id}");
switch ($id) {
case 'executions':
try {
/**
* Rename stdout to response
*/
$this->projectDB->renameAttribute($id, 'stdout', 'response');
} catch (\Throwable $th) {
Console::warning("'stdout' from {$id}: {$th->getMessage()}");
}
break;
case 'projects':
try {
/**
* Rename providers to authProviders
* Rename providers to authProviders.
*/
$this->projectDB->renameAttribute($id, 'providers', 'authProviders');
} catch (\Throwable $th) {
@ -106,6 +96,9 @@ class V13 extends Migration
break;
case 'users':
try {
/**
* Recreate sessions for new subquery.
*/
$this->projectDB->deleteAttribute($id, 'sessions');
$this->projectDB->createAttribute(
collection: $id,
@ -120,6 +113,9 @@ class V13 extends Migration
Console::warning("'sessions' from {$id}: {$th->getMessage()}");
}
try {
/**
* Recreate tokens for new subquery.
*/
$this->projectDB->deleteAttribute($id, 'tokens');
$this->projectDB->createAttribute(
collection: $id,
@ -134,6 +130,9 @@ class V13 extends Migration
Console::warning("'tokens' from {$id}: {$th->getMessage()}");
}
try {
/**
* Recreate memberships for new subquery.
*/
$this->projectDB->deleteAttribute($id, 'memberships');
$this->projectDB->createAttribute(
collection: $id,
@ -158,32 +157,64 @@ class V13 extends Migration
Console::warning("'_key_user' from {$id}: {$th->getMessage()}");
}
break;
case 'executions':
// TODO: migrate stdout (size => 1000000)
// TODO: migrate stderr (size => 1000000)
break;
case 'executions':
try {
/**
* Rename stdout to response
*/
$this->projectDB->renameAttribute($id, 'stdout', 'response');
// TODO: migrate response (size => 1000000)
// TODO: migrate stderr (size => 1000000)
} catch (\Throwable $th) {
Console::warning("'stdout' from {$id}: {$th->getMessage()}");
}
break;
case 'stats':
//TODO: migrate value (size => 8)
break;
case 'tokens':
try {
$this->createCollection('tokens');
} catch (\Throwable $th) {
Console::warning("'tokens': {$th->getMessage()}");
}
break;
case 'builds':
try {
/**
* Increase stdout size.
*/
$this->projectDB->updateAttribute($id, 'stdout', size: 1000000);
} catch (\Throwable $th) {
Console::warning("'stdout' from {$id}: {$th->getMessage()}");
}
try {
/**
* Increase stderr size.
*/
$this->projectDB->updateAttribute($id, 'stderr', size: 1000000);
} catch (\Throwable $th) {
Console::warning("'stderr' from {$id}: {$th->getMessage()}");
}
break;
case 'executions':
try {
/**
* Rename stdout to response.
* Increase response size.
*/
$this->projectDB->renameAttribute($id, 'stdout', 'response');
$this->projectDB->updateAttribute($id, 'response', size: 1000000);
} catch (\Throwable $th) {
Console::warning("'stdout' from {$id}: {$th->getMessage()}");
}
try {
/**
* Increase stderr size.
*/
$this->projectDB->updateAttribute($id, 'stderr', size: 1000000);
} catch (\Throwable $th) {
Console::warning("'stderr' from {$id}: {$th->getMessage()}");
}
break;
case 'stats':
try {
/**
* Increase value size ot BIGINT.
*/
$this->projectDB->updateAttribute($id, 'value', size: 8);
} catch (\Throwable $th) {
Console::warning("'size' from {$id}: {$th->getMessage()}");
}
break;
case 'tokens':
try {
/**
* Create new Tokens collection.
*/
$this->createCollection('tokens');
} catch (\Throwable $th) {
Console::warning("'tokens': {$th->getMessage()}");
}
break;
}
usleep(100000);
}