##// END OF EJS Templates
deps: bumped pycryptodome==3.21.0 for security issue
deps: bumped pycryptodome==3.21.0 for security issue

File last commit:

r2628:b50c9994 stable
r5640:acc4336c default
Show More
db-schema.rst
51 lines | 1.6 KiB | text/x-rst | RstLexer
project: added all source files and assets
r1 =======================
DB Schema and Migration
=======================
docs: updates to contributor documentation #4039
r271 To create or alter tables in the database, it's necessary to change a couple of
project: added all source files and assets
r1 files, apart from configuring the settings pointing to the latest database
schema.
Database Model and ORM
----------------------
On ``rhodecode.model.db`` you will find the database definition of all tables and
docs: updates to contributor documentation #4039
r271 fields. Any freshly installed database will be correctly created by the definitions
here. So, any change to this file will affect the tests without having to change
project: added all source files and assets
r1 any other file.
docs: updates to contributor documentation #4039
r271 A second layer are the business classes inside ``rhodecode.model``.
project: added all source files and assets
r1
Database Migration
------------------
Three files play a role when creating database migrations:
* Database schema inside ``rhodecode.lib.dbmigrate``
* Database version inside ``rhodecode.lib.dbmigrate``
* Configuration ``__dbversion__`` at ``rhodecode.__init__``
Schema is a snapshot of the database version BEFORE the migration. So, it's
the initial state before any changes were added. The name convention is
docs: updates to contributor documentation #4039
r271 the latest release version where the snapshot was created, and not the
project: added all source files and assets
r1 target version of this code.
Version is the method that will define how to UPGRADE/DOWNGRADE the database.
``rhodecode.__init__`` contains only a variable that defines up to which version of
the database will be used to upgrade. Eg.: ``__dbversion__ = 45``
For examples on how to create those files, please see the existing code.
Migration Command
^^^^^^^^^^^^^^^^^
docs: updates to contributor documentation #4039
r271 After you've changed the database ORM and migration files, you can run::
project: added all source files and assets
r1
docs: updated old commands not longer available starting from 4.11
r2628 rc-upgrade-db <ini-file>
project: added all source files and assets
r1
docs: updates to contributor documentation #4039
r271 The database will be upgraded up to the version defined in the ``__init__`` file.