Skip to content

Remove organizations#3923

Merged
sumerjabri merged 1 commit into
craftercms:support/4.xfrom
jmendeza:feature/8652-4x
May 15, 2026
Merged

Remove organizations#3923
sumerjabri merged 1 commit into
craftercms:support/4.xfrom
jmendeza:feature/8652-4x

Conversation

@jmendeza
Copy link
Copy Markdown
Member

Remove organizations
craftercms/craftercms#8652

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

Review Change Stack

Summary by CodeRabbit

  • Refactor
    • Removed organization-level functionality and associated API response codes
    • Updated database schema version from 4.5.1.0 to 4.5.1.1
    • Restructured audit and group table definitions to remove organization references
    • Removed organization management tables and related mappings from the system

Walkthrough

This PR removes organization-related support across the audit system and domain models, including API response constants, AuditLog fields, service initialization, MyBatis persistence mappings, database schema tables, and data access layer queries, migrating the database schema from version 4.5.0.5 to 4.5.1.1.

Changes

Organization Support Removal

Layer / File(s) Summary
API Response Constants
src/main/java/org/craftercms/studio/model/rest/ApiResponse.java
Removes ORG_NOT_FOUND and ORG_ALREADY_EXISTS constants, causing API response codes to jump from 2001-range directly to 4000-range.
Audit Domain Model
src/main/java/org/craftercms/studio/api/v2/dal/AuditLog.java
Removes organizationId field and its public accessor/mutator methods (getOrganizationId, setOrganizationId) from the AuditLog DAL class.
Audit Service Implementation
src/main/java/org/craftercms/studio/impl/v2/service/audit/internal/AuditServiceInternalImpl.java
Updates createAuditLogEntry() to stop assigning organizationId to 1 while preserving other entry initialization logic.
Audit Persistence Mappings
src/main/resources/org/craftercms/studio/api/v2/dal/AuditDAO.xml
Removes organizationId mappings from AuditLogMap and AuditDashboardMap result maps and removes organization_id from the insertAuditLog statement.
Database Schema: Audit and Organization Tables
src/main/resources/crafter/studio/database/createDDL.sql
Removes organization_id column from the audit table, deletes organization and organization_user table definitions, redefines group table without org_id foreign key, and updates schema version to 4.5.1.1.
Security DAO: Remove Organization Association
src/main/resources/org/craftercms/studio/api/v2/dal/SecurityDAO.xml
Removes organization association mapping from GroupMap, deletes OrganizationMap resultMap, and removes selectOrganizationById SQL statement.
Database Migration: Upgrade Script and Pipeline
src/main/resources/crafter/studio/database/upgrade/4.5.x/4.5.1.0-to-4.5.1.1.sql, src/main/resources/crafter/studio/upgrade/pipelines.yaml
Creates new upgrade script that drops organization_id from audit table, removes org_id and foreign key from group table, and drops organization_user and organization tables. Registers the upgrade in the system pipeline for version transition 4.5.1.0 → 4.5.1.1.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • sumerjabri
🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Remove organizations' directly and clearly describes the main change: the removal of organization-related functionality across the codebase.
Description check ✅ Passed The description 'Remove organizations' with a reference to issue #8652 is directly related to the changeset, which comprehensively removes all organization-related entities and functionality.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/resources/crafter/studio/database/upgrade/4.5.x/4.5.1.0-to-4.5.1.1.sql`:
- Around line 19-22: The ALTER TABLE `group` statement uses unsupported `DROP
FOREIGN KEY IF EXISTS` syntax in MySQL; change the migration to first detect the
FK/index/column existence and only drop them if present: query
INFORMATION_SCHEMA.KEY_COLUMN_USAGE or INFORMATION_SCHEMA.STATISTICS to check
for foreign key `group_ix_org_id` and index `group_ix_org_id` and wrap the DROP
FOREIGN KEY `group_ix_org_id`, DROP INDEX `group_ix_org_id`, and DROP COLUMN
`org_id` operations inside conditional logic (or a small stored procedure/IF
block) so the migration does not use the invalid `IF EXISTS` clause and will
safely run on MySQL.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3c3cf4f6-4d09-47c3-8f96-a18bd0c79d2a

📥 Commits

Reviewing files that changed from the base of the PR and between 345455b and 2baa6ac.

📒 Files selected for processing (10)
  • src/main/api/studio-api.yaml
  • src/main/java/org/craftercms/studio/api/v2/dal/AuditLog.java
  • src/main/java/org/craftercms/studio/api/v2/dal/Organization.java
  • src/main/java/org/craftercms/studio/impl/v2/service/audit/internal/AuditServiceInternalImpl.java
  • src/main/java/org/craftercms/studio/model/rest/ApiResponse.java
  • src/main/resources/crafter/studio/database/createDDL.sql
  • src/main/resources/crafter/studio/database/upgrade/4.5.x/4.5.1.0-to-4.5.1.1.sql
  • src/main/resources/crafter/studio/upgrade/pipelines.yaml
  • src/main/resources/org/craftercms/studio/api/v2/dal/AuditDAO.xml
  • src/main/resources/org/craftercms/studio/api/v2/dal/SecurityDAO.xml
💤 Files with no reviewable changes (2)
  • src/main/java/org/craftercms/studio/api/v2/dal/Organization.java
  • src/main/api/studio-api.yaml

@jmendeza jmendeza marked this pull request as ready for review May 14, 2026 23:56
@jmendeza jmendeza requested a review from sumerjabri as a code owner May 14, 2026 23:56
@sumerjabri sumerjabri merged commit c6e5201 into craftercms:support/4.x May 15, 2026
2 of 4 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