Skip to content

docs: add docs site#90

Open
jwelmac wants to merge 17 commits intomainfrom
feat/create-docs-site
Open

docs: add docs site#90
jwelmac wants to merge 17 commits intomainfrom
feat/create-docs-site

Conversation

@jwelmac
Copy link
Copy Markdown
Member

@jwelmac jwelmac commented Dec 23, 2025

Status

IN DEVELOPMENT

Description

Create docs site

Closes #88

Type of Change

  • 📝 Documentation

Summary by CodeRabbit

  • Documentation

    • Launched a comprehensive docs site and configuration.
    • Added Getting Started, Migration (v3→v4), and index pages.
    • Added environment guides for Core Dart, Flutter, and Serverpod.
    • Documented models, enums, tables, and RPC usage with examples.
  • Chores

    • Updated CLI initialization flow and added an init executable.
    • Introduced migration tooling to detect and generate database migration scripts automatically.

✏️ Tip: You can customize this high-level summary in your review settings.

@docs-page
Copy link
Copy Markdown

docs-page bot commented Dec 23, 2025

To view this pull requests documentation preview, visit the following URL:

docs.page/khuwn-soulutions/supabase_codegen~90

Documentation is deployed and generated using docs.page.

@jwelmac jwelmac self-assigned this Dec 23, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 23, 2025

📝 Walkthrough

Walkthrough

