Skip to content

Conversation

@atilafassina
Copy link
Collaborator

@atilafassina atilafassina commented May 22, 2025

This PR adds support to SQL seed scripts


To test it

  1. pull this branch, go to /examples/tanstack-start
  2. observe schema.sql on root of this app, adjust the schema to your needs
  3. run the dev server

Easiest way to confirm the schema and data have been pushed is to claim the newly created DB to your account and check on Neon's Console.

@atilafassina atilafassina self-assigned this May 22, 2025
@atilafassina atilafassina added the enhancement New feature or request label May 22, 2025
@atilafassina atilafassina requested a review from Copilot May 22, 2025 15:44

This comment was marked as outdated.

@atilafassina atilafassina marked this pull request as ready for review June 19, 2025 13:21
@atilafassina atilafassina enabled auto-merge (squash) June 19, 2025 15:38
@atilafassina atilafassina disabled auto-merge June 19, 2025 17:42
@atilafassina atilafassina enabled auto-merge (squash) June 25, 2025 14:24
Copy link
Contributor

@guillaumervls guillaumervls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides comments in the code:

  • it's probably simpler that instantNeon accepts ~ the same argument structure as the vite plugin.
  • less terms/names is better, so I'd go either for "seed" or "onCreate". Probably seed is actually better than "onCreate", so the onCreate would be better named seed.
Copy link
Contributor

@guillaumervls guillaumervls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you removed schema.json, probably those lines can be simplified in the release workflow file https://github.com/neondatabase/neondb-cli/blob/c1bf20c61bd64f35a071f74e95efadca56dd2765/.github/workflows/release.yml#L80-L94

@guillaumervls
Copy link
Contributor

(we're getting there! 🙌 )

@atilafassina atilafassina requested a review from Copilot June 26, 2025 09:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for seeding a SQL script during database initialization. Key changes include:

  • Modifying the InstantNeon API and postgresPlugin to accept a new seed option.
  • Introducing a new CLI flag to specify a SQL file for seeding.
  • Updating documentation, examples, and changelogs accordingly.

Reviewed Changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/vite-plugin-postgres/src/index.ts Updated options to use InstantNeonParams and forward the seed option.
packages/vite-plugin-postgres/README.md Documented the new seed option and provided usage examples.
packages/neondb/src/lib/utils/args.ts Added new CLI flag (sql) for specifying the seed file; updates to help text.
packages/neondb/src/lib/types.ts Added the SqlScript type and updated InstantNeonParams with seed support.
packages/neondb/src/lib/seed-database.ts Introduced a function to execute SQL seed commands after DB creation.
packages/neondb/src/lib/instant-neon.ts Integrated seed support to push the schema if provided.
packages/neondb/src/cli.ts Modified CLI logic to prompt/handle the seed file flag and pass through.
Other files (package.json, examples, changsets) Updated scripts, examples, and changelogs for the new schema seeding feature.
Comments suppressed due to low confidence (1)

packages/neondb/src/lib/utils/args.ts:26

  • The CLI flag for specifying the SQL seed file is defined as 'sql' here, but the documentation and examples reference '--seed'. Consider aligning the flag name across the code and documentation for consistency.
			sql: {
@guillaumervls guillaumervls disabled auto-merge June 26, 2025 10:36
@atilafassina atilafassina merged commit 8ae511e into main Jun 26, 2025
7 checks passed
@atilafassina atilafassina deleted the schema-push branch June 26, 2025 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

3 participants