Skip to content

Conversation

@yogeshmahajan-1903
Copy link
Contributor

@yogeshmahajan-1903 yogeshmahajan-1903 commented Jan 8, 2026

Summary by CodeRabbit

  • Chores
    • Bumped database schema version to v49.
    • Added a migration to convert primary key IDs to a larger integer type to support bigger IDs.
    • Updated the Database model to use larger integer type for the id field; related server reference remains unchanged.

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

@coderabbitai
Copy link

coderabbitai bot commented Jan 8, 2026

Walkthrough

Bumps schema version to 49, updates the Database model to use BigInteger for id, and adds an Alembic migration converting the database.id column from Integer to BigInteger; the migration implements upgrade() and a no-op downgrade() with a comment about pgAdmin downgrades.

Changes

Cohort / File(s) Summary
Database Schema Migration
web/migrations/versions/018e16dad6aa_.py
New Alembic migration (revision 018e16dad6aa) using batch_alter_table to change database.id from Integer to BigInteger; implements upgrade(); downgrade() is a documented no-op.
Schema Version & Model Update
web/pgadmin/model/__init__.py
SCHEMA_VERSION incremented 4849; Database.id column type changed from Integer to BigInteger (primary key preserved).

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: upgrading the database table's ID column from Integer to BigInteger to support large OID values, which directly matches the file changes in the migration and model updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ffa1a0b and 9557803.

📒 Files selected for processing (2)
  • web/migrations/versions/018e16dad6aa_.py
  • web/pgadmin/model/__init__.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/pgadmin/model/init.py
  • web/migrations/versions/018e16dad6aa_.py
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: run-python-tests-pg (windows-latest, 17)
  • GitHub Check: run-python-tests-pg (windows-latest, 15)
  • GitHub Check: run-python-tests-pg (ubuntu-22.04, 15)
  • GitHub Check: run-feature-tests-pg (17)
  • GitHub Check: run-javascript-tests (macos-latest)

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

@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

Caution

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

⚠️ Outside diff range comments (2)
web/pgadmin/model/__init__.py (2)

17-17: Fix typo in comment.

"migratio" should be "migration".

✏️ Proposed fix
-2) Create an Alembic migratio to ensure that the appropriate changes are
+2) Create an Alembic migration to ensure that the appropriate changes are

417-422: Critical type mismatch: Database.server column type doesn't match Server.id.

The migration script (018e16dad6aa_.py) only alters the database.id column to BigInteger, but the model changes the server column to BigInteger while Server.id remains Integer. This creates a foreign key constraint mismatch: a BigInteger column (Database.server) referencing an Integer primary key (Server.id).

To fix this:

  1. Server.id must be upgraded to BigInteger
  2. All foreign key columns referencing Server.id must also be upgraded to BigInteger: Process.server_id, QueryHistoryModel.sid, SharedServer.osid
  3. The migration script must be updated to handle all these changes, not just Database.id
🤖 Fix all issues with AI agents
In @web/migrations/versions/018e16dad6aa_.py:
- Around line 20-26: The Database ORM model's id column is still declared as
db.Integer but the migration alters the database to sa.BigInteger; update the
Database model's id declaration (the id = db.Column(...) in the Database model
class) to use db.BigInteger as the column type and keep primary_key=True so the
ORM matches the migrated schema.

In @web/pgadmin/model/__init__.py:
- Line 415: The model's Database.id column still uses db.Integer but the
migration changed it to BigInteger; update the Database class definition where
id = db.Column(...) to use db.BigInteger instead (e.g., id =
db.Column(db.BigInteger, primary_key=True)), and ensure the db/SQLAlchemy import
supports BigInteger so the model and migration types match.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62e2d18 and dc449b9.

📒 Files selected for processing (2)
  • web/migrations/versions/018e16dad6aa_.py
  • web/pgadmin/model/__init__.py
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: run-python-tests-pg (windows-latest, 15)
  • GitHub Check: run-feature-tests-pg (16)
  • GitHub Check: run-feature-tests-pg (18)
  • GitHub Check: run-feature-tests-pg (14)
  • GitHub Check: run-feature-tests-pg (17)
  • GitHub Check: run-feature-tests-pg (15)
  • GitHub Check: run-feature-tests-pg (13)
🔇 Additional comments (2)
web/pgadmin/model/__init__.py (1)

36-36: Schema version bump looks correct.

