Merge pull request #5177 from nextcloud/backport/5157/stable18

[stable18] add migration to tutorial
This commit is contained in:
Morris Jobke 2020-10-06 09:03:14 +02:00 committed by GitHub
commit 7cbc363b0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -24,7 +24,7 @@ This mechanism is a versatile and typed approach to events in Nextcloud's php co
Naming scheme
^^^^^^^^^^^^^
The name should reflect the subject and the actions. Prefixing event classes with `Event` makes it easier to recognize their purpose.
The name should reflect the subject and the actions. Suffixing event classes with `Event` makes it easier to recognize their purpose.
For example, if a user is created, a `UserCreatedEvent` will be emitted.

View File

@ -135,6 +135,8 @@ For version you should use the your app versions. So if you app is at version
Don't forget to remove your `database.xml` file.
.. _migration_console_command:
Console commands
----------------

View File

@ -264,11 +264,17 @@ so for example **notestutorial/lib/Migration/Version000000Date20181013124731.php
}
}
To create the tables in the database, the :doc:`version tag <info>` in **notestutorial/appinfo/info.xml** needs to be increased:
To create the tables in the database, run the :ref:`migration <migration_console_command>` command::
php ./occ migrations:excute <appId> <versionNumber>
Example: sudo -u www-data php ./occ migrations:execute photos 000000Date20201002183800
.. note:: to trigger the tabele creation/alteration when user updating the app, update the :doc:`version tag <info>` in **notestutorial/appinfo/info.xml** . migration will be executed when user reload page after app upgrade
.. code-block:: xml
<?xml version="1.0"?>
<?xml version="1.0"?>
<info>
<id>notestutorial</id>
<name>Notes Tutorial</name>
@ -283,7 +289,6 @@ To create the tables in the database, the :doc:`version tag <info>` in **notestu
</dependencies>
</info>
Reload the page to trigger the database migration.
Now that the tables are created we want to map the database result to a PHP object to be able to control data. First create an :doc:`entity <storage/database>` in **notestutorial/lib/Db/Note.php**: