-1

我想使用 Fluent Migrator 为我的 .net 项目进行数据库迁移。任何人都有将 Fluent Migrator 与 XL Deploy 集成以进行数据库部署的成功案例?

问候,潘迪安。

4

1 回答 1

1

这可以通过自定义来完成 使用XLDeploy 规则 您首先需要拥有迁移脚本,该脚本将包含迁移数据库所需的步骤。

然后您需要在 XL Deploy 服务器的ext文件夹中添加或修改以下文件:

1-synthetic.xml,它将包含定义的配置项(CI)类型。例如,这些将包含您需要传递给脚本的参数,如下所示,

<type type="MigrateDB.DeployedScripts" extends="udm.BaseDeployedArtifact" deployable-type="MigrateDB.Scripts" container-type="MigrateDB.Runner">
    <property name="username"
          kind="string"
          required="false"
          description="The user to use to connect to the database."/>
    <property name="password"
          kind="string"
          required="false"
          password="true"
          description="The password to use to connect to the database."/>
    <property name="schemas"
          kind="set_of_string"
          required="true"
          description="list of schemas."/>
</type>

2- xl-rules.xml,它将包含定义的规则

首先,您在进行初始部署或通过设置条件更新时定义何时需要运行此规则,如下所示

<conditions>
    <type>MigrateDB.DeployedScripts</type>
    <operation>CREATE</operation>
    <operation>MODIFY</operation>
</conditions>

然后您可以定义迁移脚本的位置,该位置将相对于ext目录,如下所示,

<jython>
    <description expression="true">"Run migration"</description>
    <order>50</order>
    <script-path>MigratDB/run-migration.py</script-path>
</jython>

确保在应用这些更改后重新启动 XLDeploy 服务。你可以看看这个插件xld-flyway-plugin是如何创建的。你也可以尝试通过将它的 jar 放在plugins目录下来发现和使用它。

于 2018-09-25T15:52:06.497 回答