# How to Downgrade Magento from Commerce to Open Source Using Opengento's Tool

Magento Commerce (EE) offers powerful features, but for many teams, Open Source (CE) is leaner, lighter, and more sustainable. If you're migrating from EE to CE, the [Opengento downgrade tool](https://github.com/opengento/magento2-downgrade-ee-ce) provides a clean, scriptable way to remove proprietary modules and reset your codebase.

Here’s how to use it safely and effectively.

---

### 🧰 Prerequisites

* Magento 2 Commerce installed (any version ≥ 2.3)
    
* Composer installed and configured
    
* Git version control (strongly recommended)
    
* Full backup of your codebase and database
    

---

### 🚀 Step-by-Step Downgrade

#### 1\. **Clone the downgrade tool**

bash

```bash
git clone https://github.com/opengento/magento2-downgrade-ee-ce.git
cd magento2-downgrade-ee-ce
```

#### 2\. **Copy the sample script**

bash

```bash
cp downgrade.sample downgrade.sh
chmod +x downgrade.sh
```

#### 3\. **Update** [`downgrade.sh`](http://downgrade.sh)

Edit the script to include SQL cleanup after the downgrade logic. Example addition at the end:

bash

```bash
# Apply SQL cleanup patches
mysql magento_db < ./scripts/attributes.sql
mysql magento_db < ./scripts/ee.sql
mysql magento_db < ./scripts/cms.sql
mysql magento_db < ./scripts/catalogrule.sql
mysql magento_db < ./scripts/salesrule.sql
mysql magento_db < ./scripts/category.sql
mysql magento_db < ./scripts/product.sql
mysql magento_db < ./scripts/cataloginventory.sql
mysql magento_db < ./scripts/customer.sql
mysql magento_db < ./scripts/quote.sql
mysql magento_db < ./scripts/sales.sql
mysql magento_db < ./scripts/wishlist.sql
```

Replace `magento_db` with your actual database name.

#### 4\. **Run the script**

bash

```bash
./downgrade.sh
```

This will:

* Remove EE modules
    
* Rewrite `composer.json`
    
* Apply SQL cleanup patches
    

### ✅ Final Steps

bash

```bash
composer install
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush
```
