英文:
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=<输入仓库名称>&db=<输入数据库名称>&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=<ENTER YOUR SNOWFLAKE_USERNAME>
set SNOWFLAKE_PASSWORD=<ENTER YOUR SNOWFLAKE PASSWORD>
set FLYWAY_VERSION=0.0
set FLYWAY_FOLDER_LOCATION=./sql/
set
FLYWAY_LICENSE_KEY=<ENTER YOUR LICENCE KEY>
set FLYWAY_URL="jdbc:snowflake://<YOUR ACCOUNT URL>/?warehouse=<ENTER WAREHOUSE NAME>&db=<ENTER DB NAME>&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%"
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's Snowflake support can be found in the Flyway documentation.
https://documentation.red-gate.com/fd/snowflake-184127607.html
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论