Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/documentation.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2022-11-08 15:53:28 +0300
committerLouis Chemineau <louis@chmn.me>2022-11-08 15:53:28 +0300
commit9007eb26bd4047117597a31bc52c9bacfff1c4ea (patch)
tree929da0fe92acb40b3041cf086eb3b3e84651069d
parent6712d4052459ad8e37bdb88140061946c31cba2a (diff)
Follow up on table management tipsartonge/fix/table_tips_followup
Signed-off-by: Louis Chemineau <louis@chmn.me>
-rw-r--r--developer_manual/basics/storage/database.rst11
1 files changed, 7 insertions, 4 deletions
diff --git a/developer_manual/basics/storage/database.rst b/developer_manual/basics/storage/database.rst
index 40e690b5f..285b1c6c9 100644
--- a/developer_manual/basics/storage/database.rst
+++ b/developer_manual/basics/storage/database.rst
@@ -322,18 +322,19 @@ Slugs are used to identify resources in the URL by a string rather than integer
$author->slugify('name'); // Some-thing
Table management tips
--------------------------
+---------------------
It makes sense to apply some general tips from the beginning, so you don't have to migrate your data and schema later on.
-1. Don't use table name longer than 23 characters. As Oracle is limited to 30 chars and we need 3 more for `oc_` at the beginning and 5 for the primary key suffix `_pkey`.
+1. Don't use table name longer than 23 characters. As Oracle is limited to 30 chars and we need 3 more for ``oc_`` at the beginning and 5 for the primary key suffix ``_pkey``.
-2. Add an auto-incremented `id` column. This will ease the use of `QBMapper` + `Entity` approach:
+2. Add an auto-incremented ``id`` column. This will ease the use of ``QBMapper`` + ``Entity`` approach:
- https://github.com/nextcloud/server/blob/master/lib/public/AppFramework/Db/QBMapper.php
- https://github.com/nextcloud/server/blob/master/lib/public/AppFramework/Db/Entity.php
.. code-block:: php
+ <?php
$table->addColumn('id', Types::BIGINT, [
'autoincrement' => true,
'notnull' => true,
@@ -345,12 +346,14 @@ It makes sense to apply some general tips from the beginning, so you don't have
.. code-block:: php
+ <?php
$table->setPrimaryKey(['id']);
-4. Manually set the name of your indexes. It will help you to manipulate them if needed in the future. Note that the names of the index are "global" database wide in some DBs. So having generic names can create conflicts.
+4. Manually set the name of your indexes. It will help you to manipulate them if needed in the future. Note that the names of the index are "global" database wide in some database platforms. So having generic names can create conflicts.
.. code-block:: php
+ <?php
$table->addUniqueIndex(['your', 'column', 'names', '...'], 'table_name_uniq_feature');
Supporting more databases