revision
alembic.command.revision(config: Config, message: Optional[str] = None, autogenerate: bool = False, sql: bool = False, head: str = 'head', splice: bool = False, branch_label: Optional[str] = None, version_path: Optional[str] = None, rev_id: Optional[str] = None, depends_on: Optional[str] = None, process_revision_directives: Callable = None) → Union[Script, None, List[Optional[Script]]]
Create a new revision file.
创建一个新的修订文件。
Parameters:
- config – a Config object.
- message – string message to apply to the revision; this is the
-moption toalembic revision. - autogenerate – whether or not to autogenerate the script from the database; this is the
--autogenerateoption toalembic revision. - sql – whether to dump the script out as a SQL string; when specified, the script is dumped to stdout. This is the
--sqloption toalembic revision. - head – head revision to build the new revision upon as a parent; this is the
--headoption toalembic revision. - splice – whether or not the new revision should be made into a new
headof its own; is required when the givenheadis not itself ahead. This is the--spliceoption toalembic revision. - branch_label – string label to apply to the branch; this is the
--branch-labeloption toalembic revision. - version_path – string symbol identifying a specific version path from the configuration; this is the
--version-pathoption toalembic revision. - rev_id – optional revision identifier to use instead of having one generated; this is the
--rev-idoption toalembic revision. - depends_on – optional list of “depends on” identifiers; this is the
--depends-onoption toalembic revision. - process_revision_directives – this is a callable that takes the same form as the callable described at EnvironmentContext.configure.process_revision_directives; will be applied to the structure generated by the revision process where it can be altered programmatically. Note that unlike all the other parameters, this option is only available via programmatic use of command.revision()
参数:
- config – 一个 Config 实例.
- message – 应用于修订的字符串 消息 ; 这是
alembic revision命令的-m选项。- autogenerate – 是否从数据库 自动生成 脚本; 这是
alembic revision命令的--autogenerate选项。- sql – 是否将脚本作为 SQL 字符串转储; 指定时,脚本被转储到标准输出。 这是
alembic revision命令的--sql选项。- head – head 修订,以作为父版本构建新修订; 这是
alembic revision命令的--head选项。- splice – 新的修订是否应该成为的新 head; 当给定的
head本身不是head时是必需的。 这是alembic revision命令的--splice选项。- branch_label – 应用于分支的字符串标签; 这是
alembic revision命令的--branch-label选项。- version_path – 标识配置中特定版本路径的字符串符号; 这是
alembic revision命令的--version-path选项。- rev_id – 要使用的可选修订标识符,而不是生成一个; 这是
alembic revision命令的--rev-id选项。- depends_on – “依赖于xxx”标识符的可选列表; 这是
alembic revision命令的--depends-on选项。- process_revision_directives – 这是一个可调用对象,其形式与 EnvironmentContext.configure.process_revision_directives 中描述的可调用对象相同; 将应用于由修订过程生成的结构,可以通过编程方式对其进行更改。 请注意,与所有其他参数不同,此选项仅可通过以编程方式使用 command.revision()