文档管理中心

您当前正在浏览HarmonyOS开发者3.0版本配套的开发者文档,对应API能力级别为API 8 Release。此版本文档已归档不再维护,推荐您使用HarmonyOS NEXT版本

API参考Java API参考ohos.data.ormClassOrmMigration

OrmMigration

java.lang.Object

|---ohos.data.orm.OrmMigration

收起
自动换行
深色代码主题
复制
  1. public abstract class OrmMigration
  2. extends Object
Upgrades and downgrades databases.

If you need to modify the database structure, for example, add a table or field, you need to create a database class, specify the new database version, and then prepare an SQL statement for upgrading or downgrading between the start and end versions specified by OrmMigration(int, int). The ORM annotation processor will identify the start and end version, and execute the specified SQL statement to complete the upgrade or downgrade.

Since:

1

Constructor Summary

展开

Constructor

Description

OrmMigration​(int beginVersion, int endVersion)

Constructor of this class for upgrading or downgrading from the start version to the end version.

Method Summary

展开

Modifier and Type

Method

Description

int

getBeginVersion​()

Obtains the value of variable beginVersion.

int

getEndVersion​()

Obtains the value of variable endVersion.

abstract void

onMigrate​(RdbStore store)

Upgrades or downgrades the database.

展开

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

OrmMigration

public OrmMigration​(int beginVersion, int endVersion)

Constructor of this class for upgrading or downgrading from the start version to the end version.

Parameters:

展开

Parameter Name

Parameter Description

beginVersion

Indicates the start version.

endVersion

Indicates the end version.

Since:

1

Method Detail

getBeginVersion

public int getBeginVersion​()

Obtains the value of variable beginVersion.

Returns:

Returns the value of variable beginVersion.

getEndVersion

public int getEndVersion​()

Obtains the value of variable endVersion.

Returns:

Returns the value of variable endVersion.

onMigrate

public abstract void onMigrate​(RdbStore store)

Upgrades or downgrades the database.

You need to specify the SQL statement for upgrading or downgrading from the start version to the end version.

Parameters:

展开

Parameter Name

Parameter Description

store

Indicates the handle of the relational database.

Since:

1

See Also:

RdbStore

搜索
请输入您想要搜索的关键词