Skip to content

Database Schema

WeaveAI uses Drizzle ORM for database management. The db:push command synchronizes your database schema with the schema definitions in your application code, creating or updating tables, columns, and relationships as needed.

Before pushing the database schema, ensure you have:

  • A PostgreSQL database set up (see one of the Installation guides first)
  • The DATABASE_URL environment variable configured with your database connection string
  • Node.js v22 or v24 and npm installed on your system
  1. Navigate to Your Project Directory

    Open a terminal and navigate to your WeaveAI root application directory (where the app files are located).

  2. Verify DATABASE_URL

    Ensure your DATABASE_URL environment variable with a value is set in the .env file (create it if it doesn’t exist). This should be a PostgreSQL connection string in the format:

    DATABASE_URL="postgresql://username:password@host:port/database"
  3. Install Drizzle Packages

    If you haven’t already installed the project dependencies, you can install just the Drizzle packages:

    Terminal window
    npm install drizzle-orm drizzle-kit

    Alternatively, install all project dependencies with:

    Terminal window
    npm install
  4. Run the Push Command

    Execute the following command:

    Terminal window
    npm run db:push

    This command will:

    • Connect to your PostgreSQL database using the DATABASE_URL
    • Create or update tables, columns, indexes, and constraints as needed

If the database connection fails:

  1. Verify your database is running and accessible
  2. Check that the credentials in DATABASE_URL are correct
  3. Ensure your database server allows public connections or from your IP address

You should run npm run db:push when:

  • Initial Setup: After deploying WeaveAI for the first time
  • After Updates (not always): When updating WeaveAI to a new version that includes schema changes
  • Development: When making local schema modifications during development