Database Schema
Overview
Section titled “Overview”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.
Prerequisites
Section titled “Prerequisites”Before pushing the database schema, ensure you have:
- A PostgreSQL database set up (see one of the Installation guides first)
- The
DATABASE_URLenvironment variable configured with your database connection string - Node.js v22 or v24 and npm installed on your system
Push Database Schema
Section titled “Push Database Schema”-
Navigate to Your Project Directory
Open a terminal and navigate to your WeaveAI root application directory (where the app files are located).
-
Verify DATABASE_URL
Ensure your
DATABASE_URLenvironment 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" -
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-kitAlternatively, install all project dependencies with:
Terminal window npm install -
Run the Push Command
Execute the following command:
Terminal window npm run db:pushThis command will:
- Connect to your PostgreSQL database using the
DATABASE_URL - Create or update tables, columns, indexes, and constraints as needed
- Connect to your PostgreSQL database using the
Connection Failed
Section titled “Connection Failed”If the database connection fails:
- Verify your database is running and accessible
- Check that the credentials in
DATABASE_URLare correct - Ensure your database server allows public connections or from your IP address
When to Push Schema
Section titled “When to Push Schema”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