Hi! We're building a multi-tenant SaaS where each organization gets their own Neon project. When provisioning a new org, we need to replicate the structure from a "template" project.
What we need to copy:
- All branches (production, staging, preview, etc.)
- The schema (tables, indexes, extensions, etc.)
- The drizzle.drizzle_migrations table contents (so Drizzle ORM knows which migrations have been applied)
What we DON'T need:
- Any data from the public schema tables (they start empty)
Current approach (feels overly complex):
- Create new project with production branch
For each branch in template project:
1. Create branch with endpoints: [{ type: "read_write" }]
2. Use getProjectBranchSchema API to fetch schema SQL
3. Strip privilege statements via regex (fragile!)
4. Execute schema SQL on new branch
5. Manually query drizzle.drizzle_migrations from source and insert into destination
Questions:
- Is there a simpler way to "clone" or "fork" a project structure without data?
- Would init_source: "schema-only" on branch creation help here? Does it copy the drizzle schema too or just public?
- Any way to create a project from a template/snapshot that includes schema but excludes data?
- Alternatively - if we copy WITH data, is there an efficient way to truncate all tables in public schema afterward?
We're using the @neondatabase/api-client TypeScript SDK. Any guidance on the recommended pattern for this use case would be great!