From 111459bb3bc05b264777883167c9d4a8b8dceb20 Mon Sep 17 00:00:00 2001 From: Sandeep Raj Kumar Date: Tue, 3 Dec 2024 23:08:27 +0530 Subject: [PATCH] =?UTF-8?q?Allow=2014=20digit=20prefixes=20for=20migration?= =?UTF-8?q?=20directories=20during=20`hasura=20scri=E2=80=A6=20(#11107)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/hasura/graphql-engine-mono/pull/11092 GitOrigin-RevId: 8d3ab13aa1be37e569822a961119e48e6ce65d01 --- cli/internal/scripts/update-project-v3.go | 2 +- cli/internal/scripts/update-project-v3_test.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cli/internal/scripts/update-project-v3.go b/cli/internal/scripts/update-project-v3.go index 9626de08d2b..25f01299dd9 100644 --- a/cli/internal/scripts/update-project-v3.go +++ b/cli/internal/scripts/update-project-v3.go @@ -294,7 +294,7 @@ func getMatchingFilesAndDirs(fs afero.Fs, parentDir string, matcher func(string) func isHasuraCLIGeneratedMigration(dirPath string) (bool, error) { var op errors.Op = "scripts.isHasuraCLIGeneratedMigration" - const regex = `^([0-9]{13})_(.*)$` + const regex = `^([0-9]{13,14})_(.*)$` match, err := regexp.MatchString(regex, filepath.Base(dirPath)) if err != nil { return match, errors.E(op, err) diff --git a/cli/internal/scripts/update-project-v3_test.go b/cli/internal/scripts/update-project-v3_test.go index 6868d25478c..b43150c8f5e 100644 --- a/cli/internal/scripts/update-project-v3_test.go +++ b/cli/internal/scripts/update-project-v3_test.go @@ -59,6 +59,24 @@ func Test_checkIfDirectoryIsMigration(t *testing.T) { false, require.NoError, }, + { + "can check if a directory name is a valid migration, 14 chars", + args{ + dirPath: "16048559649031_test", + }, + true, + false, + require.NoError, + }, + { + "can check if a directory name is a valid migration, 15 chars", + args{ + dirPath: "160485596490312_test", + }, + false, + false, + require.NoError, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {