Automatically adding the new table/rework into the sqitch plan when I. create a pr in git

131 views
Skip to first unread message

mdha...@xometry.com

unread,
Jul 1, 2020, 8:37:35 AM7/1/20
to Sqitch Users
I have implemented the CICD pipeline with the sqitch, snowflake and  gitlab
my pipeline do this for adding a new table
1) I will add the new table to a sqitch plan, by using sqitch add command manually
2) once I pushed my changes to remote branch I have and then I create a pr  it will create a job in gitlab and build the sqitch docker image and perform some tests and it will deploy the changes that I added in sqitch plan manually in step 1
But there is a request from our team is without installing the sqitch locally or locally building the docker image and add the new table to sqitch plan, is there is a way where we can automate the step 1, means
- when I create a table in my git repo in deploy folder (without doing with sqitch add, just normally adding the new file) and when I create a pr, I want sqitch to be integrated to my git repo, so that it will automatically add the new table/ rework we added in the deploy folder into the sqitch plan without manually adding it and then do the step 2

David E. Wheeler

unread,
Jul 1, 2020, 10:47:50 AM7/1/20
to mdha...@xometry.com, Sqitch Users
On Jul 1, 2020, at 08:37, 'mdha...@xometry.com' via Sqitch Users <sqitch...@googlegroups.com> wrote:

> - when I create a table in my git repo in deploy folder (without doing with sqitch add, just normally adding the new file) and when I create a pr, I want sqitch to be integrated to my git repo, so that it will automatically add the new table/ rework we added in the deploy folder into the sqitch plan without manually adding it and then do the step 2

No, but you could manually add it to the plan file by copying a previous change and editing it. The format for a change is:


$change_name [space-delimited list of dependencies] $ISO8601-UTC-Date $author_name <$email> # Note with whatever UTF-8 characters you like, as long as it stays on a single line.

Example from the tutorial:

lists [users] 2013-12-31T19:28:05Z Marge N. O’Vera <ma...@example.com> # Adds table for storing lists.

A tag is similar, but always starts with an @ sign (change names must not include spaces or at signs):

@$tag_name $ISO8601-UTC-Date $author_name <$email> # UTF-8 Note

Again from the tutorial:

@v1.0.0-dev2 2013-12-31T19:52:13Z Marge N. O’Vera <ma...@example.com> # Tag v1.0.0-dev2.

So you can do it manually, and in your pipeline Sqitch will complain if there’s an error. But I have to ask: what’s the barrier from your team to installing and using Sqitch?

Best,

David

signature.asc

mdha...@xometry.com

unread,
Jul 7, 2020, 10:17:54 AM7/7/20
to Sqitch Users
Thank you David

mdha...@xometry.com

unread,
Jul 22, 2020, 9:48:10 AM7/22/20
to Sqitch Users
Hi David,
Here is what I tried
1) Added first SQL file "TEST.sql" in deploy folder and then in the plan without using the "sqitch add" I added it manually as follows 
    TEST 2020-07-20T08:14:09Z mangadhatrika <mangad...@test.com> # Adding new files
2) Deployed the change without any error
3) I added a new column in TEST.sql and now I added manually again without doing the "sqitch rework" I added it manually as follows

@v1.0.0-devcd57a16 2020-07-22T08:08:15Z mangadhatrika <mangad...@test.com> # tag v2.0.0-devcd57a16
TEST [TE...@v1.0.0-devcd57a16] 2020-07-22T08:08:15Z mangadhatrika <mangad...@test.com>

Then I see the different errors 

. [Errno 2] No such file or directory: 'deploy/TE...@v1.0.0-devcd57a16

not ok

"/Applications/SnowSQL.app/Contents/MacOS/snowsql" unexpectedly returned exit value 1

Deploy failed


next thing I tried is the adding the file manually to the deploy folder TE...@v1.0.0-devcd57a16.sql then it is not identifying that partcular file has been changed and it says "Nothing to deploy" and passed


Please help me what I am I doing wrong? This is last blocking block to complete my implementation

Thanks,
Manga

David E. Wheeler

unread,
Aug 1, 2020, 4:03:30 PM8/1/20
to mdha...@xometry.com, Sqitch Users
On Jul 22, 2020, at 09:48, 'mdha...@xometry.com' via Sqitch Users <sqitch...@googlegroups.com> wrote:

> 3) I added a new column in TEST.sql and now I added manually again without doing the "sqitch rework" I added it manually as follows
>
> @v1.0.0-devcd57a16 2020-07-22T08:08:15Z mangadhatrika <mangad...@test.com> # tag v2.0.0-devcd57a16
> TEST [TE...@v1.0.0-devcd57a16] 2020-07-22T08:08:15Z mangadhatrika <mangad...@test.com>
>
> Then I see the different errors
>
> . [Errno 2] No such file or directory: 'deploy/TE...@v1.0.0-devcd57a16

This is why I recommend the use of the `sqitch rework` command: It handles all the file renaming for you (as described in some detail in the tutorials).

That said, I don’t recommend `rework` for adding columns, because ALTER TABLE ADD COLUMN is not idempotent. I suggest adding a new change, instead (or, if you haven’t released, just change the deploy file directly).

> next thing I tried is the adding the file manually to the deploy folder TE...@v1.0.0-devcd57a16.sql then it is not identifying that partcular file has been changed and it says "Nothing to deploy" and passed

TE...@v1.0.0-devcd57a16.sql should contain the contents of the original TEST.sql file, then you can edit TEST.sql directly.

HTH,

David

signature.asc
Reply all
Reply to author
Forward
0 new messages