realtimex-crm 0.4.0 → 0.4.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "realtimex-crm",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
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,7 @@
|
|
|
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'",
|
|
68
69
|
"ghpages:deploy": "node ./scripts/ghpages-deploy.mjs",
|
|
69
70
|
"supabase:remote:init": "node ./scripts/supabase-remote-init.mjs",
|
|
70
71
|
"prepare": "husky"
|
|
@@ -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)
|