Skip to content

Commit 9264a22

Browse files
ImTotemclaude
andcommitted
fix(data): payment_status to Korean + n8n owner auto-setup
- Change payment_status defaults: Unpaid→미납, Paid→납부, Exempt→면제 - Add migration 002 to update existing PG data - Add n8n owner account auto-creation via REST API on first deploy Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cfa9931 commit 9264a22

File tree

6 files changed

+76
-9
lines changed

6 files changed

+76
-9
lines changed

alembic/versions/001_initial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def upgrade() -> None:
3131
sa.Column("team", sa.String),
3232
sa.Column("role", sa.String),
3333
sa.Column("join_date", sa.String),
34-
sa.Column("payment_status", sa.String, server_default="Unpaid"),
34+
sa.Column("payment_status", sa.String, server_default="미납"),
3535
sa.Column("last_updated", sa.String),
3636
)
3737

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""payment_status values to Korean
2+
3+
Revision ID: 002
4+
Revises: 001
5+
"""
6+
7+
from alembic import op
8+
9+
revision = "002"
10+
down_revision = "001"
11+
12+
_MAPPING = {
13+
"Unpaid": "미납",
14+
"Paid": "납부",
15+
"Exempt": "면제",
16+
}
17+
18+
19+
def upgrade() -> None:
20+
for eng, kor in _MAPPING.items():
21+
op.execute(
22+
f"UPDATE payment_statuses SET name = '{kor}' WHERE name = '{eng}'"
23+
)
24+
op.execute(
25+
f"UPDATE members SET payment_status = '{kor}' WHERE payment_status = '{eng}'"
26+
)
27+
op.execute("ALTER TABLE members ALTER COLUMN payment_status SET DEFAULT '미납'")
28+
29+
30+
def downgrade() -> None:
31+
for eng, kor in _MAPPING.items():
32+
op.execute(
33+
f"UPDATE payment_statuses SET name = '{eng}' WHERE name = '{kor}'"
34+
)
35+
op.execute(
36+
f"UPDATE members SET payment_status = '{eng}' WHERE payment_status = '{kor}'"
37+
)
38+
op.execute("ALTER TABLE members ALTER COLUMN payment_status SET DEFAULT 'Unpaid'")

infra/scripts/init_n8n.sh

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,32 @@ json.dump(cred, sys.stdout)
7878
echo "$cred_json" | $COMPOSE exec -T n8n n8n import:credentials --input=/dev/stdin
7979
}
8080

81+
setup_owner() {
82+
set -a; source .env; set +a
83+
local port
84+
port=$(grep -m1 '^N8N_PORT=' .env | cut -d= -f2-)
85+
local status
86+
status=$(curl -sf "http://localhost:${port}/rest/settings" 2>/dev/null | python3 -c "
87+
import json, sys
88+
d = json.load(sys.stdin)
89+
print('setup' if d.get('userManagement',{}).get('showSetupOnFirstLoad') else 'done')
90+
" 2>/dev/null || echo "unknown")
91+
if [ "$status" != "setup" ]; then
92+
echo " Owner already configured — skipping"
93+
return 0
94+
fi
95+
echo " Creating owner account..."
96+
curl -sf -X POST "http://localhost:${port}/rest/owner/setup" \
97+
-H "Content-Type: application/json" \
98+
-d "{
99+
\"email\": \"${N8N_AUTH_USER}@bcsdlab.com\",
100+
\"firstName\": \"BCSD\",
101+
\"lastName\": \"Admin\",
102+
\"password\": \"${N8N_AUTH_PASSWORD}\"
103+
}" > /dev/null
104+
echo " Owner created: ${N8N_AUTH_USER}@bcsdlab.com"
105+
}
106+
81107
echo "=== n8n Init ==="
82108

83109
echo "1. Starting n8n..."
@@ -90,15 +116,18 @@ if ! wait_n8n; then
90116
exit 1
91117
fi
92118

93-
echo "3. Importing workflows..."
119+
echo "3. Setting up owner account..."
120+
setup_owner
121+
122+
echo "4. Importing workflows..."
94123
import_workflow "/workflows/pg_sheets_sync.json" "PG → Sheets Sync (5min)"
95124
import_workflow "/workflows/link_auto_expire.json" "Link Auto-Expiration (hourly)"
96125

97-
echo "4. Setting up Google Sheets credential..."
126+
echo "5. Setting up Google Sheets credential..."
98127
set -a; source .env; set +a
99128
setup_credential
100129

101-
echo "5. Activating workflows..."
130+
echo "6. Activating workflows..."
102131
activate_workflow "PG → Sheets Sync"
103132
activate_workflow "Link Auto-Expiration"
104133

src/bcsd_api/auth/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,5 @@ def _base_fields(member_id: str, name: str, email: str) -> dict:
9090
"email": email,
9191
"status": "Beginner",
9292
"team": "",
93-
"payment_status": "Unpaid",
93+
"payment_status": "미납",
9494
}

src/bcsd_api/sheets/migrations/V001_initial.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
{"name": "Mentor"},
4646
],
4747
"payment_statuses": [
48-
{"name": "Unpaid"},
49-
{"name": "Paid"},
50-
{"name": "Exempt"},
48+
{"name": "미납"},
49+
{"name": "납부"},
50+
{"name": "면제"},
5151
],
5252
}
5353

src/bcsd_api/tables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
Column("team", String),
1717
Column("role", String),
1818
Column("join_date", String),
19-
Column("payment_status", String, server_default="Unpaid"),
19+
Column("payment_status", String, server_default="미납"),
2020
Column("last_updated", String),
2121
)
2222

0 commit comments

Comments
 (0)