Use migrations to adjust the database schema to be ready for use with…#546
Conversation
|
@DeepDiver1975, thanks for your PR! By analyzing the history of the files in this pull request, we identified @janklostermann, @nickvergessen and @PVince81 to be potential reviewers. |
0feef87 to
6740643
Compare
| $this->addSql("ALTER TABLE $tableName ADD (\"tmpsubjectparams\" CLOB, \"tmpmessageparams\" CLOB)"); | ||
| $this->addSql("UPDATE $tableName SET \"tmpsubjectparams\"=\"subjectparams\", \"tmpmessageparams\"=\"messageparams\""); | ||
| $this->addSql("COMMIT"); | ||
| $this->addSql("ALTER TABLE $tableName DROP COLUMN \"subjectparams\""); |
There was a problem hiding this comment.
DROP takes time. Instead of DROP rename it to a different name, eg "oldsubjectparams" and "oldmessageparams", then rename the temp colums. This keeps the gap to a minimum ... the old* colums can then be deleted after the migration ...
basically we have to decide if we want a fast migration (which requires more disk space and a subsequent cleanup) or a migration that keeps a clean state ...
I vote for fast.
There was a problem hiding this comment.
In the case of an overblown activity table I guess it could be several GBs for a duplicate table, not sure if this is acceptable.
There was a problem hiding this comment.
no, you need the space anyway because you have to duplicate the columns anyway ...
| $tableName = "{$prefix}activity"; | ||
| if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) { | ||
| $tableName = $this->connection->quoteIdentifier($tableName); | ||
| $this->addSql("ALTER TABLE $tableName ADD (\"tmpsubjectparams\" CLOB, \"tmpmessageparams\" CLOB)"); |
There was a problem hiding this comment.
if you are not using $this->connection->quoteIdentifier('tmpsubjectparams'); you might as well use ALTER TABLE \"$tableName\" ...
There was a problem hiding this comment.
do not make these colums CLOB, then we might as well say activities is unsupported on oracle. In https://github.com/owncloud/activity/blob/master/lib/Data.php#L207 we execute a SELECT * which causes the automatic conversion of OCI-Lob objects into strings. In the case of the appconfig table that easily adds a millisecond per row, for ~120 rows that makes 120ms ON EVERY REQUEST. Here we have the activity table with thousands of rows and two CLOBS. The default limit is 30 ... or 50 ... I would expect 60-100ms for these queries.
-
in https://github.com/owncloud/activity/blob/master/lib/Data.php#L303 we only need
affecteduserandtimestamp, get rid of the*: fixed with select only necessary colums #547 -
alse LIKE does not work on CLOB columns: https://github.com/owncloud/activity/blob/master/appinfo/update.php#L38 in this case we might get away with it if the cleanup happens before this up script.
There was a problem hiding this comment.
ok, CLOB might work ... performance will suck big time compared to the open source databases ... but might be acceptable.
There was a problem hiding this comment.
I guess we can remove these update steps - 1.2.2 is oc 8.1 afaik
bc96af3 to
7e4584c
Compare
70c4fa3 to
dc2fa45
Compare
| class Version20161122085340 extends AbstractMigration { | ||
|
|
||
| /** | ||
| * @param Schema $schema |
There was a problem hiding this comment.
Indentation swaps somewhat from tabs to spaces here and in the rest of this file.
There was a problem hiding this comment.
This is because the migration generator uses spaces instead of tabs...
24e2621 to
3d13eba
Compare
727775a to
3ce6b06
Compare
👍 |
755bf16 to
a972dc4
Compare

… mysql mb4