The version increment from 48 to 49 aligns with the addition of a new migration.

web/migrations/versions/018e16dad6aa_.py (1)

28-30: Downgrade not implemented - acceptable for pgAdmin upgrades.

The downgrade function is intentionally not implemented, which is consistent with pgAdmin's upgrade-only policy.

Copy link

@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: 0

Caution

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

⚠️ Outside diff range comments (1)
web/pgadmin/model/__init__.py (1)

417-422: Foreign key type mismatch with Server.id.

The server column is now BigInteger, but it references Server.id (line 191) which remains db.Integer. This creates a type mismatch in the foreign key relationship.

Additionally, per the AI summary, the migration only alters the id column—not the server column—so the physical schema won't match this model definition.

Since server stores pgAdmin's internal server ID (not a PostgreSQL OID), it likely doesn't need BigInteger. Consider keeping it as Integer to match Server.id:

Suggested fix
     server = db.Column(
-        db.BigInteger,
+        db.Integer,
         db.ForeignKey(SERVER_ID),
         nullable=False,
         primary_key=True
     )

Alternatively, if BigInteger is intentional here, then Server.id and the migration should also be updated for consistency.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc449b9 and 217fc7e.

📒 Files selected for processing (2)
  • web/migrations/versions/018e16dad6aa_.py
  • web/pgadmin/model/__init__.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/migrations/versions/018e16dad6aa_.py
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: run-feature-tests-pg (17)
  • GitHub Check: run-feature-tests-pg (18)
  • GitHub Check: run-feature-tests-pg (13)
  • GitHub Check: run-feature-tests-pg (16)
  • GitHub Check: run-feature-tests-pg (15)
  • GitHub Check: run-feature-tests-pg (14)
  • GitHub Check: run-python-tests-pg (windows-latest, 17)
🔇 Additional comments (2)
web/pgadmin/model/__init__.py (2)

36-36: LGTM!

Schema version correctly incremented to reflect the model changes, as required by the documented upgrade process.


415-415: LGTM!

Appropriate change to BigInteger for storing PostgreSQL OID values, which are unsigned 32-bit integers and can exceed the signed Integer range (~2.1 billion).

Copy link

@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

Caution

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

⚠️ Outside diff range comments (1)
web/pgadmin/model/__init__.py (1)

415-422: Critical: Foreign key type mismatch between Database.server and Server.id.

The Database.server column is changed to BigInteger (line 418) with ForeignKey(SERVER_ID), but it references server.id which is defined as Integer (line 191). This type mismatch violates foreign key constraints in most database backends. Additionally, this is inconsistent with other models—QueryHistoryModel.sid and SharedServer.osid both use Integer for their SERVER_ID foreign keys, making Database.server the only BigInteger reference to server.id.

Required: Either upgrade Server.id to BigInteger to support large OID values across all referencing models, or revert Database.server back to Integer to maintain consistency.

🤖 Fix all issues with AI agents
In @web/migrations/versions/018e16dad6aa_.py:
- Around line 28-33: The migration only alters Database.id to BigInteger but
misses updating the Database.server column; update the upgrade() function
(inside the existing with op.batch_alter_table("database") as batch_op block) to
also call batch_op.alter_column('server', existing_type=sa.Integer(),
type_=sa.BigInteger(), nullable=False) so the database.server column matches the
model change to BigInteger (Database.server).
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 217fc7e and ffa1a0b.

📒 Files selected for processing (2)
  • web/migrations/versions/018e16dad6aa_.py
  • web/pgadmin/model/__init__.py
🔇 Additional comments (2)
web/migrations/versions/018e16dad6aa_.py (1)

36-38: No-op downgrade is intentional per pgAdmin policy.

The downgrade function is a no-op, which aligns with pgAdmin's upgrade-only approach. This is acceptable and properly documented.

web/pgadmin/model/__init__.py (1)

36-36: LGTM: Schema version bumped appropriately.

The schema version increment from 48 to 49 follows the documented process and aligns with the model changes and migration being added.

@yogeshmahajan-1903 yogeshmahajan-1903 changed the title Upgrade ID column in the database table to BigInteger to support large OID values. Upgrade ID column in the database table to BigInteger to support large OID values.#9223 Jan 8, 2026
@akshay-joshi akshay-joshi merged commit bef374d into pgadmin-org:master Jan 8, 2026
35 of 37 checks passed
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.

2 participants