realtimex-crm 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{DealList-C7t7lLe9.js → DealList-B7Q5fWfD.js} +2 -2
- package/dist/assets/{DealList-C7t7lLe9.js.map → DealList-B7Q5fWfD.js.map} +1 -1
- package/dist/assets/{index-IQ-gFBbx.js → index-7x4zGeo4.js} +33 -30
- package/dist/assets/{index-IQ-gFBbx.js.map → index-7x4zGeo4.js.map} +1 -1
- package/dist/index.html +1 -1
- package/dist/stats.html +1 -1
- package/package.json +3 -1
- package/src/components/atomic-crm/setup/DatabaseSetupGuide.tsx +58 -63
- package/supabase/migrations/README.md +98 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "realtimex-crm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "RealTimeX CRM - A full-featured CRM built with React, shadcn-admin-kit, and Supabase. Fork of Atomic CRM with RealTimeX App SDK integration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -65,6 +65,8 @@
|
|
|
65
65
|
"prettier": "prettier --config ./.prettierrc.json --check \"**/*.{js,json,ts,tsx,css,md,html}\"",
|
|
66
66
|
"registry:build": "npx shadcn build",
|
|
67
67
|
"registry:gen": "node ./scripts/generate-registry.mjs",
|
|
68
|
+
"setup:gen": "cat supabase/migrations/*.sql > public/setup.sql && echo 'Generated public/setup.sql from migrations'",
|
|
69
|
+
"db:migrate": "node ./scripts/auto-migrate.mjs",
|
|
68
70
|
"ghpages:deploy": "node ./scripts/ghpages-deploy.mjs",
|
|
69
71
|
"supabase:remote:init": "node ./scripts/supabase-remote-init.mjs",
|
|
70
72
|
"prepare": "husky"
|
|
@@ -61,17 +61,65 @@ export function DatabaseSetupGuide({
|
|
|
61
61
|
</div>
|
|
62
62
|
</div>
|
|
63
63
|
|
|
64
|
-
{/* Option 1:
|
|
64
|
+
{/* Option 1: Automatic Migration */}
|
|
65
65
|
<div className="space-y-3">
|
|
66
66
|
<div className="flex items-center gap-2">
|
|
67
67
|
<div className="flex items-center justify-center w-6 h-6 rounded-full bg-primary text-primary-foreground text-sm font-bold">
|
|
68
68
|
1
|
|
69
69
|
</div>
|
|
70
|
-
<h3 className="font-semibold">
|
|
70
|
+
<h3 className="font-semibold">Automatic Migration (Recommended)</h3>
|
|
71
71
|
</div>
|
|
72
72
|
<div className="ml-8 space-y-3">
|
|
73
73
|
<p className="text-sm text-muted-foreground">
|
|
74
|
-
|
|
74
|
+
Run the automated migration script from your terminal:
|
|
75
|
+
</p>
|
|
76
|
+
|
|
77
|
+
<div className="space-y-3">
|
|
78
|
+
<div>
|
|
79
|
+
<p className="text-sm text-muted-foreground mb-2 font-semibold">
|
|
80
|
+
If you used the CLI to create your project:
|
|
81
|
+
</p>
|
|
82
|
+
<pre className="bg-muted p-3 rounded text-sm overflow-x-auto">
|
|
83
|
+
npm run db:migrate
|
|
84
|
+
</pre>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div>
|
|
88
|
+
<p className="text-sm text-muted-foreground mb-2 font-semibold">
|
|
89
|
+
Or clone the repository first:
|
|
90
|
+
</p>
|
|
91
|
+
<pre className="bg-muted p-3 rounded text-sm overflow-x-auto">
|
|
92
|
+
git clone https://github.com/therealtimex/realtimex-crm.git{"\n"}
|
|
93
|
+
cd realtimex-crm{"\n"}
|
|
94
|
+
npm install{"\n"}
|
|
95
|
+
npm run db:migrate
|
|
96
|
+
</pre>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<div className="text-sm text-muted-foreground space-y-2">
|
|
100
|
+
<p>The script will:</p>
|
|
101
|
+
<ul className="list-disc list-inside ml-2 space-y-1">
|
|
102
|
+
<li>Install Supabase CLI if needed</li>
|
|
103
|
+
<li>Link your project using Project ID and Database Password</li>
|
|
104
|
+
<li>Apply all migrations automatically</li>
|
|
105
|
+
<li>Take about 5-10 seconds to complete</li>
|
|
106
|
+
</ul>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
{/* Option 2: SQL Editor */}
|
|
113
|
+
<div className="space-y-3">
|
|
114
|
+
<div className="flex items-center gap-2">
|
|
115
|
+
<div className="flex items-center justify-center w-6 h-6 rounded-full bg-primary text-primary-foreground text-sm font-bold">
|
|
116
|
+
2
|
|
117
|
+
</div>
|
|
118
|
+
<h3 className="font-semibold">Manual SQL Editor</h3>
|
|
119
|
+
</div>
|
|
120
|
+
<div className="ml-8 space-y-3">
|
|
121
|
+
<p className="text-sm text-muted-foreground">
|
|
122
|
+
Copy and paste SQL directly into Supabase:
|
|
75
123
|
</p>
|
|
76
124
|
|
|
77
125
|
<ol className="list-decimal list-inside space-y-2 text-sm text-muted-foreground">
|
|
@@ -82,7 +130,7 @@ export function DatabaseSetupGuide({
|
|
|
82
130
|
target="_blank"
|
|
83
131
|
rel="noopener noreferrer"
|
|
84
132
|
className="text-primary hover:underline inline-flex items-center gap-1"
|
|
85
|
-
download
|
|
133
|
+
download="setup.sql"
|
|
86
134
|
>
|
|
87
135
|
setup.sql
|
|
88
136
|
<ExternalLink className="h-3 w-3" />
|
|
@@ -100,15 +148,9 @@ export function DatabaseSetupGuide({
|
|
|
100
148
|
<ExternalLink className="h-3 w-3" />
|
|
101
149
|
</a>
|
|
102
150
|
</li>
|
|
103
|
-
<li>
|
|
104
|
-
|
|
105
|
-
</li>
|
|
106
|
-
<li>
|
|
107
|
-
Click "Run" to execute all migrations at once
|
|
108
|
-
</li>
|
|
109
|
-
<li>
|
|
110
|
-
Reload this page after completion
|
|
111
|
-
</li>
|
|
151
|
+
<li>Copy all contents from setup.sql and paste into the editor</li>
|
|
152
|
+
<li>Click "Run" to execute</li>
|
|
153
|
+
<li>Reload this page after completion</li>
|
|
112
154
|
</ol>
|
|
113
155
|
|
|
114
156
|
{projectRef && (
|
|
@@ -126,13 +168,13 @@ export function DatabaseSetupGuide({
|
|
|
126
168
|
</div>
|
|
127
169
|
</div>
|
|
128
170
|
|
|
129
|
-
{/* Option
|
|
171
|
+
{/* Option 3: Supabase CLI Manual */}
|
|
130
172
|
<div className="space-y-3">
|
|
131
173
|
<div className="flex items-center gap-2">
|
|
132
174
|
<div className="flex items-center justify-center w-6 h-6 rounded-full bg-primary text-primary-foreground text-sm font-bold">
|
|
133
|
-
|
|
175
|
+
3
|
|
134
176
|
</div>
|
|
135
|
-
<h3 className="font-semibold">
|
|
177
|
+
<h3 className="font-semibold">Advanced: Manual CLI Setup</h3>
|
|
136
178
|
</div>
|
|
137
179
|
<div className="ml-8 space-y-3">
|
|
138
180
|
<div>
|
|
@@ -180,53 +222,6 @@ export function DatabaseSetupGuide({
|
|
|
180
222
|
</div>
|
|
181
223
|
</div>
|
|
182
224
|
|
|
183
|
-
{/* Option 3: Individual Migrations */}
|
|
184
|
-
<div className="space-y-3">
|
|
185
|
-
<div className="flex items-center gap-2">
|
|
186
|
-
<div className="flex items-center justify-center w-6 h-6 rounded-full bg-primary text-primary-foreground text-sm font-bold">
|
|
187
|
-
3
|
|
188
|
-
</div>
|
|
189
|
-
<h3 className="font-semibold">Advanced: Run Individual Migrations</h3>
|
|
190
|
-
</div>
|
|
191
|
-
<div className="ml-8 space-y-3">
|
|
192
|
-
<p className="text-sm text-muted-foreground">
|
|
193
|
-
For advanced users who want to review each migration:
|
|
194
|
-
</p>
|
|
195
|
-
|
|
196
|
-
<ol className="list-decimal list-inside space-y-2 text-sm text-muted-foreground">
|
|
197
|
-
<li>
|
|
198
|
-
Browse migrations at{" "}
|
|
199
|
-
<a
|
|
200
|
-
href="https://github.com/therealtimex/realtimex-crm/tree/main/supabase/migrations"
|
|
201
|
-
target="_blank"
|
|
202
|
-
rel="noopener noreferrer"
|
|
203
|
-
className="text-primary hover:underline inline-flex items-center gap-1"
|
|
204
|
-
>
|
|
205
|
-
GitHub
|
|
206
|
-
<ExternalLink className="h-3 w-3" />
|
|
207
|
-
</a>
|
|
208
|
-
</li>
|
|
209
|
-
<li>
|
|
210
|
-
Open your{" "}
|
|
211
|
-
<a
|
|
212
|
-
href={`https://supabase.com/dashboard/project/${projectRef}/sql/new`}
|
|
213
|
-
target="_blank"
|
|
214
|
-
rel="noopener noreferrer"
|
|
215
|
-
className="text-primary hover:underline inline-flex items-center gap-1"
|
|
216
|
-
>
|
|
217
|
-
Supabase SQL Editor
|
|
218
|
-
<ExternalLink className="h-3 w-3" />
|
|
219
|
-
</a>
|
|
220
|
-
</li>
|
|
221
|
-
<li>
|
|
222
|
-
Run each migration file in chronological order (by date in filename)
|
|
223
|
-
</li>
|
|
224
|
-
<li>
|
|
225
|
-
Reload this page after all migrations are complete
|
|
226
|
-
</li>
|
|
227
|
-
</ol>
|
|
228
|
-
</div>
|
|
229
|
-
</div>
|
|
230
225
|
|
|
231
226
|
{/* Verification */}
|
|
232
227
|
<div className="space-y-3 pt-4 border-t">
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Database Migrations
|
|
2
|
+
|
|
3
|
+
This directory contains all the SQL migration files needed to set up the RealTimeX CRM database schema.
|
|
4
|
+
|
|
5
|
+
## Quick Setup (Recommended)
|
|
6
|
+
|
|
7
|
+
The easiest way to set up your database is to use the combined `setup.sql` file:
|
|
8
|
+
|
|
9
|
+
1. Download [setup.sql](https://raw.githubusercontent.com/therealtimex/realtimex-crm/main/public/setup.sql)
|
|
10
|
+
2. Open your [Supabase SQL Editor](https://supabase.com/dashboard)
|
|
11
|
+
3. Copy the entire contents of `setup.sql` and paste into the SQL Editor
|
|
12
|
+
4. Click "Run" to execute all migrations at once
|
|
13
|
+
|
|
14
|
+
## Using Supabase CLI
|
|
15
|
+
|
|
16
|
+
If you prefer using the CLI:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Install Supabase CLI
|
|
20
|
+
npm install -g supabase
|
|
21
|
+
|
|
22
|
+
# Clone this repository
|
|
23
|
+
git clone https://github.com/therealtimex/realtimex-crm.git
|
|
24
|
+
cd realtimex-crm
|
|
25
|
+
|
|
26
|
+
# Link to your Supabase project
|
|
27
|
+
supabase link --project-ref YOUR_PROJECT_REF
|
|
28
|
+
|
|
29
|
+
# Push migrations
|
|
30
|
+
supabase db push
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Migration Files
|
|
34
|
+
|
|
35
|
+
These migrations are applied in chronological order (by date in filename):
|
|
36
|
+
|
|
37
|
+
1. **20240730075029_init_db.sql** - Creates core tables (contacts, companies, deals, sales, tasks, tags)
|
|
38
|
+
2. **20240730075425_init_triggers.sql** - Sets up user sync triggers between auth.users and sales table
|
|
39
|
+
3. **20240806124555_task_sales_id.sql** - Adds sales_id to tasks table
|
|
40
|
+
4. **20240807082449_remove-aquisition.sql** - Removes deprecated acquisition field
|
|
41
|
+
5. **20240808141826_init_state_configure.sql** - Creates init_state table for tracking initialization
|
|
42
|
+
6. **20240813084010_tags_policy.sql** - Adds RLS policies for tags table
|
|
43
|
+
7. **20241104153231_sales_policies.sql** - Adds RLS policies for sales table
|
|
44
|
+
8. **20250109152531_email_jsonb.sql** - Migrates email to JSONB format for multiple emails
|
|
45
|
+
9. **20250113132531_phone_jsonb.sql** - Migrates phone to JSONB format for multiple phones
|
|
46
|
+
10. **20251204172855_merge_contacts_function.sql** - Adds contact merging functionality
|
|
47
|
+
11. **20251204201317_drop_merge_contacts_function.sql** - Refactors merge function
|
|
48
|
+
|
|
49
|
+
## What Gets Created
|
|
50
|
+
|
|
51
|
+
After running migrations, your database will have:
|
|
52
|
+
|
|
53
|
+
### Tables
|
|
54
|
+
- `contacts` - Contact information with JSONB email/phone support
|
|
55
|
+
- `companies` - Company records with logo support
|
|
56
|
+
- `deals` - Deal pipeline with stages and amounts
|
|
57
|
+
- `contactNotes` - Notes attached to contacts
|
|
58
|
+
- `dealNotes` - Notes attached to deals
|
|
59
|
+
- `tasks` - Task management
|
|
60
|
+
- `sales` - CRM users (synced with auth.users)
|
|
61
|
+
- `tags` - Tagging system
|
|
62
|
+
- `init_state` - Initialization tracking
|
|
63
|
+
|
|
64
|
+
### Views
|
|
65
|
+
- `contacts_summary` - Aggregated contact data with task counts
|
|
66
|
+
- `companies_summary` - Aggregated company data
|
|
67
|
+
|
|
68
|
+
### Functions
|
|
69
|
+
- `handle_new_user()` - Auto-creates sales record when user signs up
|
|
70
|
+
- `handle_update_user()` - Syncs user metadata updates
|
|
71
|
+
- Edge functions for user management, email processing, contact merging
|
|
72
|
+
|
|
73
|
+
### Row Level Security (RLS)
|
|
74
|
+
All tables have RLS enabled with policies that:
|
|
75
|
+
- Currently use permissive policies (`using (true)`) for all authenticated users
|
|
76
|
+
- Track ownership via `sales_id` foreign keys
|
|
77
|
+
- Can be made restrictive for data isolation (see migration files for examples)
|
|
78
|
+
|
|
79
|
+
## Regenerating setup.sql
|
|
80
|
+
|
|
81
|
+
If you modify any migration files, regenerate the combined setup.sql:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm run setup:gen
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Troubleshooting
|
|
88
|
+
|
|
89
|
+
If migrations fail:
|
|
90
|
+
1. Check that your Supabase project is active and accessible
|
|
91
|
+
2. Ensure you have sufficient permissions (project owner)
|
|
92
|
+
3. Try running migrations one by one to identify the problematic migration
|
|
93
|
+
4. Check Supabase logs for detailed error messages
|
|
94
|
+
|
|
95
|
+
For help, see:
|
|
96
|
+
- [RealTimeX CRM Documentation](https://github.com/therealtimex/realtimex-crm#readme)
|
|
97
|
+
- [Supabase CLI Documentation](https://supabase.com/docs/guides/cli)
|
|
98
|
+
- [Report an Issue](https://github.com/therealtimex/realtimex-crm/issues)
|