Adds a documentation site (new docs.json and multiple MDX pages) and a migration subsystem plus startup refactor: new lib/migrations/* modules, renamed initialization API (initinitializeConfiguration), updated bin entrypoints to run migration checks, and several import/packaging adjustments.

Changes

Cohort / File(s) Summary
Docs site config
docs.json
New docs.page configuration (metadata, theme, favicon, social/header, anchors, sidebar).
Docs — Landing & Guides
docs/index.mdx, docs/getting-started/index.mdx, docs/getting-started/migration-v3-to-v4.mdx
New landing, quick-start, and migration guide pages.
Docs — Environments
docs/environments/core.mdx, docs/environments/flutter.mdx, docs/environments/serverpod.mdx
New environment-specific integration guides (Core, Flutter, Serverpod) with setup, CLI usage, and init examples.
Docs — Models & Functions
docs/models/tables.mdx, docs/models/enums.mdx, docs/functions/rpc.mdx
New docs for generated tables/rows, enum mappings, and type-safe RPC usage with examples.
Migration subsystem
packages/supabase_codegen/lib/migrations/check_migration.dart, packages/supabase_codegen/lib/migrations/migrations.dart, packages/supabase_codegen/lib/migrations/sql/*.dart
New migration orchestration: checkMigration, getMigration, addCodegenFunctionsMigration, extractPath; SQL helper modules added and re-exported; sqlFunctions aggregator added.
Bin entry changes
packages/supabase_codegen/bin/generate_types.dart, packages/supabase_codegen/bin/init.dart, packages/supabase_codegen_flutter/bin/init.dart, packages/supabase_codegen_serverpod/bin/init.dart
Binaries now import migrations and call checkMigration() or invoke initializeConfiguration(...) instead of the previous init(...).
Initialization API rename
packages/supabase_codegen/lib/init/init.dart
Public initializer renamed from init(...)initializeConfiguration(...); main updated to delegate to new name.
Removed / stripped file
packages/supabase_codegen/bin/add_codegen_functions.dart
Previously contained migration workflow — now stripped to a minimal main that calls checkMigration() (implementation moved to migrations lib).
Import adjustments
packages/supabase_codegen/lib/migrations/sql/get_*.dart
Replaced relative imports with package imports (e.g., package:supabase_codegen/migrations/sql/codegen_sql_function.dart).
SQL aggregation
packages/supabase_codegen/lib/migrations/sql/sql.dart
New aggregator re-exporting SQL modules and exposing sqlFunctions list.
Flutter package metadata
packages/supabase_codegen_flutter/pubspec.yaml
Added init executable entry under executables.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant CLI as CLI main
  participant Init as initializeConfiguration
  participant Migrate as checkMigration
  participant FS as Filesystem
  participant SupabaseCLI as "supabase CLI"
  Note right of CLI: startup sequence triggers migrations
  CLI->>Init: call initializeConfiguration()
  Init->>Migrate: call checkMigration()
  Migrate->>FS: list migrations dir & read SQL helpers
  Migrate->>SupabaseCLI: query DB functions (spawn `supabase` or read)
  SupabaseCLI-->>Migrate: stdout (existing functions)
  Migrate->>Migrate: compute merged migration SQL
  alt migration required
    Migrate->>SupabaseCLI: run `supabase migrations new` (spawn)
    SupabaseCLI-->>Migrate: stdout with created path
    Migrate->>Migrate: extractPath(stdout)
    Migrate->>FS: write computed SQL to migration file
    Migrate->>CLI: log migration created
  else no changes needed
    Migrate->>CLI: log no changes
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • feat: typed rpc functions #82 — Related RPC generation changes (generate_rpcs, RPC templates, exports) that pair with migration and docs additions.
  • feat: use generated rpc #89 — Overlaps schema discovery and migration SQL helpers (get_schema_info / getEnum / getRpc) re-exported by the new migrations/sql module.

Suggested labels

enhancement

Suggested reviewers

  • codescype

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Changes include refactoring of migration system functions (checkMigration, init rename to initializeConfiguration) beyond documentation scope. Move migration-related refactoring (check_migration.dart, init.dart changes, migrations.dart barrel) to a separate pull request focused on code refactoring.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'docs: add docs site' directly and clearly describes the main change - adding documentation site files and configuration.
Linked Issues check ✅ Passed All linked issue requirements are met: RPC documentation is included (docs/functions/rpc.mdx), docs.page is used (docs.json configuration present), and comprehensive documentation site is created.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/create-docs-site

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 649e66d and dfa7364.

📒 Files selected for processing (10)
  • docs.json
  • docs/environments/core.mdx
  • docs/environments/flutter.mdx
  • docs/environments/serverpod.mdx
  • docs/functions/rpc.mdx
  • docs/getting-started/index.mdx
  • docs/getting-started/migration-v3-to-v4.mdx
  • docs/index.mdx
  • docs/models/enums.mdx
  • docs/models/tables.mdx
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/lib/src/generator/generator.dart:6-7
Timestamp: 2025-12-08T19:48:00.427Z
Learning: In packages/supabase_codegen/lib/src/generator/generator.dart, the exports for rpcs/_rpcs.dart and utils/utils.dart are intended for use by other internal projects within the organization, not for external public consumption. Advanced external users who leverage these should read the internal documentation of the methods directly.
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/bin/sql/get_rpc_functions.dart:18-18
Timestamp: 2025-12-05T21:36:42.890Z
Learning: For supabase_codegen RPC function generation: the initial implementation (PR #82) is intentionally scoped to discover RPC functions only in the 'public' schema. Multi-schema support is planned for a subsequent PR.
📚 Learning: 2025-12-08T19:48:00.427Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/lib/src/generator/generator.dart:6-7
Timestamp: 2025-12-08T19:48:00.427Z
Learning: In packages/supabase_codegen/lib/src/generator/generator.dart, the exports for rpcs/_rpcs.dart and utils/utils.dart are intended for use by other internal projects within the organization, not for external public consumption. Advanced external users who leverage these should read the internal documentation of the methods directly.

Applied to files:

  • docs/models/enums.mdx
  • docs/environments/core.mdx
  • docs/functions/rpc.mdx
  • docs/getting-started/migration-v3-to-v4.mdx
  • docs/index.mdx
  • docs/environments/serverpod.mdx
  • docs/environments/flutter.mdx
  • docs/getting-started/index.mdx
📚 Learning: 2025-12-08T17:28:59.275Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen_serverpod/example/example_server/test/integration/greeting_endpoint_test.dart:6-12
Timestamp: 2025-12-08T17:28:59.275Z
Learning: In packages/supabase_codegen_serverpod/example/example_server/test/integration/greeting_endpoint_test.dart, the integration tests are intentionally skipped by default (SKIP_GREETING_INTEGRATION_TEST with defaultValue: true) because the test setup is more extensive than needed for the project at this time. The run pipeline may be updated in the future to enable these tests if deemed necessary.

Applied to files:

  • docs/environments/core.mdx
  • docs/environments/serverpod.mdx
  • docs/environments/flutter.mdx
📚 Learning: 2025-12-05T21:36:42.890Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/bin/sql/get_rpc_functions.dart:18-18
Timestamp: 2025-12-05T21:36:42.890Z
Learning: For supabase_codegen RPC function generation: the initial implementation (PR #82) is intentionally scoped to discover RPC functions only in the 'public' schema. Multi-schema support is planned for a subsequent PR.

Applied to files:

  • docs/functions/rpc.mdx
  • docs/environments/serverpod.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (12)
docs/environments/core.mdx (1)

1-99: LGTM! Clear and comprehensive Core Dart documentation.

The documentation is well-structured with clear setup instructions, CLI usage examples, and multiple client configuration options. The version numbers are consistent with the migration guide, and the commands are accurate.

docs/getting-started/index.mdx (1)

1-78: LGTM! Excellent getting started guide.

The documentation provides a clear, consistent introduction to Supabase Codegen with well-organized tabs for different environments. The version numbers and commands are accurate and consistent across all sections.

docs/environments/serverpod.mdx (1)

1-92: LGTM! Clear Serverpod integration documentation.

The documentation provides comprehensive guidance for integrating Supabase Codegen with Serverpod, including helpful type mappings and important exclusion notes. The structure is logical and easy to follow.

docs/index.mdx (1)

1-55: LGTM! Welcoming and informative landing page.

The documentation homepage effectively introduces Supabase Codegen with clear navigation to key resources and well-articulated use cases for different development scenarios.

docs/getting-started/migration-v3-to-v4.mdx (1)

1-68: LGTM! Comprehensive migration guide.

The migration guide clearly documents breaking changes, new features, and provides step-by-step instructions for upgrading from v3 to v4. The warnings about dependency conflicts are particularly helpful.

docs/environments/flutter.mdx (4)

79-82: Verify the service client getters exist.

Please confirm that authClient, storageClient, functionsClient, and realtimeClient getters are exported and available in the supabase_codegen_flutter package.


58-58: The supabase_codegen_flutter:generate_types command is properly implemented and accessible. The executable is registered in pubspec.yaml and the corresponding generate_types.dart implementation file exists in the bin directory.


66-67: The loadClientFromEnv() function is confirmed to exist in the supabase_codegen_flutter package. It extracts configuration keys from the environment file (via DotEnv().extractKeys()) and initializes the Supabase client, as documented.


90-93: The documentation example is accurate. The queryRows() method exists in the SupabaseTable base class and is callable without parameters since both queryFn and limit arguments are optional. The generated table classes inherit this method and the example correctly demonstrates its usage.

docs/models/tables.mdx (3)

86-86: Remove copyWith usage from documentation—the method is not generated for row classes.

The SupabaseDataRow base class and generated row classes do not include a copyWith method. The update example at line 86 showing profile.copyWith(bio: 'Senior Software Engineer') will fail at runtime. Either implement copyWith generation for row classes or update the documentation to show alternative update patterns.

Likely an incorrect or invalid review comment.


74-88: CRUD method examples are accurate and match the generated API.

The insert, querySingleRow, and update methods exist with the correct signatures, and field constants are generated as static const strings (e.g., ProfilesRow.emailField). The documentation examples correctly reflect the actual implementation, including the use of copyWith on row objects and the pattern of passing field constants to query/update operations.


34-64: The generated code example is accurate and matches the actual code generation implementation. All base classes, helper functions, and patterns documented are correctly implemented in the codebase.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

♻️ Duplicate comments (5)
docs/environments/flutter.mdx (1)

40-40: Verify the init command is registered as an executable.

A previous review flagged that dart run supabase_codegen_flutter:init may not be available if the init command isn't registered in the package's pubspec.yaml executables section. Confirm this command works as documented or update the documentation accordingly.

#!/bin/bash
# Verify init command is registered in supabase_codegen_flutter

echo "=== Checking pubspec.yaml for init executable ==="
if [ -f "packages/supabase_codegen_flutter/pubspec.yaml" ]; then
  echo "Found pubspec.yaml, checking executables section:"
  rg -A 10 "executables:" packages/supabase_codegen_flutter/pubspec.yaml || echo "No executables section found"
  
  echo -e "\n=== Checking if init.dart exists ==="
  if [ -f "packages/supabase_codegen_flutter/bin/init.dart" ]; then
    echo "✓ init.dart exists"
  else
    echo "✗ init.dart not found"
  fi
else
  echo "✗ pubspec.yaml not found at expected location"
fi
docs/models/enums.mdx (1)

48-51: Fix code block formatting in CodeGroup.

The code examples are compressed into single lines, which will render poorly. Each code block should use proper multi-line formatting.

🔎 Proposed fix for better formatting
 <CodeGroup>
-  ```dart // By name final parsedRole = UserRole.values.byName("moderator"); ```
-  ```dart // To string print(UserRole.admin.name); // "admin" ```
+  ```dart
+  // By name
+  final parsedRole = UserRole.values.byName("moderator");
+  ```
+  ```dart
+  // To string
+  print(UserRole.admin.name); // "admin"
+  ```
 </CodeGroup>
docs/functions/rpc.mdx (3)

43-43: Fix code block syntax error.

Line 43 has four backticks instead of three, which will break the code block rendering.

🔎 Proposed fix
-````
+```
 </Accordion>

51-51: Fix code block syntax error.

Line 51 has four backticks instead of three, which will break the code block rendering.

🔎 Proposed fix
-````
+```

53-56: Consider documenting schema limitation.

The Info block mentions that internal Supabase RPCs are excluded, but doesn't mention that RPC function generation is currently scoped to the 'public' schema only. Users with functions in other schemas may be confused when their functions aren't discovered.

Based on learnings, consider adding a note about this limitation to set proper expectations.

💡 Suggested addition
 <Info>
-  Internal Supabase RPCs (like `get_schema_info`) are excluded by default for
-  security and clarity.
+  **Note:** RPC function generation is currently limited to the `public` schema.
+  Internal Supabase RPCs (like `get_schema_info`) are excluded by default for
+  security and clarity. If your functions are in other schemas, they won't be
+  discovered automatically.
 </Info>
📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dfa7364 and 3d2c0ad.

📒 Files selected for processing (9)
  • docs.json
  • docs/environments/core.mdx
  • docs/environments/flutter.mdx
  • docs/environments/serverpod.mdx
  • docs/functions/rpc.mdx
  • docs/getting-started/index.mdx
  • docs/index.mdx
  • docs/models/enums.mdx
  • docs/models/tables.mdx
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/bin/sql/get_rpc_functions.dart:18-18
Timestamp: 2025-12-05T21:36:42.890Z
Learning: For supabase_codegen RPC function generation: the initial implementation (PR #82) is intentionally scoped to discover RPC functions only in the 'public' schema. Multi-schema support is planned for a subsequent PR.
📚 Learning: 2025-12-08T19:48:00.427Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/lib/src/generator/generator.dart:6-7
Timestamp: 2025-12-08T19:48:00.427Z
Learning: In packages/supabase_codegen/lib/src/generator/generator.dart, the exports for rpcs/_rpcs.dart and utils/utils.dart are intended for use by other internal projects within the organization, not for external public consumption. Advanced external users who leverage these should read the internal documentation of the methods directly.

Applied to files:

  • docs/getting-started/index.mdx
  • docs/functions/rpc.mdx
  • docs/environments/flutter.mdx
  • docs/models/enums.mdx
  • docs/environments/serverpod.mdx
  • docs/environments/core.mdx
  • docs/index.mdx
📚 Learning: 2025-12-08T17:28:59.275Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen_serverpod/example/example_server/test/integration/greeting_endpoint_test.dart:6-12
Timestamp: 2025-12-08T17:28:59.275Z
Learning: In packages/supabase_codegen_serverpod/example/example_server/test/integration/greeting_endpoint_test.dart, the integration tests are intentionally skipped by default (SKIP_GREETING_INTEGRATION_TEST with defaultValue: true) because the test setup is more extensive than needed for the project at this time. The run pipeline may be updated in the future to enable these tests if deemed necessary.

Applied to files:

  • docs/getting-started/index.mdx
  • docs/environments/flutter.mdx
  • docs/environments/serverpod.mdx
  • docs/environments/core.mdx
📚 Learning: 2025-12-05T21:36:42.890Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/bin/sql/get_rpc_functions.dart:18-18
Timestamp: 2025-12-05T21:36:42.890Z
Learning: For supabase_codegen RPC function generation: the initial implementation (PR #82) is intentionally scoped to discover RPC functions only in the 'public' schema. Multi-schema support is planned for a subsequent PR.

Applied to files:

  • docs/functions/rpc.mdx
  • docs/environments/serverpod.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (9)
docs/environments/core.mdx (2)

1-99: LGTM!

The documentation is well-structured with clear sections for installation, setup, CLI usage, and client configuration. The use of tabs for different initialization methods provides good UX.


16-16: Update the package version to the latest available on pub.dev.

The specified version ^4.0.0 does not exist on pub.dev. The latest version of supabase_codegen is 3.0.1. Update this constraint to ^3.0.1 (or an appropriate version that exists), and verify the same version is corrected across all documentation files that reference it.

⛔ Skipped due to learnings
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/lib/src/generator/generator.dart:6-7
Timestamp: 2025-12-08T19:48:00.427Z
Learning: In packages/supabase_codegen/lib/src/generator/generator.dart, the exports for rpcs/_rpcs.dart and utils/utils.dart are intended for use by other internal projects within the organization, not for external public consumption. Advanced external users who leverage these should read the internal documentation of the methods directly.
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/bin/sql/get_rpc_functions.dart:18-18
Timestamp: 2025-12-05T21:36:42.890Z
Learning: For supabase_codegen RPC function generation: the initial implementation (PR #82) is intentionally scoped to discover RPC functions only in the 'public' schema. Multi-schema support is planned for a subsequent PR.
docs/models/enums.mdx (1)

1-47: LGTM!

The enum documentation clearly explains the mapping between PostgreSQL and Dart enums, with good examples and proper warnings about regenerating types.

Also applies to: 52-56

docs/getting-started/index.mdx (1)

1-37: LGTM!

The getting started guide provides a clear overview of the three package variants and a straightforward quick start workflow. The CardGroup presentation is effective.

Also applies to: 49-53, 65-69

docs/index.mdx (1)

1-47: LGTM!

The main documentation index provides an excellent overview with clear navigation to key sections. The use of CardGroup and Tabs effectively showcases the package's capabilities and use cases.

docs.json (1)

1-109: LGTM!

The documentation site configuration is well-structured with clear navigation sections and appropriate metadata. The sidebar organization logically groups content by General, Getting Started, Environments, Models, Functions, and Packages.

docs/environments/serverpod.mdx (1)

1-84: LGTM!

The Serverpod documentation is comprehensive and well-structured. It clearly explains the setup process, type mappings, and important exclusions. The use of Steps and Info components enhances readability.

docs/environments/flutter.mdx (1)

1-39: LGTM!

The Flutter documentation provides clear guidance on installation, setup, and integration. The automatic environment loading feature and service getters are well-documented with practical examples.

Also applies to: 41-86

docs/models/tables.mdx (1)

1-86: LGTM!

The tables documentation effectively explains the generated classes with clear examples. The use of an Accordion for the generated code example is a good UX decision, and the CRUD operation examples are practical and easy to follow.

{
"name": "Supabase Codegen",
"description": "Generate type-safe Dart models from your Supabase database.",
"favicon": "https://raw.githubusercontent.com/Khuwn-Soulutions/supabase_codegen/main/assets/logo.png",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify GitHub URLs are accessible

echo "=== Checking favicon URL ==="
curl -I -s "https://raw.githubusercontent.com/Khuwn-Soulutions/supabase_codegen/main/assets/logo.png" | head -n 1

echo -e "\n=== Checking package tree URLs ==="
for path in \
  "packages/supabase_codegen" \
  "packages/supabase_codegen_flutter" \
  "packages/supabase_codegen_serverpod"; do
  echo "Checking: $path"
  curl -I -s "https://github.com/Khuwn-Soulutions/supabase_codegen/tree/main/$path" | head -n 1
done

echo -e "\n=== Verifying package directories exist locally ==="
for dir in packages/supabase_codegen packages/supabase_codegen_flutter packages/supabase_codegen_serverpod; do
  if [ -d "$dir" ]; then
    echo "$dir exists"
  else
    echo "$dir not found"
  fi
done

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 495


🏁 Script executed:

cat -n docs.json

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 3295


Fix broken favicon URL.

The favicon URL on line 4 returns a 404 error and is not accessible. The referenced asset path does not exist or is unavailable. The package links on lines 96-105 are accessible and valid.

🤖 Prompt for AI Agents
In docs.json around line 4, the configured favicon URL
("https://raw.githubusercontent.com/Khuwn-Soulutions/supabase_codegen/main/assets/logo.png")
is broken (404); replace it with a valid, accessible favicon URL (e.g., point to
an existing asset in this repo or the working package assets referenced on lines
96-105), update the JSON value to that new URL, and verify the new link returns
HTTP 200 and serves an image.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/supabase_codegen_flutter/bin/init.dart (1)

8-12: Unawaited Future — consider making main async.

initializeConfiguration() returns Future<void>, but the synchronous arrow function doesn't await it. This means the process may exit before configuration completes, especially if the function performs async I/O operations.

🔎 Proposed fix
 /// Call the supabase_codegen init with relevant environment
-void main() => initializeConfiguration(
+Future<void> main() => initializeConfiguration(
   forFlutter: true,
   defaultEnvPath: defaultEnvFile,
   defaultOutputPath: defaultOutputPath,
 );

Or, if you also need to call checkMigration() for consistency with the core package:

 /// Call the supabase_codegen init with relevant environment
-void main() => initializeConfiguration(
-  forFlutter: true,
-  defaultEnvPath: defaultEnvFile,
-  defaultOutputPath: defaultOutputPath,
-);
+Future<void> main() async {
+  await initializeConfiguration(
+    forFlutter: true,
+    defaultEnvPath: defaultEnvFile,
+    defaultOutputPath: defaultOutputPath,
+  );
+  // await checkMigration(); // if needed for consistency
+}
📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d2c0ad and f70b093.

📒 Files selected for processing (15)
  • docs/functions/rpc.mdx
  • packages/supabase_codegen/bin/add_codegen_functions.dart
  • packages/supabase_codegen/bin/generate_types.dart
  • packages/supabase_codegen/bin/init.dart
  • packages/supabase_codegen/lib/init/init.dart
  • packages/supabase_codegen/lib/migrations/check_migration.dart
  • packages/supabase_codegen/lib/migrations/migrations.dart
  • packages/supabase_codegen/lib/migrations/sql/codegen_sql_function.dart
  • packages/supabase_codegen/lib/migrations/sql/get_enum_types.dart
  • packages/supabase_codegen/lib/migrations/sql/get_rpc_functions.dart
  • packages/supabase_codegen/lib/migrations/sql/get_schema_info.dart
  • packages/supabase_codegen/lib/migrations/sql/sql.dart
  • packages/supabase_codegen_flutter/bin/init.dart
  • packages/supabase_codegen_flutter/pubspec.yaml
  • packages/supabase_codegen_serverpod/bin/init.dart
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/bin/sql/get_rpc_functions.dart:18-18
Timestamp: 2025-12-05T21:36:42.890Z
Learning: For supabase_codegen RPC function generation: the initial implementation (PR #82) is intentionally scoped to discover RPC functions only in the 'public' schema. Multi-schema support is planned for a subsequent PR.
📚 Learning: 2025-12-08T19:48:00.427Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/lib/src/generator/generator.dart:6-7
Timestamp: 2025-12-08T19:48:00.427Z
Learning: In packages/supabase_codegen/lib/src/generator/generator.dart, the exports for rpcs/_rpcs.dart and utils/utils.dart are intended for use by other internal projects within the organization, not for external public consumption. Advanced external users who leverage these should read the internal documentation of the methods directly.

Applied to files:

  • packages/supabase_codegen_flutter/pubspec.yaml
  • packages/supabase_codegen/lib/migrations/migrations.dart
  • packages/supabase_codegen_flutter/bin/init.dart
  • packages/supabase_codegen/lib/migrations/check_migration.dart
  • packages/supabase_codegen_serverpod/bin/init.dart
  • docs/functions/rpc.mdx
  • packages/supabase_codegen/bin/init.dart
  • packages/supabase_codegen/lib/init/init.dart
  • packages/supabase_codegen/bin/generate_types.dart
  • packages/supabase_codegen/bin/add_codegen_functions.dart
📚 Learning: 2025-12-22T14:30:19.980Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 89
File: packages/supabase_codegen_templates/tables_and_enums/__brick__/tables/{{#tables}}{{{name}}}.dart{{/tables}}:30-31
Timestamp: 2025-12-22T14:30:19.980Z
Learning: In Dart 3.8+, use null-aware element syntax to include map entries only when the value is non-null, e.g. {key: ?value} omits the entry if value is null. Prefer this over conditional map entries like if (value != null) key: value. Apply this pattern to all Dart files where map literals are constructed to improve readability and avoid extra conditionals.

Applied to files:

  • packages/supabase_codegen/lib/migrations/migrations.dart
  • packages/supabase_codegen_flutter/bin/init.dart
  • packages/supabase_codegen/lib/migrations/check_migration.dart
  • packages/supabase_codegen_serverpod/bin/init.dart
  • packages/supabase_codegen/bin/init.dart
  • packages/supabase_codegen/lib/init/init.dart
  • packages/supabase_codegen/bin/generate_types.dart
  • packages/supabase_codegen/bin/add_codegen_functions.dart
📚 Learning: 2025-12-05T21:36:42.890Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/bin/sql/get_rpc_functions.dart:18-18
Timestamp: 2025-12-05T21:36:42.890Z
Learning: For supabase_codegen RPC function generation: the initial implementation (PR #82) is intentionally scoped to discover RPC functions only in the 'public' schema. Multi-schema support is planned for a subsequent PR.

Applied to files:

  • packages/supabase_codegen/lib/migrations/check_migration.dart
  • docs/functions/rpc.mdx
  • packages/supabase_codegen/bin/generate_types.dart
  • packages/supabase_codegen/bin/add_codegen_functions.dart
📚 Learning: 2025-12-08T17:28:59.275Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen_serverpod/example/example_server/test/integration/greeting_endpoint_test.dart:6-12
Timestamp: 2025-12-08T17:28:59.275Z
Learning: In packages/supabase_codegen_serverpod/example/example_server/test/integration/greeting_endpoint_test.dart, the integration tests are intentionally skipped by default (SKIP_GREETING_INTEGRATION_TEST with defaultValue: true) because the test setup is more extensive than needed for the project at this time. The run pipeline may be updated in the future to enable these tests if deemed necessary.

Applied to files:

  • packages/supabase_codegen_serverpod/bin/init.dart
  • packages/supabase_codegen/bin/init.dart
📚 Learning: 2025-12-08T19:55:36.377Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/lib/src/generator/generator_config/rpc/rpc_return_config.dart:13-20
Timestamp: 2025-12-08T19:55:36.377Z
Learning: In packages/supabase_codegen, the fromJson factory methods in configuration classes (e.g., RpcReturnTypeConfig, RpcConfig, GeneratorConfig) are intended only for internal round-trip serialization from toJson, not for deserializing external or user-provided JSON. Therefore, they do not require defensive error handling for invalid enum names or malformed structures.

Applied to files:

  • docs/functions/rpc.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (9)
docs/functions/rpc.mdx (1)

53-55: Well done addressing the schema limitation documentation.

This Info block clearly documents the public schema restriction, addressing the previous review feedback. Users now have proper expectations about RPC discovery scope.

Based on learnings, this limitation is intentional and accurately documented.

packages/supabase_codegen/bin/add_codegen_functions.dart (1)

1-5: LGTM!

Clean delegation to the centralized migrations module. The async/await pattern is correctly applied.

packages/supabase_codegen/lib/migrations/migrations.dart (1)

1-2: LGTM!

Clean barrel file that centralizes migration exports. This aligns with the broader refactor to consolidate migration-related APIs.

packages/supabase_codegen_flutter/pubspec.yaml (1)

34-37: LGTM!

The new init executable is correctly added, following the existing pattern. This enables users to run dart run supabase_codegen_flutter:init to initialize Flutter-specific configuration.

packages/supabase_codegen/bin/generate_types.dart (1)

3-10: LGTM!

The migration check is appropriately invoked before type generation, ensuring that any necessary database migrations are applied first. The import refactor to use the centralized migrations barrel is correct.

packages/supabase_codegen/bin/init.dart (1)

1-8: LGTM!

The initialization sequence correctly awaits configuration setup before checking migrations. The async conversion and import additions are properly implemented.

packages/supabase_codegen_serverpod/bin/init.dart (1)

8-14: Verify if checkMigration() should be called here for consistency.

The core package's bin/init.dart calls both initializeConfiguration() and checkMigration(), but this Serverpod variant only calls initializeConfiguration() followed by addExtraClassesToGeneratorConfig().

If the migration check is intentionally omitted for Serverpod (e.g., migrations are handled elsewhere), this is fine. Otherwise, consider adding the checkMigration() call for consistency with the core package.

packages/supabase_codegen/lib/init/init.dart (1)

9-12: LGTM!

The rename from init() to initializeConfiguration() improves API clarity. The function signature and delegation pattern are correct—returning Future<void> from main() ensures the Dart runtime awaits completion.

packages/supabase_codegen/lib/migrations/check_migration.dart (1)

19-31: LGTM!

Clean orchestration function with proper null handling and Dart 3 record destructuring.

Comment on lines +114 to +129
/// Extract the path from the given [input]
String extractPath(String input) {
// Define a regular expression to match the path
final pathRegExp = RegExp(r'\b\w+/\w+/\d+_\w+\.sql\b');

// Find the match in the input string
final Match? match = pathRegExp.firstMatch(input);

// If a match is found, return the matched path
if (match != null) {
return match.group(0)!;
}

// If no match is found, return an empty string or handle it as needed
return '';
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, locate and examine the extractPath function
find . -name "check_migration.dart" -type f

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 140


🏁 Script executed:

# Search for any test files related to check_migration
fd -type f -name "*check_migration*" -o -name "*test*" | grep -i "check_migration\|test.*migration"

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 247


🏁 Script executed:

# Search for usages of extractPath function
rg -n "extractPath" --type dart

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 296


🏁 Script executed:

# Read the file to see the context of extractPath usage
cat -n ./packages/supabase_codegen/lib/migrations/check_migration.dart | head -130 | tail -40

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 1434


🏁 Script executed:

# Search for test files in the project
find . -type f -name "*.dart" | grep -i test

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 6463


🏁 Script executed:

# Search specifically for any tests of check_migration
rg -l "check_migration" --type dart

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 133


🏁 Script executed:

# Search for migration-related tests or references
rg "extractPath|check_migration" --type dart -i

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 377


🏁 Script executed:

# Check the migrations.dart file to see if there are any other references or tests
cat -n ./packages/supabase_codegen/lib/migrations/migrations.dart | head -50

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 144


🏁 Script executed:

# Look for any test files that might test migration functionality
find ./packages/supabase_codegen/test -name "*migration*" -type f

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 59


🏁 Script executed:

# Check if there are any comments or documentation about Supabase migration output format
rg "supabase migration" -i --type dart -C 3

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 59


🏁 Script executed:

# Look at the entire check_migration.dart file to understand the context better
cat -n ./packages/supabase_codegen/lib/migrations/check_migration.dart

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 4934


🏁 Script executed:

# Search for any Supabase CLI output examples in docs or tests
rg "20\d{2}\d{2}\d{2}" --type dart

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 344


🏁 Script executed:

# Search for any Supabase CLI related documentation or comments in the codebase
rg -i "supabase.*migration.*new\|supabase.*output" --type dart -C 2

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 59


🏁 Script executed:

# Check if there are any issues or comments about Supabase CLI output format
rg -i "cli.*output\|stdout" ./packages/supabase_codegen/lib/migrations/check_migration.dart -C 2

Repository: Khuwn-Soulutions/supabase_codegen

Length of output: 59


🌐 Web query:

Supabase CLI migration new command output format path

💡 Result:

The command creates a file under a local supabase/migrations directory with the name format:

supabase/migrations/_<migration_name>.sql

(e.g. supabase/migrations/20230306095710_schema_test.sql). [1][2]

Sources:
[1] Supabase CLI docs — supabase migration new.
[2] Supabase docs — creating/pulling migrations (supabase/migrations/_*.sql).


Add tests for extractPath() to prevent regressions if the Supabase CLI output format changes.

The regex pattern works correctly for the documented Supabase migration output format (supabase/migrations/<timestamp>_<name>.sql). However, there are no tests for this function. Since it depends on external tool output, adding test cases would catch potential breakage if the Supabase CLI output format changes in the future. The error handling is defensive—returning an empty string and relying on the caller to log detailed CLI output for debugging—which is good, but tests would provide additional safety.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbf79cc and 2b93d16.

📒 Files selected for processing (5)
  • docs/functions/rpc.mdx
  • packages/supabase_codegen/lib/migrations/sql/get_enum_types.dart
  • packages/supabase_codegen/lib/migrations/sql/get_rpc_functions.dart
  • packages/supabase_codegen/lib/migrations/sql/get_schema_info.dart
  • packages/supabase_codegen/lib/migrations/sql/sql.dart
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-12-08T19:48:00.427Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/lib/src/generator/generator.dart:6-7
Timestamp: 2025-12-08T19:48:00.427Z
Learning: In packages/supabase_codegen/lib/src/generator/generator.dart, the exports for rpcs/_rpcs.dart and utils/utils.dart are intended for use by other internal projects within the organization, not for external public consumption. Advanced external users who leverage these should read the internal documentation of the methods directly.

Applied to files:

  • docs/functions/rpc.mdx
  • packages/supabase_codegen/lib/migrations/sql/get_schema_info.dart
  • packages/supabase_codegen/lib/migrations/sql/get_enum_types.dart
  • packages/supabase_codegen/lib/migrations/sql/get_rpc_functions.dart
  • packages/supabase_codegen/lib/migrations/sql/sql.dart
📚 Learning: 2025-12-05T21:36:42.890Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/bin/sql/get_rpc_functions.dart:18-18
Timestamp: 2025-12-05T21:36:42.890Z
Learning: For supabase_codegen RPC function generation: the initial implementation (PR #82) is intentionally scoped to discover RPC functions only in the 'public' schema. Multi-schema support is planned for a subsequent PR.

Applied to files:

  • docs/functions/rpc.mdx
  • packages/supabase_codegen/lib/migrations/sql/get_schema_info.dart
  • packages/supabase_codegen/lib/migrations/sql/get_enum_types.dart
  • packages/supabase_codegen/lib/migrations/sql/get_rpc_functions.dart
  • packages/supabase_codegen/lib/migrations/sql/sql.dart
📚 Learning: 2025-12-08T19:55:36.377Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/lib/src/generator/generator_config/rpc/rpc_return_config.dart:13-20
Timestamp: 2025-12-08T19:55:36.377Z
Learning: In packages/supabase_codegen, the fromJson factory methods in configuration classes (e.g., RpcReturnTypeConfig, RpcConfig, GeneratorConfig) are intended only for internal round-trip serialization from toJson, not for deserializing external or user-provided JSON. Therefore, they do not require defensive error handling for invalid enum names or malformed structures.

Applied to files:

  • docs/functions/rpc.mdx
📚 Learning: 2025-12-22T14:30:19.980Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 89
File: packages/supabase_codegen_templates/tables_and_enums/__brick__/tables/{{#tables}}{{{name}}}.dart{{/tables}}:30-31
Timestamp: 2025-12-22T14:30:19.980Z
Learning: In Dart 3.8+, use null-aware element syntax to include map entries only when the value is non-null, e.g. {key: ?value} omits the entry if value is null. Prefer this over conditional map entries like if (value != null) key: value. Apply this pattern to all Dart files where map literals are constructed to improve readability and avoid extra conditionals.

Applied to files:

  • packages/supabase_codegen/lib/migrations/sql/get_schema_info.dart
  • packages/supabase_codegen/lib/migrations/sql/get_enum_types.dart
  • packages/supabase_codegen/lib/migrations/sql/get_rpc_functions.dart
  • packages/supabase_codegen/lib/migrations/sql/sql.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (5)
packages/supabase_codegen/lib/migrations/sql/get_schema_info.dart (1)

1-1: LGTM: Package import improves maintainability.

The change from a relative import to a package import follows Dart best practices and improves refactoring safety and IDE support.

packages/supabase_codegen/lib/migrations/sql/get_enum_types.dart (1)

1-1: LGTM: Consistent with package import refactor.

The import path change aligns with the refactoring applied across all SQL migration files, ensuring consistency.

packages/supabase_codegen/lib/migrations/sql/get_rpc_functions.dart (1)

1-1: LGTM: Package import refactor complete.

This completes the consistent migration to package imports across all SQL migration files in the module.

packages/supabase_codegen/lib/migrations/sql/sql.dart (1)

1-10: Well-structured barrel file for SQL migrations.

The new aggregator module follows Dart conventions and provides a clean public API surface. The sqlFunctions list offers convenient access to all migration DDL statements.

docs/functions/rpc.mdx (1)

195-203: Well documented limitations.

The Notes section clearly communicates important constraints about schema scope and internal RPC exclusions, which properly sets user expectations. This addresses previous feedback about documenting the public schema limitation.

Based on learnings, the 'public' schema limitation is intentional for the initial implementation, with multi-schema support planned for a subsequent release.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
packages/supabase_codegen/lib/migrations/check_migration.dart (1)

88-103: Check CLI exit code before processing output.

The previous review comment about checking result.exitCode before extracting the path has not been addressed. The CLI command may fail for various reasons (CLI not installed, permission issues, etc.), but only path extraction failure is handled.

🔎 Proposed fix
   /// Create new migration using supabase CLI
   final result = await Process.run('supabase', [
     'migration',
     'new',
     name,
   ], runInShell: true);

+  /// Check if CLI command succeeded
+  if (result.exitCode != 0) {
+    logger
+      ..err('Supabase CLI failed to create migration.')
+      ..detail('Exit code: ${result.exitCode}')
+      ..detail('CLI stdout: ${result.stdout}')
+      ..detail('CLI stderr: ${result.stderr}');
+    return false;
+  }
+
   /// Read path of migration
   final path = extractPath(result.stdout.toString());
📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2b93d16 and c67d764.

📒 Files selected for processing (1)
  • packages/supabase_codegen/lib/migrations/check_migration.dart
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-12-08T19:48:00.427Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/lib/src/generator/generator.dart:6-7
Timestamp: 2025-12-08T19:48:00.427Z
Learning: In packages/supabase_codegen/lib/src/generator/generator.dart, the exports for rpcs/_rpcs.dart and utils/utils.dart are intended for use by other internal projects within the organization, not for external public consumption. Advanced external users who leverage these should read the internal documentation of the methods directly.

Applied to files:

  • packages/supabase_codegen/lib/migrations/check_migration.dart
📚 Learning: 2025-12-05T21:36:42.890Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/bin/sql/get_rpc_functions.dart:18-18
Timestamp: 2025-12-05T21:36:42.890Z
Learning: For supabase_codegen RPC function generation: the initial implementation (PR #82) is intentionally scoped to discover RPC functions only in the 'public' schema. Multi-schema support is planned for a subsequent PR.

Applied to files:

  • packages/supabase_codegen/lib/migrations/check_migration.dart
📚 Learning: 2025-12-22T14:30:19.980Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 89
File: packages/supabase_codegen_templates/tables_and_enums/__brick__/tables/{{#tables}}{{{name}}}.dart{{/tables}}:30-31
Timestamp: 2025-12-22T14:30:19.980Z
Learning: In Dart 3.8+, use null-aware element syntax to include map entries only when the value is non-null, e.g. {key: ?value} omits the entry if value is null. Prefer this over conditional map entries like if (value != null) key: value. Apply this pattern to all Dart files where map literals are constructed to improve readability and avoid extra conditionals.

Applied to files:

  • packages/supabase_codegen/lib/migrations/check_migration.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (2)
packages/supabase_codegen/lib/migrations/check_migration.dart (2)

53-72: Async file I/O now correctly used.

The synchronous readAsStringSync() has been replaced with await File(file).readAsString(), preventing event loop blocking. The logic for detecting function changes across migration files is sound.


114-129: Path extraction implementation is appropriate.

The regex correctly matches the documented Supabase migration output format. The defensive approach of returning an empty string allows the caller to provide detailed diagnostic information when extraction fails.

Comment on lines +19 to +31
/// Check for migration to apply to add or update codegen functions
Future<void> checkMigration() async {
final result = await getMigration();
if (result == null) {
logger.info('No migration to apply.');
return;
}

final (:migration, :name) = result;
logger.detail(dcli.green('Migration to add/update: $name'));
await addCodegenFunctionsMigration(migration: migration, name: name);
logger.success('Migration created please apply to your database.');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Success message logged regardless of actual outcome.

addCodegenFunctionsMigration can fail silently (early return on CLI failure or path extraction failure) without indicating failure. The success message on line 30 will still be logged, giving the user incorrect feedback.

Consider having addCodegenFunctionsMigration return a boolean or throw on failure, so checkMigration can conditionally log the success message.

🔎 Proposed fix
 /// Add codegen functions migration
-Future<void> addCodegenFunctionsMigration({
+Future<bool> addCodegenFunctionsMigration({
   required String migration,
   String name = _addFunctions,
 }) async {
   /// Create new migration using supabase CLI
   final result = await Process.run('supabase', [
     'migration',
     'new',
     name,
   ], runInShell: true);

   /// Read path of migration
   final path = extractPath(result.stdout.toString());
   if (path.isEmpty) {
     logger
       ..err('Failed to extract migration path from CLI output.')
       ..detail('CLI stdout: ${result.stdout}')
       ..detail('CLI stderr: ${result.stderr}');
-    return;
+    return false;
   }

   /// Write the sql functions to migration file
   path.write(migration);

   // Print result to shell
   // ignore: avoid_print
   final pathLink = link(uri: Uri.file(path), message: path);
   logger.info('Migration file created at: $pathLink');
+  return true;
 }

Then update checkMigration:

   final (:migration, :name) = result;
   logger.detail(dcli.green('Migration to add/update: $name'));
-  await addCodegenFunctionsMigration(migration: migration, name: name);
-  logger.success('Migration created please apply to your database.');
+  final success = await addCodegenFunctionsMigration(migration: migration, name: name);
+  if (success) {
+    logger.success('Migration created please apply to your database.');
+  }
 }
🤖 Prompt for AI Agents
In packages/supabase_codegen/lib/migrations/check_migration.dart around lines 19
to 31, the code always logs a success message even when
addCodegenFunctionsMigration may fail silently; change
addCodegenFunctionsMigration to either return a boolean indicating
success/failure or throw on error, then update checkMigration to await the call,
check the boolean (or wrap in try/catch) and only call logger.success when the
operation actually succeeded; on failure log an error message or rethrow the
exception so callers get correct feedback.

Comment on lines +105 to +106
/// Write the sql functions to migration file
path.write(migration);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Prefer async file write for consistency.

path.write(migration) uses dcli's synchronous String.write() extension. For consistency with the async approach used elsewhere in this file (e.g., readAsString), consider using await File(path).writeAsString(migration).

🔎 Proposed fix
   /// Write the sql functions to migration file
-  path.write(migration);
+  await File(path).writeAsString(migration);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Write the sql functions to migration file
path.write(migration);
/// Write the sql functions to migration file
await File(path).writeAsString(migration);
🤖 Prompt for AI Agents
In packages/supabase_codegen/lib/migrations/check_migration.dart around lines
105–106, the code uses the synchronous String.write() extension
(path.write(migration)) to write the migration; change this to an async file
write by using await File(path).writeAsString(migration), ensure the enclosing
function is marked async, import dart:io if missing, and propagate or handle the
returned Future (e.g., await the call) for consistency with other async I/O in
this file.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (3)
packages/supabase_codegen/lib/migrations/check_migration.dart (3)

19-31: Success message logged regardless of actual outcome.

addCodegenFunctionsMigration can fail silently (early return on lines 102 or 112) without indicating failure, yet the success message on line 30 will still be logged, giving incorrect feedback to the user.

This issue was previously flagged and remains unaddressed. Consider having addCodegenFunctionsMigration return a boolean or throw on failure, so checkMigration can conditionally log the success message only when the operation actually succeeds.


116-116: Prefer async file write for consistency.

path.write(migration) uses dcli's synchronous write operation, which blocks the event loop. Since this is already an async function and other file I/O in this file uses async methods (e.g., readAsString on line 55), using async file write here would be more consistent.

This issue was previously flagged and remains unaddressed.

🔎 Proposed fix
   /// Write the sql functions to migration file
-  path.write(migration);
+  await File(path).writeAsString(migration);

124-139: Consider adding tests for extractPath() to prevent regressions.

The regex pattern correctly handles the documented Supabase CLI migration output format (supabase/migrations/<timestamp>_<name>.sql). However, since this function depends on external tool output, adding test cases would provide safety if the CLI output format changes in future versions.

This suggestion was previously made and remains valid.

📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c67d764 and bbafe4c.

📒 Files selected for processing (1)
  • packages/supabase_codegen/lib/migrations/check_migration.dart
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/bin/sql/get_rpc_functions.dart:18-18
Timestamp: 2025-12-05T21:36:42.890Z
Learning: For supabase_codegen RPC function generation: the initial implementation (PR #82) is intentionally scoped to discover RPC functions only in the 'public' schema. Multi-schema support is planned for a subsequent PR.
📚 Learning: 2025-12-08T19:48:00.427Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 82
File: packages/supabase_codegen/lib/src/generator/generator.dart:6-7
Timestamp: 2025-12-08T19:48:00.427Z
Learning: In packages/supabase_codegen/lib/src/generator/generator.dart, the exports for rpcs/_rpcs.dart and utils/utils.dart are intended for use by other internal projects within the organization, not for external public consumption. Advanced external users who leverage these should read the internal documentation of the methods directly.

Applied to files:

  • packages/supabase_codegen/lib/migrations/check_migration.dart
📚 Learning: 2025-12-22T14:30:19.980Z
Learnt from: jwelmac
Repo: Khuwn-Soulutions/supabase_codegen PR: 89
File: packages/supabase_codegen_templates/tables_and_enums/__brick__/tables/{{#tables}}{{{name}}}.dart{{/tables}}:30-31
Timestamp: 2025-12-22T14:30:19.980Z
Learning: In Dart 3.8+, use null-aware element syntax to include map entries only when the value is non-null, e.g. {key: ?value} omits the entry if value is null. Prefer this over conditional map entries like if (value != null) key: value. Apply this pattern to all Dart files where map literals are constructed to improve readability and avoid extra conditionals.

Applied to files:

  • packages/supabase_codegen/lib/migrations/check_migration.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (3)
packages/supabase_codegen/lib/migrations/check_migration.dart (3)

9-17: LGTM!

The constants are well-named, appropriately scoped, and used consistently throughout the file.


33-81: LGTM!

The migration detection logic is well-structured and defensive. The use of async file I/O, sorted file processing, and list copies to avoid concurrent modification demonstrates good practices. The string-based function matching is pragmatic for this use case.


95-103: LGTM!

The exit code validation ensures that CLI failures are properly detected and reported before attempting to extract the migration path. This addresses the previously flagged issue and provides clear error diagnostics.

import 'package:dcli/dcli.dart' as dcli;
import 'package:mason_logger/mason_logger.dart';
import 'package:path/path.dart';
import 'package:supabase_codegen/migrations/migrations.dart';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Import sql.dart directly instead of the barrel file.

This file imports migrations.dart, which in turn exports this file (check_migration.dart) and sql.dart. Since the only symbol used from that import is sqlFunctions (defined in sql.dart), directly importing sql.dart would reduce coupling and avoid potential circular dependency issues.

🔎 Proposed fix
-import 'package:supabase_codegen/migrations/migrations.dart';
+import 'package:supabase_codegen/migrations/sql/sql.dart';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import 'package:supabase_codegen/migrations/migrations.dart';
import 'package:supabase_codegen/migrations/sql/sql.dart';
🤖 Prompt for AI Agents
In packages/supabase_codegen/lib/migrations/check_migration.dart around line 6,
the file currently imports the barrel file migrations.dart but only uses
sqlFunctions from sql.dart; replace the barrel import with a direct import of
sql.dart (e.g. import 'package:supabase_codegen/migrations/sql.dart';), remove
the existing migrations.dart import, and ensure any references to sqlFunctions
still resolve—this reduces coupling and avoids potential circular dependencies.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: add doc site

1 participant