Skip to main content

Database Migrations

Apply migrations remotely:

npx wrangler d1 migrations apply chyperai_db --remote

Verify tables:

npx wrangler d1 execute chyperai_db --remote --command "SELECT name FROM sqlite_master WHERE type='table';"

Seed data:

-- db/migrations/0003_seed.sql
INSERT INTO tenants (id, name, slug) VALUES ('t_default', 'Default Tenant', 'default');
INSERT INTO projects (...)

Common issues:

  • UNIQUE constraint via ALTER TABLE is not supported; use a UNIQUE INDEX.
  • Ensure wrangler.toml binds DB and DO correctly for Pages.