Documentation

    Documentation

    Documentation

    Ring Platform Logo

    Завантаження документації...

    Підготовка контенту платформи Ring

    Ring Platform Logo

    Завантаження документації...

    Підготовка контенту платформи Ring

    Ring Platform Logo

    Завантаження документації...

    Підготовка контенту платформи Ring

    1. /
    2. /Database migrations

    Updated Jun 10, 20262 min listen

    1. /
    2. /Database migrations

    Updated Jun 10, 20262 min listen

    1. /
    2. /Database migrations

    Updated Jun 10, 20262 min listen

    Concepts, value, and typical clone scenarios — less code.

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Architecture
    Data Model
    Real Time
    Discovery Mutation Sync
    Security
    Backend Services
    k8s-postgres-fcm Mode
    Firebase Integration
    Features
    Authentication
    Email AI-CRM
    Entities
    Opportunities
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Tunnel Protocol
    Wallet & Credit System
    Multi-Vendor Store
    Referral Codes (Refcodes)
    Affiliate & Referral Enablement
    Payments Overview
    PaymentConductor
    SubscriptionConductor
    VideoConductor
    News Module - Digital Newspaper Experience
    Member Blogs
    Public Profile Pages
    Username Reservation System
    Scientific Editor
    Locale System
    Security & Compliance
    NFT Marketplace
    Token Staking System
    Performance Optimization Patterns
    Mobile Experience
    Wallet
    Wallet Security Tips
    API
    Authentication
    Email AI-CRM API
    Entities
    Opportunities
    Messaging API
    Notifications API
    Wallet API
    Store API
    Admin API
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Branding
    Themes
    Web3
    Token launch jurisdictions
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Development
    Local Setup
    Code Structure
    Documentation components
    Community tooling
    Ring MCP Server
    Generative Images (ImageConductor)
    Autonomous Newsroom (Grok)
    OSS vs enterprise
    Whitelabel Navigation
    Best Practices
    Workflow
    Code Style
    Performance
    Testing
    Deployment
    Debugging
    Contributing
    MCP
    ring-image-create
    ring-video-create
    Examples
    Quick Start
    White Label
    Real World
    Integrations
    Ethereum wallets (Wagmi v3)

    Quick entry (CTOs · auditors · agents)

    Welcome — mission & audiences
    Quick Reference
    Getting started
    Architecture & Auth.js
    Backend modes & databases (DB_BACKEND_MODE)
    Self-hosted
    Ring MCP Tools
    Ring MCP Server
    Token economics
    Token launch jurisdictions
    Deploy (Docker · k8s)
    Security & compliance reads
    ringdom.org — LegioX homebase
    Source — MIT license (GitHub)

    Concepts, value, and typical clone scenarios — less code.

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Architecture
    Data Model
    Real Time
    Discovery Mutation Sync
    Security
    Backend Services
    k8s-postgres-fcm Mode
    Firebase Integration
    Features
    Authentication
    Email AI-CRM
    Entities
    Opportunities
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Tunnel Protocol
    Wallet & Credit System
    Multi-Vendor Store
    Referral Codes (Refcodes)
    Affiliate & Referral Enablement
    Payments Overview
    PaymentConductor
    SubscriptionConductor
    VideoConductor
    News Module - Digital Newspaper Experience
    Member Blogs
    Public Profile Pages
    Username Reservation System
    Scientific Editor
    Locale System
    Security & Compliance
    NFT Marketplace
    Token Staking System
    Performance Optimization Patterns
    Mobile Experience
    Wallet
    Wallet Security Tips
    API
    Authentication
    Email AI-CRM API
    Entities
    Opportunities
    Messaging API
    Notifications API
    Wallet API
    Store API
    Admin API
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Branding
    Themes
    Web3
    Token launch jurisdictions
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Development
    Local Setup
    Code Structure
    Documentation components
    Community tooling
    Ring MCP Server
    Generative Images (ImageConductor)
    Autonomous Newsroom (Grok)
    OSS vs enterprise
    Whitelabel Navigation
    Best Practices
    Workflow
    Code Style
    Performance
    Testing
    Deployment
    Debugging
    Contributing
    MCP
    ring-image-create
    ring-video-create
    Examples
    Quick Start
    White Label
    Real World
    Integrations
    Ethereum wallets (Wagmi v3)

    Quick entry (CTOs · auditors · agents)

    Welcome — mission & audiences
    Quick Reference
    Getting started
    Architecture & Auth.js
    Backend modes & databases (DB_BACKEND_MODE)
    Self-hosted
    Ring MCP Tools
    Ring MCP Server
    Token economics
    Token launch jurisdictions
    Deploy (Docker · k8s)
    Security & compliance reads
    ringdom.org — LegioX homebase
    Source — MIT license (GitHub)

    Concepts, value, and typical clone scenarios — less code.

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Architecture
    Data Model
    Real Time
    Discovery Mutation Sync
    Security
    Backend Services
    k8s-postgres-fcm Mode
    Firebase Integration
    Features
    Authentication
    Email AI-CRM
    Entities
    Opportunities
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Tunnel Protocol
    Wallet & Credit System
    Multi-Vendor Store
    Referral Codes (Refcodes)
    Affiliate & Referral Enablement
    Payments Overview
    PaymentConductor
    SubscriptionConductor
    VideoConductor
    News Module - Digital Newspaper Experience
    Member Blogs
    Public Profile Pages
    Username Reservation System
    Scientific Editor
    Locale System
    Security & Compliance
    NFT Marketplace
    Token Staking System
    Performance Optimization Patterns
    Mobile Experience
    Wallet
    Wallet Security Tips
    API
    Authentication
    Email AI-CRM API
    Entities
    Opportunities
    Messaging API
    Notifications API
    Wallet API
    Store API
    Admin API
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Branding
    Themes
    Web3
    Token launch jurisdictions
    Deployment
    Self-hosted deployment
    Vercel
    Docker
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Development
    Local Setup
    Code Structure
    Documentation components
    Community tooling
    Ring MCP Server
    Generative Images (ImageConductor)
    Autonomous Newsroom (Grok)
    OSS vs enterprise
    Whitelabel Navigation
    Best Practices
    Workflow
    Code Style
    Performance
    Testing
    Deployment
    Debugging
    Contributing
    MCP
    ring-image-create
    ring-video-create
    Examples
    Quick Start
    White Label
    Real World
    Integrations
    Ethereum wallets (Wagmi v3)

    Quick entry (CTOs · auditors · agents)

    Welcome — mission & audiences
    Quick Reference
    Getting started
    Architecture & Auth.js
    Backend modes & databases (DB_BACKEND_MODE)
    Self-hosted
    Ring MCP Tools
    Ring MCP Server
    Token economics
    Token launch jurisdictions
    Deploy (Docker · k8s)
    Security & compliance reads
    ringdom.org — LegioX homebase
    Source — MIT license (GitHub)
    Docs
    Getting Started
    Docs
    Getting Started
    Docs
    Getting Started

    Database migrations

    Ring Platform requires PostgreSQL when using DB_BACKEND_MODE=k8s-postgres-fcm or supabase-fcm.

    Prerequisites

    • PostgreSQL 14+ (18 recommended for local dev) with optional PostGIS
    • DATABASE_URL or DB_* connection vars in .env.local

    Quick start — Homebrew (all Ring clones)

    From the Ringdom monorepo root:

    bash
    
    brew install postgresql@18 postgis
    brew services start postgresql@18
    ./infrastructure/postgres/bootstrap-brew-dev.sh --compare-prod

    Manifest: infrastructure/postgres/DEV-DATABASE-MANIFEST.json
    Cross-clone matrix: infrastructure/postgres/MIGRATION-KINGDOM-MATRIX.md

    Apply order — ring-platform.org (ring_platform)

    data/schema.sql is v4.0.1+ and already includes settlements, refcodes, generated images, platform settings, telegram audit, and store inventory (inventory_levels, inventory_reservations). Fresh installs need fewer incremental files.

    bash
    
    # 1. Base schema (v4.0.1+ — includes inventory, refcodes, platform_settings, …)
    psql "$DATABASE_URL" -f data/schema.sql
    
    # 2. Ringdom core (copied to every Ring clone)
    psql "$DATABASE_URL" -f data/migrations/002_news_content_schema.sql
    psql "$DATABASE_URL" -f data/migrations/003_news_kingdom_upgrade.sql
    psql "$DATABASE_URL" -f data/migrations/004_payment_transactions.sql
    
    # 3. Incremental only if schema predates merge (idempotent)
    psql "$DATABASE_URL" -f data/migrations/005_refcodes_schema.sql
    psql "$DATABASE_URL" -f data/migrations/006_generated_images_schema.sql
    psql "$DATABASE_URL" -f data/migrations/007_settlements_schema.sql
    psql "$DATABASE_URL" -f data/migrations/008_inventory_schema.sql   # noop when already in schema.sql
    psql "$DATABASE_URL" -f data/migrations/011_platform_settings.sql
    
    # 4. Email AI-CRM (JSONB — skip deprecated 001 column schema)
    psql "$DATABASE_URL" -f data/migrations/009_email_crm_jsonb.sql
    psql "$DATABASE_URL" -f data/migrations/010_email_crm_tasks_jsonb.sql

    Helper scripts: ./scripts/run-migration.sh, ./scripts/apply-refcodes-migrations-dev.sh, ./scripts/apply-platform-settings-migrations-dev.sh.

    Do not apply 001_email_crm_schema.sql

    001_email_crm_schema.sql is obsolete (column-model tables + invalid global_users FK). Use 009 + 010 JSONB migrations. On ring-ringdom-org the file lives under data/migrations/_deprecated/.

    Migration reference

    FileTables / purposeIn schema.sql v4.0.1+?
    002_news_content_schema.sqlnews, news_categories, news_likesPartial — run for kingdom indexes/seeds
    003_news_kingdom_upgrade.sqlKingdom fields, news_submission_auditPartial
    004_payment_transactions.sqlPaymentConductor ledgerPartial
    005_refcodes_schema.sqlrefcodes, referral_rewardsYes
    006_generated_images_schema.sqlgenerated_imagesYes
    007_settlements_schema.sqlERP settlement pipelineYes
    008_inventory_schema.sqlinventory_levels, inventory_reservationsYes (merged 2026-06-10)
    009 / 010Email CRM JSONBNo — opt-in feature
    011_platform_settings.sql

    Ring clone databases (unified baseline)

    Every Ring-backend clone uses ring-platform.org/data/schema.sql first (53 app tables), then optional data/schema-delta.sql for project-only tables. Bootstrap: ./infrastructure/postgres/bootstrap-brew-dev.sh (add --fresh if a legacy v3 schema left column-model tables that block JSONB apply).

    CloneDatabase (dev)Total tablesBeyond platform
    ring-platform.orgring_platform54—
    ring-greenfood-live, ring-vikka-ua, ring-ring-ck-uaper manifest54—
    ring-zemna-airing_zemna_ai56publications, publication_versions
    ring-ringdom-orgring_ringdom_org56global_users, settler_briefs
    ring-subiworx-comring_subiworx_com58shop marketplace tables
    ring-connect-software

    Do not bootstrap from per-clone forked data/schema.sql (obsolete v3 ~25-table snapshots). See infrastructure/postgres/MIGRATION-KINGDOM-MATRIX.md.

    See ring-ringdom-org/data/README.md for global_users and settler registry (Ringdom-only).

    Optional seeds

    Verify

    Dev database: ring_platform on local Homebrew Postgres (ring_user / see manifest).

    Related

    • Installation
    • Local setup
    • Backend modes
    • Referral Codes
    • Email AI-CRM
    • ERP inventory
    • data/migrations/README.md

    Database migrations

    Ring Platform requires PostgreSQL when using DB_BACKEND_MODE=k8s-postgres-fcm or supabase-fcm.

    Prerequisites

    • PostgreSQL 14+ (18 recommended for local dev) with optional PostGIS
    • DATABASE_URL or DB_* connection vars in .env.local

    Quick start — Homebrew (all Ring clones)

    From the Ringdom monorepo root:

    bash
    
    brew install postgresql@18 postgis
    brew services start postgresql@18
    ./infrastructure/postgres/bootstrap-brew-dev.sh --compare-prod

    Manifest: infrastructure/postgres/DEV-DATABASE-MANIFEST.json
    Cross-clone matrix: infrastructure/postgres/MIGRATION-KINGDOM-MATRIX.md

    Apply order — ring-platform.org (ring_platform)

    data/schema.sql is v4.0.1+ and already includes settlements, refcodes, generated images, platform settings, telegram audit, and store inventory (inventory_levels, inventory_reservations). Fresh installs need fewer incremental files.

    bash
    
    # 1. Base schema (v4.0.1+ — includes inventory, refcodes, platform_settings, …)
    psql "$DATABASE_URL" -f data/schema.sql
    
    # 2. Ringdom core (copied to every Ring clone)
    psql "$DATABASE_URL" -f data/migrations/002_news_content_schema.sql
    psql "$DATABASE_URL" -f data/migrations/003_news_kingdom_upgrade.sql
    psql "$DATABASE_URL" -f data/migrations/004_payment_transactions.sql
    
    # 3. Incremental only if schema predates merge (idempotent)
    psql "$DATABASE_URL" -f data/migrations/005_refcodes_schema.sql
    psql "$DATABASE_URL" -f data/migrations/006_generated_images_schema.sql
    psql "$DATABASE_URL" -f data/migrations/007_settlements_schema.sql
    psql "$DATABASE_URL" -f data/migrations/008_inventory_schema.sql   # noop when already in schema.sql
    psql "$DATABASE_URL" -f data/migrations/011_platform_settings.sql
    
    # 4. Email AI-CRM (JSONB — skip deprecated 001 column schema)
    psql "$DATABASE_URL" -f data/migrations/009_email_crm_jsonb.sql
    psql "$DATABASE_URL" -f data/migrations/010_email_crm_tasks_jsonb.sql

    Helper scripts: ./scripts/run-migration.sh, ./scripts/apply-refcodes-migrations-dev.sh, ./scripts/apply-platform-settings-migrations-dev.sh.

    Do not apply 001_email_crm_schema.sql

    001_email_crm_schema.sql is obsolete (column-model tables + invalid global_users FK). Use 009 + 010 JSONB migrations. On ring-ringdom-org the file lives under data/migrations/_deprecated/.

    Migration reference

    FileTables / purposeIn schema.sql v4.0.1+?
    002_news_content_schema.sqlnews, news_categories, news_likesPartial — run for kingdom indexes/seeds
    003_news_kingdom_upgrade.sqlKingdom fields, news_submission_auditPartial
    004_payment_transactions.sqlPaymentConductor ledgerPartial
    005_refcodes_schema.sqlrefcodes, referral_rewardsYes
    006_generated_images_schema.sqlgenerated_imagesYes
    007_settlements_schema.sqlERP settlement pipelineYes
    008_inventory_schema.sqlinventory_levels, inventory_reservationsYes (merged 2026-06-10)
    009 / 010Email CRM JSONBNo — opt-in feature
    011_platform_settings.sql

    Ring clone databases (unified baseline)

    Every Ring-backend clone uses ring-platform.org/data/schema.sql first (53 app tables), then optional data/schema-delta.sql for project-only tables. Bootstrap: ./infrastructure/postgres/bootstrap-brew-dev.sh (add --fresh if a legacy v3 schema left column-model tables that block JSONB apply).

    CloneDatabase (dev)Total tablesBeyond platform
    ring-platform.orgring_platform54—
    ring-greenfood-live, ring-vikka-ua, ring-ring-ck-uaper manifest54—
    ring-zemna-airing_zemna_ai56publications, publication_versions
    ring-ringdom-orgring_ringdom_org56global_users, settler_briefs
    ring-subiworx-comring_subiworx_com58shop marketplace tables
    ring-connect-software

    Do not bootstrap from per-clone forked data/schema.sql (obsolete v3 ~25-table snapshots). See infrastructure/postgres/MIGRATION-KINGDOM-MATRIX.md.

    See ring-ringdom-org/data/README.md for global_users and settler registry (Ringdom-only).

    Optional seeds

    Verify

    Dev database: ring_platform on local Homebrew Postgres (ring_user / see manifest).

    Related

    • Installation
    • Local setup
    • Backend modes
    • Referral Codes
    • Email AI-CRM
    • ERP inventory
    • data/migrations/README.md

    Database migrations

    Ring Platform requires PostgreSQL when using DB_BACKEND_MODE=k8s-postgres-fcm or supabase-fcm.

    Prerequisites

    • PostgreSQL 14+ (18 recommended for local dev) with optional PostGIS
    • DATABASE_URL or DB_* connection vars in .env.local

    Quick start — Homebrew (all Ring clones)

    From the Ringdom monorepo root:

    bash
    
    brew install postgresql@18 postgis
    brew services start postgresql@18
    ./infrastructure/postgres/bootstrap-brew-dev.sh --compare-prod

    Manifest: infrastructure/postgres/DEV-DATABASE-MANIFEST.json
    Cross-clone matrix: infrastructure/postgres/MIGRATION-KINGDOM-MATRIX.md

    Apply order — ring-platform.org (ring_platform)

    data/schema.sql is v4.0.1+ and already includes settlements, refcodes, generated images, platform settings, telegram audit, and store inventory (inventory_levels, inventory_reservations). Fresh installs need fewer incremental files.

    bash
    
    # 1. Base schema (v4.0.1+ — includes inventory, refcodes, platform_settings, …)
    psql "$DATABASE_URL" -f data/schema.sql
    
    # 2. Ringdom core (copied to every Ring clone)
    psql "$DATABASE_URL" -f data/migrations/002_news_content_schema.sql
    psql "$DATABASE_URL" -f data/migrations/003_news_kingdom_upgrade.sql
    psql "$DATABASE_URL" -f data/migrations/004_payment_transactions.sql
    
    # 3. Incremental only if schema predates merge (idempotent)
    psql "$DATABASE_URL" -f data/migrations/005_refcodes_schema.sql
    psql "$DATABASE_URL" -f data/migrations/006_generated_images_schema.sql
    psql "$DATABASE_URL" -f data/migrations/007_settlements_schema.sql
    psql "$DATABASE_URL" -f data/migrations/008_inventory_schema.sql   # noop when already in schema.sql
    psql "$DATABASE_URL" -f data/migrations/011_platform_settings.sql
    
    # 4. Email AI-CRM (JSONB — skip deprecated 001 column schema)
    psql "$DATABASE_URL" -f data/migrations/009_email_crm_jsonb.sql
    psql "$DATABASE_URL" -f data/migrations/010_email_crm_tasks_jsonb.sql

    Helper scripts: ./scripts/run-migration.sh, ./scripts/apply-refcodes-migrations-dev.sh, ./scripts/apply-platform-settings-migrations-dev.sh.

    Do not apply 001_email_crm_schema.sql

    001_email_crm_schema.sql is obsolete (column-model tables + invalid global_users FK). Use 009 + 010 JSONB migrations. On ring-ringdom-org the file lives under data/migrations/_deprecated/.

    Migration reference

    FileTables / purposeIn schema.sql v4.0.1+?
    002_news_content_schema.sqlnews, news_categories, news_likesPartial — run for kingdom indexes/seeds
    003_news_kingdom_upgrade.sqlKingdom fields, news_submission_auditPartial
    004_payment_transactions.sqlPaymentConductor ledgerPartial
    005_refcodes_schema.sqlrefcodes, referral_rewardsYes
    006_generated_images_schema.sqlgenerated_imagesYes
    007_settlements_schema.sqlERP settlement pipelineYes
    008_inventory_schema.sqlinventory_levels, inventory_reservationsYes (merged 2026-06-10)
    009 / 010Email CRM JSONBNo — opt-in feature
    011_platform_settings.sql

    Ring clone databases (unified baseline)

    Every Ring-backend clone uses ring-platform.org/data/schema.sql first (53 app tables), then optional data/schema-delta.sql for project-only tables. Bootstrap: ./infrastructure/postgres/bootstrap-brew-dev.sh (add --fresh if a legacy v3 schema left column-model tables that block JSONB apply).

    CloneDatabase (dev)Total tablesBeyond platform
    ring-platform.orgring_platform54—
    ring-greenfood-live, ring-vikka-ua, ring-ring-ck-uaper manifest54—
    ring-zemna-airing_zemna_ai56publications, publication_versions
    ring-ringdom-orgring_ringdom_org56global_users, settler_briefs
    ring-subiworx-comring_subiworx_com58shop marketplace tables
    ring-connect-software

    Do not bootstrap from per-clone forked data/schema.sql (obsolete v3 ~25-table snapshots). See infrastructure/postgres/MIGRATION-KINGDOM-MATRIX.md.

    See ring-ringdom-org/data/README.md for global_users and settler registry (Ringdom-only).

    Optional seeds

    Verify

    Dev database: ring_platform on local Homebrew Postgres (ring_user / see manifest).

    Related

    • Installation
    • Local setup
    • Backend modes
    • Referral Codes
    • Email AI-CRM
    • ERP inventory
    • data/migrations/README.md
    platform_settings
    Yes — runtime reads/writes via db().*Doc in platform-settings-service.ts and ring-token-oracle.ts (not raw SQL in feature modules)
    ring_connect_software_dev
    70
    PR Ops + cross-project user analytics
    bash
    
    psql "$DATABASE_URL" -f scripts/seed-news-v1.6.0.sql
    bash
    
    psql "$DATABASE_URL" -c "\dt news*"
    psql "$DATABASE_URL" -c "\dt payment_transactions"
    psql "$DATABASE_URL" -c "\dt inventory_*"
    psql "$DATABASE_URL" -c "\dt ref*"
    psql "$DATABASE_URL" -c "\dt email_*"
    psql "$DATABASE_URL" -c "\dt platform_settings"
    platform_settings
    Yes — runtime reads/writes via db().*Doc in platform-settings-service.ts and ring-token-oracle.ts (not raw SQL in feature modules)
    ring_connect_software_dev
    70
    PR Ops + cross-project user analytics
    bash
    
    psql "$DATABASE_URL" -f scripts/seed-news-v1.6.0.sql
    bash
    
    psql "$DATABASE_URL" -c "\dt news*"
    psql "$DATABASE_URL" -c "\dt payment_transactions"
    psql "$DATABASE_URL" -c "\dt inventory_*"
    psql "$DATABASE_URL" -c "\dt ref*"
    psql "$DATABASE_URL" -c "\dt email_*"
    psql "$DATABASE_URL" -c "\dt platform_settings"
    platform_settings
    Yes — runtime reads/writes via db().*Doc in platform-settings-service.ts and ring-token-oracle.ts (not raw SQL in feature modules)
    ring_connect_software_dev
    70
    PR Ops + cross-project user analytics
    bash
    
    psql "$DATABASE_URL" -f scripts/seed-news-v1.6.0.sql
    bash
    
    psql "$DATABASE_URL" -c "\dt news*"
    psql "$DATABASE_URL" -c "\dt payment_transactions"
    psql "$DATABASE_URL" -c "\dt inventory_*"
    psql "$DATABASE_URL" -c "\dt ref*"
    psql "$DATABASE_URL" -c "\dt email_*"
    psql "$DATABASE_URL" -c "\dt platform_settings"