Greg Claude Opus 4.7 (1M context) commited on
Commit
c4b0d0f
·
1 Parent(s): c2e5673

feat(accounts): add U.E.C Maria Antonia Valero demo account migration

Browse files

Creates a parallel is_demo=true account with admin user (Rosmery
Contreras) on alembic upgrade. Schedule L-V 07:00-12:00, facial
check-in mode, pro plan. Idempotent inserts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

.claude/settings.local.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(python -m py_compile app/api/v1/endpoints/enrollments.py)"
5
- ]
6
- }
7
- }
 
 
 
 
 
 
 
 
backend/alembic/versions/027_create_maria_antonia_valero_account.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """create U.E.C Maria Antonia Valero demo account with admin user
2
+
3
+ Creates a second is_demo=TRUE tenant (coexists with the Talos demo) for
4
+ showcase purposes. The /developer/purge-demo endpoint targets the FIRST
5
+ is_demo account it finds (lowest id), which remains the Talos one — this
6
+ new account is not affected by purge.
7
+
8
+ Defaults (CAMBIAR DESPUÉS DEL PRIMER LOGIN):
9
+ - email: admin@mariaantoniavalero.com
10
+ - password: mav2026
11
+
12
+ Revision ID: 027
13
+ Revises: 026
14
+ Create Date: 2026-06-02
15
+ """
16
+
17
+ from alembic import op
18
+
19
+ revision = "027"
20
+ down_revision = "026"
21
+ branch_labels = None
22
+ depends_on = None
23
+
24
+
25
+ ORG_NAME = "U.E.C Maria Antonia Valero"
26
+ ADMIN_EMAIL = "admin@mariaantoniavalero.com"
27
+ ADMIN_PASSWORD = "mav2026"
28
+
29
+ SCHEDULE_JSON = (
30
+ '{"monday":{"entry":"07:00","exit":"12:00"},'
31
+ '"tuesday":{"entry":"07:00","exit":"12:00"},'
32
+ '"wednesday":{"entry":"07:00","exit":"12:00"},'
33
+ '"thursday":{"entry":"07:00","exit":"12:00"},'
34
+ '"friday":{"entry":"07:00","exit":"12:00"}}'
35
+ )
36
+
37
+
38
+ def upgrade() -> None:
39
+ import bcrypt # noqa: PLC0415
40
+
41
+ op.execute(
42
+ f"""
43
+ INSERT INTO accounts (
44
+ organization_name,
45
+ address,
46
+ director_name,
47
+ category,
48
+ plan_id,
49
+ tolerance,
50
+ checkin_mode,
51
+ self_checkin_enabled,
52
+ is_active,
53
+ is_demo,
54
+ schedule
55
+ )
56
+ SELECT
57
+ '{ORG_NAME}',
58
+ NULL,
59
+ 'Rosmery Contreras',
60
+ 'school',
61
+ COALESCE(
62
+ (SELECT id FROM plans WHERE name = 'pro' LIMIT 1),
63
+ (SELECT id FROM plans ORDER BY id DESC LIMIT 1)
64
+ ),
65
+ 15,
66
+ 'facial',
67
+ 0,
68
+ TRUE,
69
+ TRUE,
70
+ '{SCHEDULE_JSON}'::json
71
+ WHERE NOT EXISTS (
72
+ SELECT 1 FROM accounts WHERE organization_name = '{ORG_NAME}'
73
+ )
74
+ """
75
+ )
76
+
77
+ password_hash = bcrypt.hashpw(ADMIN_PASSWORD.encode(), bcrypt.gensalt()).decode()
78
+
79
+ op.execute(
80
+ f"""
81
+ INSERT INTO users (
82
+ account_id,
83
+ name,
84
+ lastname,
85
+ email,
86
+ password_hash,
87
+ role,
88
+ is_active
89
+ )
90
+ SELECT
91
+ (SELECT id FROM accounts WHERE organization_name = '{ORG_NAME}' LIMIT 1),
92
+ 'Rosmery',
93
+ 'Contreras',
94
+ '{ADMIN_EMAIL}',
95
+ '{password_hash}',
96
+ 'admin',
97
+ '1'
98
+ WHERE NOT EXISTS (
99
+ SELECT 1 FROM users WHERE email = '{ADMIN_EMAIL}'
100
+ )
101
+ """
102
+ )
103
+
104
+
105
+ def downgrade() -> None:
106
+ op.execute(f"DELETE FROM users WHERE email = '{ADMIN_EMAIL}'")
107
+ op.execute(f"DELETE FROM accounts WHERE organization_name = '{ORG_NAME}'")