Skip to content

Commit 9759ffc

Browse files
ImTotemclaude
andcommitted
fix(infra): add id to workflow JSONs, clean up old hourly workflow
n8n import:workflow requires id field. Also delete the old "Link Auto-Expiration (hourly)" before importing the new (1min). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 091db8b commit 9759ffc

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

infra/scripts/init_n8n.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,18 @@ import_workflow() {
3636
return 0
3737
fi
3838
echo " Importing '$name'..."
39-
$COMPOSE exec -T n8n n8n import:workflow --input="$file"
39+
$COMPOSE exec -T n8n n8n import:workflow --input="$file" 2>&1 || true
40+
}
41+
42+
delete_workflow() {
43+
local name="$1"
44+
if ! workflow_exists "$name"; then
45+
return 0
46+
fi
47+
local wf_id
48+
wf_id=$($COMPOSE exec -T n8n n8n list:workflow 2>&1 | grep "$name" | awk -F'|' '{print $1}')
49+
echo " Deleting old workflow '$name' (id: $wf_id)..."
50+
$COMPOSE exec -T n8n n8n delete:workflow --id="$wf_id" 2>&1 || true
4051
}
4152

4253
setup_owner() {
@@ -113,7 +124,10 @@ setup_owner
113124
echo "4. Setting up Postgres credential..."
114125
setup_pg_credential
115126

116-
echo "5. Importing workflows..."
127+
echo "5. Cleaning up old workflows..."
128+
delete_workflow "Link Auto-Expiration (hourly)"
129+
130+
echo "6. Importing workflows..."
117131
import_workflow "/workflows/pg_sheets_sync.json" "PG → Sheets Sync (5min)"
118132
import_workflow "/workflows/link_auto_expire.json" "Link Auto-Expiration (1min)"
119133

workflows/link_auto_expire.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"id": "link-auto-expire",
23
"name": "Link Auto-Expiration (1min)",
34
"nodes": [
45
{

workflows/pg_sheets_sync.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"id": "pg-sheets-sync",
23
"name": "PG → Sheets Sync (5min)",
34
"nodes": [
45
{

0 commit comments

Comments
 (0)