OpportunitiesEntities
Docs
    Ring Platform

    Decentralized Self-building Future

    Sign In
    Entities
    Opportunities
    Store
    Docs
    Platform Concepts
    RING EconomySonoratek LLCGlobal ImpactAI Meets Web3
    Get Started
    Quick StartCalculatorRoadmap
    Privacy|Contact
    v1.104.26|Sonoratek LLC

    Documentation

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

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Features
    Multi-Vendor Store
    Inventory & Stock
    Vendor Management
    Commissions & Settlements
    SubscriptionConductor
    PaymentConductor
    Ring Oracle
    Payments Overview
    Public Pools & DAO Jars
    WayForPay Payment Integration
    Wallet & Credit System
    WalletConductor
    Credit Rewards
    Affiliate & Referral Enablement
    Referral Codes (Refcodes)
    NFT Exhibition Marketplace
    Solana NFT Gates
    Token Staking System
    Owner Project Lab
    Entities
    Opportunities
    Real-Time Messaging
    Ring Tasks
    WebRTC Calls & STUNner TURN
    Peer Games
    News Module
    Member Blogs
    Public Profile Pages
    Profile Account Widgets
    Ring File Cabinet
    Username Reservation System
    Scientific Editor
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Email AI-CRM
    Ring Mailer & RingdomX Mail
    Tunnel Protocol
    VideoConductor
    MediaConductor
    Generative Gallery
    Authentication
    Security & Compliance
    Admin console
    Admin Wiki
    Manage via Telegram
    Locale System
    Mobile Experience
    Performance Optimization Patterns
    Examples
    Quick Start
    Basic Setup
    White Label
    Custom Branding
    Web3 Integration
    Real World
    Advanced Features
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Vertical Presets (SSOT)
    Ringization playbook
    Branding
    Themes
    Features
    Localization
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Project configuration
    Public environment variables
    Order Lab secrets
    WalletConnect Project ID (Reown Cloud)
    Supported services
    NODUS wiki (project knowledge)
    Configuration playbook
    Web3
    Token launch jurisdictions
    Wallet
    Wallet Security Tips
    Integrations
    Ethereum wallets (Wagmi v3)
    RingFileBase (object storage API)
    Ring CDN (RingFileBase edge)
    Deployment
    Self-hosted deployment
    Vercel Deployment
    Docker
    Environment Configuration
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Architecture
    Data Model
    Security
    Real Time
    Discovery Mutation Sync
    PaymentConductor architecture
    WalletConductor architecture
    News Kingdom architecture
    Backend Services
    Firebase Integration
    Development
    Ring MCP Server
    OSS vs enterprise

    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)

    Documentation

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

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Features
    Multi-Vendor Store
    Inventory & Stock
    Vendor Management
    Commissions & Settlements
    SubscriptionConductor
    PaymentConductor
    Ring Oracle
    Payments Overview
    Public Pools & DAO Jars
    WayForPay Payment Integration
    Wallet & Credit System
    WalletConductor
    Credit Rewards
    Affiliate & Referral Enablement
    Referral Codes (Refcodes)
    NFT Exhibition Marketplace
    Solana NFT Gates
    Token Staking System
    Owner Project Lab
    Entities
    Opportunities
    Real-Time Messaging
    Ring Tasks
    WebRTC Calls & STUNner TURN
    Peer Games
    News Module
    Member Blogs
    Public Profile Pages
    Profile Account Widgets
    Ring File Cabinet
    Username Reservation System
    Scientific Editor
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Email AI-CRM
    Ring Mailer & RingdomX Mail
    Tunnel Protocol
    VideoConductor
    MediaConductor
    Generative Gallery
    Authentication
    Security & Compliance
    Admin console
    Admin Wiki
    Manage via Telegram
    Locale System
    Mobile Experience
    Performance Optimization Patterns
    Examples
    Quick Start
    Basic Setup
    White Label
    Custom Branding
    Web3 Integration
    Real World
    Advanced Features
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Vertical Presets (SSOT)
    Ringization playbook
    Branding
    Themes
    Features
    Localization
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Project configuration
    Public environment variables
    Order Lab secrets
    WalletConnect Project ID (Reown Cloud)
    Supported services
    NODUS wiki (project knowledge)
    Configuration playbook
    Web3
    Token launch jurisdictions
    Wallet
    Wallet Security Tips
    Integrations
    Ethereum wallets (Wagmi v3)
    RingFileBase (object storage API)
    Ring CDN (RingFileBase edge)
    Deployment
    Self-hosted deployment
    Vercel Deployment
    Docker
    Environment Configuration
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Architecture
    Data Model
    Security
    Real Time
    Discovery Mutation Sync
    PaymentConductor architecture
    WalletConductor architecture
    News Kingdom architecture
    Backend Services
    Firebase Integration
    Development
    Ring MCP Server
    OSS vs enterprise

    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)

    Documentation

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

    Welcome to Ring
    Quick Reference
    Getting Started
    Prerequisites
    Installation
    First Success Validation
    Next Steps
    Features
    Multi-Vendor Store
    Inventory & Stock
    Vendor Management
    Commissions & Settlements
    SubscriptionConductor
    PaymentConductor
    Ring Oracle
    Payments Overview
    Public Pools & DAO Jars
    WayForPay Payment Integration
    Wallet & Credit System
    WalletConductor
    Credit Rewards
    Affiliate & Referral Enablement
    Referral Codes (Refcodes)
    NFT Exhibition Marketplace
    Solana NFT Gates
    Token Staking System
    Owner Project Lab
    Entities
    Opportunities
    Real-Time Messaging
    Ring Tasks
    WebRTC Calls & STUNner TURN
    Peer Games
    News Module
    Member Blogs
    Public Profile Pages
    Profile Account Widgets
    Ring File Cabinet
    Username Reservation System
    Scientific Editor
    Notifications
    Push Notifications with FCM (Ring-Powered)
    Email AI-CRM
    Ring Mailer & RingdomX Mail
    Tunnel Protocol
    VideoConductor
    MediaConductor
    Generative Gallery
    Authentication
    Security & Compliance
    Admin console
    Admin Wiki
    Manage via Telegram
    Locale System
    Mobile Experience
    Performance Optimization Patterns
    Examples
    Quick Start
    Basic Setup
    White Label
    Custom Branding
    Web3 Integration
    Real World
    Advanced Features
    Customization
    Quick Start — Your First Ring Clone
    Customization Guide
    Vertical Presets (SSOT)
    Ringization playbook
    Branding
    Themes
    Features
    Localization
    Token Economics Setup
    Payment Gateway Integration
    Reference Ring deployments
    Project configuration
    Public environment variables
    Order Lab secrets
    WalletConnect Project ID (Reown Cloud)
    Supported services
    NODUS wiki (project knowledge)
    Configuration playbook
    Web3
    Token launch jurisdictions
    Wallet
    Wallet Security Tips
    Integrations
    Ethereum wallets (Wagmi v3)
    RingFileBase (object storage API)
    Ring CDN (RingFileBase edge)
    Deployment
    Self-hosted deployment
    Vercel Deployment
    Docker
    Environment Configuration
    Monitoring & Analytics
    Performance Optimization
    Backup & Recovery
    Architecture
    Data Model
    Security
    Real Time
    Discovery Mutation Sync
    PaymentConductor architecture
    WalletConductor architecture
    News Kingdom architecture
    Backend Services
    Firebase Integration
    Development
    Ring MCP Server
    OSS vs enterprise

    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)
    Ring Logo

    Loading documentation...

    Preparing Ring content

    Ring Logo

    Loading documentation...

    Preparing Ring content

    Ring Logo

    Loading documentation...

    Preparing Ring content

    Database Migrations

    Ring keeps its PostgreSQL schema in two places inside ring/web/data/. schema.sql is the flattened single source of truth for new databases. migrations/ holds the numbered incremental files that brought existing databases to the same shape. This page explains which one to use and when.

    Use the Founder / Developer tabs in the docs sidebar to filter this page. Shared sections apply to both audiences.

    Status: ./install.sh setup-db and npm run db:apply-schema currently fail on public checkouts because they look for paths that moved under web/. Also, schema.sql contains CREATE EXTENSION IF NOT EXISTS postgis;, so a plain psql -f data/schema.sql stops with an error on PostgreSQL images that do not ship PostGIS (for example postgres:16-alpine). Use the commands in Step 2 below.

    Older docs saidCurrent behavior
    Apply schema.sql, then 002, 003, 004 in orderFresh installs apply only web/data/schema.sql (flattened, version 4.1.0)
    Run ./scripts/run-migration.sh or apply-*-migrations-dev.shThose helpers are not in the public tree. Use psql directly
    Install Homebrew postgresql@18 with a bootstrap scriptAny PostgreSQL 16 or newer works. The bootstrap script is Ringdom-internal
    Seed news from scripts/seed-news-v1.6.0.sqlThat file does not exist. Seeds for currencies, countries, store settings and news categories are inside schema.sql
    data/schema-delta.sqlNot used. Deltas live as numbered files in data/migrations/

    What this means for your community

    You do not need to understand SQL to run a Ring clone, but you should know the rule your developer follows: a new database gets one file, an existing database gets only the new files. That rule is what keeps upgrades boring.

    New clone

    One schema file creates every table (109 at version 4.1.0) plus the reference seeds. No replaying of history.

    Upgrading a live clone

    Your developer applies only the numbered files your database has not seen yet, after a backup.

    Choosing a database

    PostgreSQL is the default production backend (k8s-postgres-fcm).

    Typical scenarios

    • Your developer creates an empty database and applies . The site is ready for the first admin login.

    Layout of web/data

    PathPurpose
    data/schema.sqlFlattened SSOT, version 4.1.0. Creates 109 public tables, the uuid-ossp, pgcrypto and postgis extensions, and reference seeds
    data/migrations/NNN_*.sqlIncremental changes, 001 through 051 committed today
    data/migrations/NNN_*.down.sqlOptional rollback, present for 051
    data/migrations/README.mdRules for adding migrations. Read it before writing one
    data/migrations/EMAIL-CRM-OPS.mdOps notes for the email CRM tables

    Every committed numbered migration through 051 is already folded into schema.sql. Do not replay data/migrations/*.sql on an empty database, and never apply 001_email_crm_schema.sql: the JSONB CRM tables from 009 and 010 replaced it and are part of schema.sql.

    The app connects with , , , , and . It does not read . See .

    Related documentation

    Self-hosted deployment

    Next-step: run the app against the database you just created.

    Docker

    Same-workflow: apply the schema to the compose Postgres container.

    Backend modes and databases

    Prerequisite: why k8s-postgres-fcm needs this schema.

    Community tooling

    See-also: install.sh and the npm db scripts, including the ones that fail today.

    1. Docs
    2. /Getting Started
    3. /Database Migrations

    Updated Oct 1, 20265 min listen

    Database Migrations

    Ring keeps its PostgreSQL schema in two places inside ring/web/data/. schema.sql is the flattened single source of truth for new databases. migrations/ holds the numbered incremental files that brought existing databases to the same shape. This page explains which one to use and when.

    Use the Founder / Developer tabs in the docs sidebar to filter this page. Shared sections apply to both audiences.

    Status: ./install.sh setup-db and npm run db:apply-schema currently fail on public checkouts because they look for paths that moved under web/. Also, schema.sql contains CREATE EXTENSION IF NOT EXISTS postgis;, so a plain psql -f data/schema.sql stops with an error on PostgreSQL images that do not ship PostGIS (for example postgres:16-alpine). Use the commands in Step 2 below.

    Older docs saidCurrent behavior
    Apply schema.sql, then 002, 003, 004 in orderFresh installs apply only web/data/schema.sql (flattened, version 4.1.0)
    Run ./scripts/run-migration.sh or apply-*-migrations-dev.shThose helpers are not in the public tree. Use psql directly
    Install Homebrew postgresql@18 with a bootstrap scriptAny PostgreSQL 16 or newer works. The bootstrap script is Ringdom-internal
    Seed news from scripts/seed-news-v1.6.0.sqlThat file does not exist. Seeds for currencies, countries, store settings and news categories are inside schema.sql
    data/schema-delta.sqlNot used. Deltas live as numbered files in data/migrations/

    What this means for your community

    You do not need to understand SQL to run a Ring clone, but you should know the rule your developer follows: a new database gets one file, an existing database gets only the new files. That rule is what keeps upgrades boring.

    New clone

    One schema file creates every table (109 at version 4.1.0) plus the reference seeds. No replaying of history.

    Upgrading a live clone

    Your developer applies only the numbered files your database has not seen yet, after a backup.

    Choosing a database

    PostgreSQL is the default production backend (k8s-postgres-fcm).

    Typical scenarios

    • Your developer creates an empty database and applies . The site is ready for the first admin login.

    Layout of web/data

    PathPurpose
    data/schema.sqlFlattened SSOT, version 4.1.0. Creates 109 public tables, the uuid-ossp, pgcrypto and postgis extensions, and reference seeds
    data/migrations/NNN_*.sqlIncremental changes, 001 through 051 committed today
    data/migrations/NNN_*.down.sqlOptional rollback, present for 051
    data/migrations/README.mdRules for adding migrations. Read it before writing one
    data/migrations/EMAIL-CRM-OPS.mdOps notes for the email CRM tables

    Every committed numbered migration through 051 is already folded into schema.sql. Do not replay data/migrations/*.sql on an empty database, and never apply 001_email_crm_schema.sql: the JSONB CRM tables from 009 and 010 replaced it and are part of schema.sql.

    The app connects with , , , , and . It does not read . See .

    Related documentation

    Self-hosted deployment

    Next-step: run the app against the database you just created.

    Docker

    Same-workflow: apply the schema to the compose Postgres container.

    Backend modes and databases

    Prerequisite: why k8s-postgres-fcm needs this schema.

    Community tooling

    See-also: install.sh and the npm db scripts, including the ones that fail today.

    1. Docs
    2. /Getting Started
    3. /Database Migrations

    Updated Oct 1, 20265 min listen

    Database Migrations

    Ring keeps its PostgreSQL schema in two places inside ring/web/data/. schema.sql is the flattened single source of truth for new databases. migrations/ holds the numbered incremental files that brought existing databases to the same shape. This page explains which one to use and when.

    Use the Founder / Developer tabs in the docs sidebar to filter this page. Shared sections apply to both audiences.

    Status: ./install.sh setup-db and npm run db:apply-schema currently fail on public checkouts because they look for paths that moved under web/. Also, schema.sql contains CREATE EXTENSION IF NOT EXISTS postgis;, so a plain psql -f data/schema.sql stops with an error on PostgreSQL images that do not ship PostGIS (for example postgres:16-alpine). Use the commands in Step 2 below.

    Older docs saidCurrent behavior
    Apply schema.sql, then 002, 003, 004 in orderFresh installs apply only web/data/schema.sql (flattened, version 4.1.0)
    Run ./scripts/run-migration.sh or apply-*-migrations-dev.shThose helpers are not in the public tree. Use psql directly
    Install Homebrew postgresql@18 with a bootstrap scriptAny PostgreSQL 16 or newer works. The bootstrap script is Ringdom-internal
    Seed news from scripts/seed-news-v1.6.0.sqlThat file does not exist. Seeds for currencies, countries, store settings and news categories are inside schema.sql
    data/schema-delta.sqlNot used. Deltas live as numbered files in data/migrations/

    What this means for your community

    You do not need to understand SQL to run a Ring clone, but you should know the rule your developer follows: a new database gets one file, an existing database gets only the new files. That rule is what keeps upgrades boring.

    New clone

    One schema file creates every table (109 at version 4.1.0) plus the reference seeds. No replaying of history.

    Upgrading a live clone

    Your developer applies only the numbered files your database has not seen yet, after a backup.

    Choosing a database

    PostgreSQL is the default production backend (k8s-postgres-fcm).

    Typical scenarios

    • Your developer creates an empty database and applies . The site is ready for the first admin login.

    Layout of web/data

    PathPurpose
    data/schema.sqlFlattened SSOT, version 4.1.0. Creates 109 public tables, the uuid-ossp, pgcrypto and postgis extensions, and reference seeds
    data/migrations/NNN_*.sqlIncremental changes, 001 through 051 committed today
    data/migrations/NNN_*.down.sqlOptional rollback, present for 051
    data/migrations/README.mdRules for adding migrations. Read it before writing one
    data/migrations/EMAIL-CRM-OPS.mdOps notes for the email CRM tables

    Every committed numbered migration through 051 is already folded into schema.sql. Do not replay data/migrations/*.sql on an empty database, and never apply 001_email_crm_schema.sql: the JSONB CRM tables from 009 and 010 replaced it and are part of schema.sql.

    The app connects with , , , , and . It does not read . See .

    Related documentation

    Self-hosted deployment

    Next-step: run the app against the database you just created.

    Docker

    Same-workflow: apply the schema to the compose Postgres container.

    Backend modes and databases

    Prerequisite: why k8s-postgres-fcm needs this schema.

    Community tooling

    See-also: install.sh and the npm db scripts, including the ones that fail today.

    1. Docs
    2. /Getting Started
    3. /Database Migrations

    Updated Oct 1, 20265 min listen

    First launch.
    schema.sql
  1. Platform upgrade. A Ring release adds a migration such as 051_likes_uci_favorites_indexes.sql. Your developer backs up, applies that one file, and redeploys.
  2. Something looks wrong after an upgrade. Migrations 051 and newer can ship a matching .down.sql file so the change can be reverted. Older files do not.
  3. Which schema path applies
    DB_HOST
    DB_PORT
    DB_NAME
    DB_USER
    DB_PASSWORD
    DB_SSL
    DATABASE_URL
    Environment

    Fresh install

    1. 1

      Create an empty database

      Run the next step as a superuser or as the database owner, because schema.sql creates extensions.

    2. 2

      Apply schema.sql

      If your server has PostGIS installed (for example a postgis/postgis image), apply the file as is:

      On plain PostgreSQL, strip the PostGIS line first. No table uses a PostGIS type, so nothing else changes:

    3. 3

      Check the result

      Grant your app role (DB_USER) access to the public schema, then start the app.

    Existing database

    Apply only the files your database has not seen. Some migrations record themselves in schema_versions with an INSERT ... WHERE NOT EXISTS (016 to 025, 037, 043 to 046, 050, 051). The others do not, so check for the tables or indexes they create before applying.

    To roll back a migration that ships a down file, apply 051_likes_uci_favorites_indexes.down.sql the same way. It also deletes its schema_versions row.

    Adding a migration (contributors)

    1. 1

      Write the next numbered file

      Use the next free number after the highest file in data/migrations/. Make it idempotent (IF NOT EXISTS), record it in schema_versions, and add a .down.sql when the change is reversible.

    2. 2

      Re-flatten schema.sql

      This runs ring/scripts/flatten-schema-from-migrations.sh. It needs a local PostgreSQL where your role can create databases (PGHOST and PGUSER default to localhost and ring_user). It recreates a scratch database ring_schema_flatten, backs up schema.sql as schema.sql.bak-pre-flatten-<timestamp>, applies the prior schema plus all migrations except 001, dumps DDL plus the reference seeds, and verifies the result on ring_schema_flatten_verify. The verify step needs PostGIS for the reason above.

    Frequently asked questions

    Impact

    Do I lose data when the schema is re-flattened?

    No. Flattening only rewrites the schema.sql file in the repository. Live databases are never touched by it.

    Migration

    My database was created from an old schema.sql. Which files do I need?

    Compare SELECT version FROM schema_versions with the numbered files, then apply the missing ones in order after a backup. Only some files record a version (see Existing database above), so check for their tables if in doubt. Note that a fresh install from today's schema.sql lists versions up to 045 even though the tables and indexes from 046 to 051 are already present.

    Ops

    Why does CREATE EXTENSION postgis fail?

    Your PostgreSQL build does not include PostGIS. Strip that line as shown in Step 2, or use a PostGIS-enabled image.

    First launch.
    schema.sql
  4. Platform upgrade. A Ring release adds a migration such as 051_likes_uci_favorites_indexes.sql. Your developer backs up, applies that one file, and redeploys.
  5. Something looks wrong after an upgrade. Migrations 051 and newer can ship a matching .down.sql file so the change can be reverted. Older files do not.
  6. Which schema path applies
    DB_HOST
    DB_PORT
    DB_NAME
    DB_USER
    DB_PASSWORD
    DB_SSL
    DATABASE_URL
    Environment

    Fresh install

    1. 1

      Create an empty database

      Run the next step as a superuser or as the database owner, because schema.sql creates extensions.

    2. 2

      Apply schema.sql

      If your server has PostGIS installed (for example a postgis/postgis image), apply the file as is:

      On plain PostgreSQL, strip the PostGIS line first. No table uses a PostGIS type, so nothing else changes:

    3. 3

      Check the result

      Grant your app role (DB_USER) access to the public schema, then start the app.

    Existing database

    Apply only the files your database has not seen. Some migrations record themselves in schema_versions with an INSERT ... WHERE NOT EXISTS (016 to 025, 037, 043 to 046, 050, 051). The others do not, so check for the tables or indexes they create before applying.

    To roll back a migration that ships a down file, apply 051_likes_uci_favorites_indexes.down.sql the same way. It also deletes its schema_versions row.

    Adding a migration (contributors)

    1. 1

      Write the next numbered file

      Use the next free number after the highest file in data/migrations/. Make it idempotent (IF NOT EXISTS), record it in schema_versions, and add a .down.sql when the change is reversible.

    2. 2

      Re-flatten schema.sql

      This runs ring/scripts/flatten-schema-from-migrations.sh. It needs a local PostgreSQL where your role can create databases (PGHOST and PGUSER default to localhost and ring_user). It recreates a scratch database ring_schema_flatten, backs up schema.sql as schema.sql.bak-pre-flatten-<timestamp>, applies the prior schema plus all migrations except 001, dumps DDL plus the reference seeds, and verifies the result on ring_schema_flatten_verify. The verify step needs PostGIS for the reason above.

    Frequently asked questions

    Impact

    Do I lose data when the schema is re-flattened?

    No. Flattening only rewrites the schema.sql file in the repository. Live databases are never touched by it.

    Migration

    My database was created from an old schema.sql. Which files do I need?

    Compare SELECT version FROM schema_versions with the numbered files, then apply the missing ones in order after a backup. Only some files record a version (see Existing database above), so check for their tables if in doubt. Note that a fresh install from today's schema.sql lists versions up to 045 even though the tables and indexes from 046 to 051 are already present.

    Ops

    Why does CREATE EXTENSION postgis fail?

    Your PostgreSQL build does not include PostGIS. Strip that line as shown in Step 2, or use a PostGIS-enabled image.

    First launch.
    schema.sql
  7. Platform upgrade. A Ring release adds a migration such as 051_likes_uci_favorites_indexes.sql. Your developer backs up, applies that one file, and redeploys.
  8. Something looks wrong after an upgrade. Migrations 051 and newer can ship a matching .down.sql file so the change can be reverted. Older files do not.
  9. Which schema path applies
    DB_HOST
    DB_PORT
    DB_NAME
    DB_USER
    DB_PASSWORD
    DB_SSL
    DATABASE_URL
    Environment

    Fresh install

    1. 1

      Create an empty database

      Run the next step as a superuser or as the database owner, because schema.sql creates extensions.

    2. 2

      Apply schema.sql

      If your server has PostGIS installed (for example a postgis/postgis image), apply the file as is:

      On plain PostgreSQL, strip the PostGIS line first. No table uses a PostGIS type, so nothing else changes:

    3. 3

      Check the result

      Grant your app role (DB_USER) access to the public schema, then start the app.

    Existing database

    Apply only the files your database has not seen. Some migrations record themselves in schema_versions with an INSERT ... WHERE NOT EXISTS (016 to 025, 037, 043 to 046, 050, 051). The others do not, so check for the tables or indexes they create before applying.

    To roll back a migration that ships a down file, apply 051_likes_uci_favorites_indexes.down.sql the same way. It also deletes its schema_versions row.

    Adding a migration (contributors)

    1. 1

      Write the next numbered file

      Use the next free number after the highest file in data/migrations/. Make it idempotent (IF NOT EXISTS), record it in schema_versions, and add a .down.sql when the change is reversible.

    2. 2

      Re-flatten schema.sql

      This runs ring/scripts/flatten-schema-from-migrations.sh. It needs a local PostgreSQL where your role can create databases (PGHOST and PGUSER default to localhost and ring_user). It recreates a scratch database ring_schema_flatten, backs up schema.sql as schema.sql.bak-pre-flatten-<timestamp>, applies the prior schema plus all migrations except 001, dumps DDL plus the reference seeds, and verifies the result on ring_schema_flatten_verify. The verify step needs PostGIS for the reason above.

    Frequently asked questions

    Impact

    Do I lose data when the schema is re-flattened?

    No. Flattening only rewrites the schema.sql file in the repository. Live databases are never touched by it.

    Migration

    My database was created from an old schema.sql. Which files do I need?

    Compare SELECT version FROM schema_versions with the numbered files, then apply the missing ones in order after a backup. Only some files record a version (see Existing database above), so check for their tables if in doubt. Note that a fresh install from today's schema.sql lists versions up to 045 even though the tables and indexes from 046 to 051 are already present.

    Ops

    Why does CREATE EXTENSION postgis fail?

    Your PostgreSQL build does not include PostGIS. Strip that line as shown in Step 2, or use a PostGIS-enabled image.