Skip to content

Conversation

@yashx007
Copy link

@yashx007 yashx007 commented Oct 2, 2025

Summary

This PR implements a complete “run locally” developer flow for the auth service and makes the local migration runner idempotent and resilient.

Key outcomes:

  • Adds a migrate:development script that safely runs local D1 migrations and verifies their effects.
  • Adds local index application support for D1.
  • Updates documentation with an easy quick-path for Windows (PowerShell/WSL) plus the recommended Nix path.
  • Makes the migration runner verify skipped migrations actually created their target tables and re-applies any migration that left the DB missing expected schema.

This addresses issue #4290 by providing clear, repeatable steps for running the service locally and a safer migration runner for developer machines.

Changes

migrate-development.js

  • New/updated runner:
    • Lists migration files and queries already-applied migrations via wrangler d1 migrations list.
    • Logs [SKIPPED], [APPLYING], [APPLIED] for visibility.
    • Verifies skipped migrations actually created the target tables; re-applies if needed.
    • Runs the indexes applier as a final step in local mode.
    • Ensures wrangler commands are executed from the project root.

apply-indexes.js

  • Added --local support to execute index creation against the local D1 preview DB.

package.json

  • Added script: "migrate:development": "node ./scripts/migrate-development.js"
  • Dev script remains: wrangler dev --port 3333.

README.md / DEVELOP.md (auth.pollinations.ai)

  • Added a short, practical “Run locally” quick-path for Windows (PowerShell + WSL) and recommended nix develop instructions.
  • Documented .dev.vars usage and the need to provide real secrets (GITHUB_CLIENT_ID/SECRET, JWT_SECRET, etc.).

Verification (what I ran locally)

  1. Install dependencies

    npm install
    
    
  2. Run idempotent migrations

    npm run migrate:development
    • Listed migrations
    • Skipped already-applied files ([SKIPPED])
    • Verified skipped files created tables; re-applied missing ones
    • Applied local indexes via apply-indexes.js --local
  3. Confirm D1 tables exist

    npx wrangler d1 execute github_auth --local --command "SELECT name FROM sqlite_master WHERE type='table';"
    • Verified expected tables exist (users, domains, oauth_state, etc.)
  4. Start dev server

    npm run dev
    • Verified worker served at http://127.0.0.1:3333
  5. Test /authorize endpoint

    curl -i "http://127.0.0.1:3333/authorize?redirect_uri=http://127.0.0.1:3333/callback"
    • Received HTTP/1.1 302 with correct Location header
  6. Verify oauth_state rows

    • Confirmed entries inserted into local D1 DB.

Notes: Missing-table errors observed early were fixed by re-applying migrations; the runner now automatically handles this.

Known manual steps / developer notes

  • Secrets: Populate .dev.vars with valid credentials:

    GITHUB_CLIENT_ID=your_real_client_id
    GITHUB_CLIENT_SECRET=your_real_client_secret
    JWT_SECRET=<32+ char secret>
    REDIRECT_URI=http://127.0.0.1:3333/callback
    ADMIN_API_KEY=...
    • GitHub OAuth app callback URL must exactly match REDIRECT_URI.
  • Nix: Recommended for repeatable dev; quick PowerShell/WSL path also documented.

  • Wrangler / D1: Runner expects a local D1 preview DB (--local). If port conflicts occur, use wrangler dev --no-open --port 3333.

Closes #4290

…inations#4290)

- Add migrate:development script that verifies skipped migrations and re-applies when needed
- Add support for local index application via apply-indexes.js --local
- Update README / DEVELOP.md with 'run locally' instructions
@github-project-automation github-project-automation bot moved this to To Do in Dev Oct 2, 2025
@netlify
Copy link

netlify bot commented Oct 2, 2025

👷 Deploy request for pollinations pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 1507888

@netlify
Copy link

netlify bot commented Oct 2, 2025

Deploy Preview for pollinations-react-hooks-docs ready!

Name Link
🔨 Latest commit 1507888
🔍 Latest deploy log https://app.netlify.com/projects/pollinations-react-hooks-docs/deploys/68e353fbfdbd4d0008c2aba8
😎 Deploy Preview https://deploy-preview-4297--pollinations-react-hooks-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@yashx007
Copy link
Author

yashx007 commented Oct 2, 2025

Hi!
This PR implements the “run locally” flow for the auth service and adds an idempotent local migration runner, along with updated docs (README.md / DEVELOP.md) and improved logging. All changes have been tested locally.
Would appreciate it if you could review and merge under Hacktoberfest!
Thanks!

@yashx007 yashx007 closed this Oct 3, 2025
@yashx007 yashx007 deleted the docs/dev-local-idempotent-migrations-4290 branch October 3, 2025 06:36
@github-project-automation github-project-automation bot moved this from To Do to Done in Dev Oct 3, 2025
@yashx007 yashx007 restored the docs/dev-local-idempotent-migrations-4290 branch October 3, 2025 06:43
@yashx007 yashx007 deleted the docs/dev-local-idempotent-migrations-4290 branch October 3, 2025 06:46
@yashx007 yashx007 restored the docs/dev-local-idempotent-migrations-4290 branch October 3, 2025 06:46
@yashx007 yashx007 reopened this Oct 3, 2025
@github-project-automation github-project-automation bot moved this from Done to To Do in Dev Oct 3, 2025
@yashx007
Copy link
Author

yashx007 commented Oct 3, 2025

Hi! @Circuit-Overtime
This PR has been reopened to properly pass all checks and ensure GitHub marks it as merged.
All Netlify deploy previews and header/redirect checks have succeeded.
The branch now merges cleanly into master with no conflicts.
Changes include the local run flow, idempotent migration runner, and updated docs.
Ready to merge under Hacktoberfest!

@voodoohop
Copy link
Member

@claude can you review? there seem to be a few empty files

@claude
Copy link
Contributor

claude bot commented Oct 4, 2025

Claude encountered an error —— View job

Failed with exit code 128

I'll analyze this and get back to you.

@yashx007
Copy link
Author

yashx007 commented Oct 4, 2025

@voodoohop
Copy link
Member

hey @yashx007 i didnt quite understand the cleanup PR. it seems to be adding empty files

@voodoohop
Copy link
Member

Screenshot 2025-10-05 at 19 52 19

Can't you just remove the unnecessary files added on this branch?

@yashx007
Copy link
Author

yashx007 commented Oct 5, 2025

@voodoohop sorry for that, u can verify - I have removed the unnecessary files as suggested. Also that cleanup PR was intended to remove a small set of zero-byte / problematic files that were tripping CI and file-parsing (some had non-ASCII trailing characters in their names). That made it look like “empty files were being added,” but the goal was to remove the unused/unsafe ones while preserving anything that could break builds.

@voodoohop
Copy link
Member

Screenshot 2025-10-06 at 00 37 28

still one empty file

@yashx007
Copy link
Author

yashx007 commented Oct 6, 2025

@voodoohop check it i have removed auth.pollinations.ai/GET and added one small line to README.md to force a Netlify rebuild.

@pollinations pollinations deleted a comment from claude bot Oct 8, 2025
@voodoohop
Copy link
Member

@yashx007 sorry for the delay. ive been on holiday. will check it in the next few days

@yashx007
Copy link
Author

@voodoohop no worries, just lemme know if there are any changes required whenever u will review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Do

Development

Successfully merging this pull request may close these issues.

Add README.md with instructions on how to run locally

3 participants