Add all core tables to REQUIRED_TABLES for auto-creation on startup
All checks were successful
Deploy / deploy (push) Successful in 11s
All checks were successful
Deploy / deploy (push) Successful in 11s
Tables like Users, Brands, Campaigns, Projects, etc. are now created automatically by ensureRequiredTables() if they don't exist, removing the need to run setup-tables.js manually on fresh deployments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
134
server/server.js
134
server/server.js
@@ -206,6 +206,140 @@ const LINK_TO_FK = {
|
|||||||
|
|
||||||
// ─── TABLE CREATION: Ensure required tables exist ────────────────
|
// ─── TABLE CREATION: Ensure required tables exist ────────────────
|
||||||
const REQUIRED_TABLES = {
|
const REQUIRED_TABLES = {
|
||||||
|
Users: [
|
||||||
|
{ title: 'name', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'email', uidt: 'Email' },
|
||||||
|
{ title: 'role', uidt: 'SingleSelect', dtxp: "'superadmin','manager','contributor'" },
|
||||||
|
{ title: 'team_role', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'brands', uidt: 'LongText' },
|
||||||
|
{ title: 'phone', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'avatar', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'tutorial_completed', uidt: 'Checkbox' },
|
||||||
|
],
|
||||||
|
Brands: [
|
||||||
|
{ title: 'name', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'name_ar', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'priority', uidt: 'Number' },
|
||||||
|
{ title: 'color', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'icon', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'category', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'logo', uidt: 'SingleLineText' },
|
||||||
|
],
|
||||||
|
Campaigns: [
|
||||||
|
{ title: 'name', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'description', uidt: 'LongText' },
|
||||||
|
{ title: 'start_date', uidt: 'Date' },
|
||||||
|
{ title: 'end_date', uidt: 'Date' },
|
||||||
|
{ title: 'status', uidt: 'SingleSelect', dtxp: "'planning','active','paused','completed','cancelled'" },
|
||||||
|
{ title: 'color', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'budget', uidt: 'Decimal' },
|
||||||
|
{ title: 'goals', uidt: 'LongText' },
|
||||||
|
{ title: 'platforms', uidt: 'LongText' },
|
||||||
|
{ title: 'budget_spent', uidt: 'Decimal' },
|
||||||
|
{ title: 'revenue', uidt: 'Decimal' },
|
||||||
|
{ title: 'impressions', uidt: 'Number' },
|
||||||
|
{ title: 'clicks', uidt: 'Number' },
|
||||||
|
{ title: 'conversions', uidt: 'Number' },
|
||||||
|
{ title: 'cost_per_click', uidt: 'Decimal' },
|
||||||
|
{ title: 'notes', uidt: 'LongText' },
|
||||||
|
{ title: 'brand_id', uidt: 'Number' },
|
||||||
|
{ title: 'created_by_user_id', uidt: 'Number' },
|
||||||
|
],
|
||||||
|
CampaignTracks: [
|
||||||
|
{ title: 'name', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'type', uidt: 'SingleSelect', dtxp: "'organic_social','paid_social','paid_search','email','seo','influencer','event','other'" },
|
||||||
|
{ title: 'platform', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'budget_allocated', uidt: 'Decimal' },
|
||||||
|
{ title: 'budget_spent', uidt: 'Decimal' },
|
||||||
|
{ title: 'revenue', uidt: 'Decimal' },
|
||||||
|
{ title: 'impressions', uidt: 'Number' },
|
||||||
|
{ title: 'clicks', uidt: 'Number' },
|
||||||
|
{ title: 'conversions', uidt: 'Number' },
|
||||||
|
{ title: 'notes', uidt: 'LongText' },
|
||||||
|
{ title: 'status', uidt: 'SingleSelect', dtxp: "'planned','active','paused','completed'" },
|
||||||
|
{ title: 'campaign_id', uidt: 'Number' },
|
||||||
|
],
|
||||||
|
CampaignAssignments: [
|
||||||
|
{ title: 'assigned_at', uidt: 'DateTime' },
|
||||||
|
{ title: 'campaign_id', uidt: 'Number' },
|
||||||
|
{ title: 'member_id', uidt: 'Number' },
|
||||||
|
{ title: 'assigner_id', uidt: 'Number' },
|
||||||
|
],
|
||||||
|
Projects: [
|
||||||
|
{ title: 'name', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'description', uidt: 'LongText' },
|
||||||
|
{ title: 'status', uidt: 'SingleSelect', dtxp: "'active','paused','completed','cancelled'" },
|
||||||
|
{ title: 'priority', uidt: 'SingleSelect', dtxp: "'low','medium','high','urgent'" },
|
||||||
|
{ title: 'start_date', uidt: 'Date' },
|
||||||
|
{ title: 'due_date', uidt: 'Date' },
|
||||||
|
{ title: 'brand_id', uidt: 'Number' },
|
||||||
|
{ title: 'owner_id', uidt: 'Number' },
|
||||||
|
{ title: 'created_by_user_id', uidt: 'Number' },
|
||||||
|
],
|
||||||
|
Tasks: [
|
||||||
|
{ title: 'title', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'description', uidt: 'LongText' },
|
||||||
|
{ title: 'status', uidt: 'SingleSelect', dtxp: "'todo','in_progress','done'" },
|
||||||
|
{ title: 'priority', uidt: 'SingleSelect', dtxp: "'low','medium','high','urgent'" },
|
||||||
|
{ title: 'start_date', uidt: 'Date' },
|
||||||
|
{ title: 'due_date', uidt: 'Date' },
|
||||||
|
{ title: 'is_personal', uidt: 'Checkbox' },
|
||||||
|
{ title: 'completed_at', uidt: 'DateTime' },
|
||||||
|
{ title: 'project_id', uidt: 'Number' },
|
||||||
|
{ title: 'assigned_to_id', uidt: 'Number' },
|
||||||
|
{ title: 'created_by_user_id', uidt: 'Number' },
|
||||||
|
],
|
||||||
|
Posts: [
|
||||||
|
{ title: 'title', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'description', uidt: 'LongText' },
|
||||||
|
{ title: 'status', uidt: 'SingleSelect', dtxp: "'draft','in_review','approved','scheduled','published','rejected'" },
|
||||||
|
{ title: 'platform', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'platforms', uidt: 'LongText' },
|
||||||
|
{ title: 'content_type', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'scheduled_date', uidt: 'DateTime' },
|
||||||
|
{ title: 'published_date', uidt: 'DateTime' },
|
||||||
|
{ title: 'notes', uidt: 'LongText' },
|
||||||
|
{ title: 'publication_links', uidt: 'LongText' },
|
||||||
|
{ title: 'brand_id', uidt: 'Number' },
|
||||||
|
{ title: 'assigned_to_id', uidt: 'Number' },
|
||||||
|
{ title: 'campaign_id', uidt: 'Number' },
|
||||||
|
{ title: 'track_id', uidt: 'Number' },
|
||||||
|
{ title: 'created_by_user_id', uidt: 'Number' },
|
||||||
|
],
|
||||||
|
Assets: [
|
||||||
|
{ title: 'filename', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'original_name', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'mime_type', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'size', uidt: 'Number' },
|
||||||
|
{ title: 'tags', uidt: 'LongText' },
|
||||||
|
{ title: 'folder', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'brand_id', uidt: 'Number' },
|
||||||
|
{ title: 'campaign_id', uidt: 'Number' },
|
||||||
|
{ title: 'uploader_id', uidt: 'Number' },
|
||||||
|
],
|
||||||
|
PostAttachments: [
|
||||||
|
{ title: 'filename', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'original_name', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'mime_type', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'size', uidt: 'Number' },
|
||||||
|
{ title: 'url', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'post_id', uidt: 'Number' },
|
||||||
|
],
|
||||||
|
Comments: [
|
||||||
|
{ title: 'entity_type', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'entity_id', uidt: 'Number' },
|
||||||
|
{ title: 'content', uidt: 'LongText' },
|
||||||
|
{ title: 'user_id', uidt: 'Number' },
|
||||||
|
],
|
||||||
|
BudgetEntries: [
|
||||||
|
{ title: 'label', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'amount', uidt: 'Decimal' },
|
||||||
|
{ title: 'source', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'category', uidt: 'SingleLineText' },
|
||||||
|
{ title: 'date_received', uidt: 'Date' },
|
||||||
|
{ title: 'notes', uidt: 'LongText' },
|
||||||
|
{ title: 'campaign_id', uidt: 'Number' },
|
||||||
|
],
|
||||||
TaskAttachments: [
|
TaskAttachments: [
|
||||||
{ title: 'filename', uidt: 'SingleLineText' },
|
{ title: 'filename', uidt: 'SingleLineText' },
|
||||||
{ title: 'original_name', uidt: 'SingleLineText' },
|
{ title: 'original_name', uidt: 'SingleLineText' },
|
||||||
|
|||||||
Reference in New Issue
Block a user