如何在Windows上为Snowflake设置Flyway。

huangapple go评论67阅读模式
英文:

How to setup Flyway for snowflake on Windows

问题

我们正在寻找自动部署Snowflake数据库对象的方法。我们了解到Flyway数据库迁移工具,并正在查阅文档以执行部署以推送更改。

Flyway是否与Snowflake兼容?如果是的话,我如何从Windows使用Flyway进行数据库部署。

英文:

We are looking for auto deployment of database objects for snowflake. We came across flyway database migration tool and going through the documentation to perform the deployment to push the changes.

Does FLyway work with Snowflake. if yes, how can I use flyway from windows to make the database deployments.

答案1

得分: 1

**Windows - Flyway Snowflake 设置**

下载 Flyway 并解压到 `c:\tools\flyway`

设置环境变量 

```FLYWAY_HOME=c:\tools\flyway```

创建文件夹

    mkdir c:\dev\db-migration\sql
    cd c:\dev\db-migration\sql

创建文件 `V1.1__create_table_person.sql`,内容如下

    create table person(
      id number,
      full_name varchar2(30)
    );

打开命令提示符并运行以下命令

    set SNOWFLAKE_USERNAME=<输入你的 SNOWFLAKE_USERNAME>
    set SNOWFLAKE_PASSWORD=<输入你的 SNOWFLAKE 密码>
    set FLYWAY_VERSION=0.0
    set FLYWAY_FOLDER_LOCATION=./sql/
    
    set 
    FLYWAY_LICENSE_KEY=<输入你的许可证密钥>
    
    set FLYWAY_URL="jdbc:snowflake://<你的账户 URL>/?warehouse=<输入仓库名称>&amp;db=<输入数据库名称>&amp;JDBC_QUERY_RESULT_FORMAT=JSON"
    
    flyway -licenseKey=%FLYWAY_LICENSE_KEY% info -url=%FLYWAY_URL% -user=%SNOWFLAKE_USERNAME% -password=%SNOWFLAKE_PASSWORD% -locations="filesystem:%FLYWAY_FOLDER_LOCATION%" -baselineOnMigrate=true -baselineVersion="%FLYWAY_VERSION%"

输出

+------------+---------+------------------------+------+--------------+---------+----------+
| 类别 | 版本 | 描述 | 类型 | 安装于 | 状态 | 可撤销 |
+------------+---------+------------------------+------+--------------+---------+----------+
| 版本化 | 1.1 | 创建表格 person | SQL | | 待处理 | 否 |
+------------+---------+------------------------+------+--------------+---------+----------+


<details>
<summary>英文:</summary>

**Windows - Flyway Snowflake setup**

download flyway and extract to `c:\tools\flyway` 

set environment variable 

```FLYWAY_HOME=c:\tools\flyway``` 

create folder

    mkdir c:\dev\db-migration\sql
    cd c:\dev\db-migration\sql

create file `V1.1__create_table_person.sql` with content

    create table person(
      id number,
      full_name varchar2(30)
    );

open command prompt and run below commands

    set SNOWFLAKE_USERNAME=&lt;ENTER YOUR SNOWFLAKE_USERNAME&gt;
    set SNOWFLAKE_PASSWORD=&lt;ENTER YOUR SNOWFLAKE PASSWORD&gt;
    set FLYWAY_VERSION=0.0
    set FLYWAY_FOLDER_LOCATION=./sql/
    
    set 
    FLYWAY_LICENSE_KEY=&lt;ENTER YOUR LICENCE KEY&gt;
    
    set FLYWAY_URL=&quot;jdbc:snowflake://&lt;YOUR ACCOUNT URL&gt;/?warehouse=&lt;ENTER WAREHOUSE NAME&gt;&amp;db=&lt;ENTER DB NAME&gt;&amp;JDBC_QUERY_RESULT_FORMAT=JSON&quot;
    
    flyway -licenseKey=%FLYWAY_LICENSE_KEY% info -url=%FLYWAY_URL% -user=%SNOWFLAKE_USERNAME% -password=%SNOWFLAKE_PASSWORD% -locations=&quot;filesystem:%FLYWAY_FOLDER_LOCATION%&quot; -baselineOnMigrate=true -baselineVersion=&quot;%FLYWAY_VERSION%&quot;

output

+------------+---------+------------------------+------+--------------+---------+----------+
| Category | Version | Description | Type | Installed On | State | Undoable |
+------------+---------+------------------------+------+--------------+---------+----------+
| Versioned | 1.1 | create table person | SQL | | Pending | No |
+------------+---------+------------------------+------+--------------+---------+----------+








</details>



# 答案2
**得分**: 1

只是要补充一下@Bikram提供的答案,在Flyway的Snowflake支持方面,可以在Flyway文档中找到一些额外的信息。
https://documentation.red-gate.com/fd/snowflake-184127607.html

<details>
<summary>英文:</summary>

Just to add to the answer @Bikram gave, some additional information on Flyway&#39;s Snowflake support can be found in the Flyway documentation.
https://documentation.red-gate.com/fd/snowflake-184127607.html

</details>



huangapple
  • 本文由 发表于 2023年5月26日 10:28:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76337294.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定